Exercise one:

prefix/postfix, a few MsgBoxes, 
insert Numbers only, changeable separators,
OK.. just playing around a lil bit too :-D


_Thank you_ for your help, i need it.

Here is my modified version of your script:


' VB Script Document
' http://forum.pspad.com/read.php?2,40623
' Posted by: grigri | Date: 05/21/2007 14:05 
Const MODULE_NAME = "InsertNumberedLines2"
Const MODULE_VER = "0.1b"
Const MODULE_TITLE = "Insert Numbered Lines2"
Const strTitle = "PSPad: Set of lines w/ increasing values"
Const useNumOnly = "###"

Sub Init
addMenuItem MODULE_TITLE, "Utilities", MODULE_NAME
End Sub

Sub InsertNumberedLines2()
Dim editor
Set editor = newEditor()
editor.assignActiveEditor
If editor Is Nothing Then Exit Sub

Dim Items, Numbers, StartNumber, EndNumber, Increment, Digits, Postfix, Prefix,
mySeparator, mySepHint

Prefix = InputBox("[Step 1 of 5]" _
          & vbCrlf & "Additionally Prefix for the start of each line" _
          & vbCrlf & "Independently from the following line set" _
          & vbCrlf & "(Leave blank for nothing)",strTitle)

mySeparator = InputBox("[Step 2 of 5]" _
          & vbCrlf & "Separator to spilt the following items:",strTitle,",")

If mySeparator = "," Then
mySepHint = "comma"
ElseIf mySeparator = ";" Then
mySepHint = "semicolon"
ElseIf mySeparator = ":" Then
mySepHint = "colon"
Else
mySepHint = ""
End If


Items = InputBox("[Step 3 of 5]" _
          & vbCrlf & "Enter the line set items," _
          & vbCrlf & "one for each line of your periodic line set:" _
          & vbCrlf & "separated by your separator: >  " & mySeparator & "  < " &
mySepHint _
          & vbCrlf & vbCrlf & "Special: use " & useNumOnly & " to insert numbers
only.",strTitle)
'comma-separated," _
If Len(Items) = 0 Then 
MsgBox "You must enter some items. Please start the script new.",0, strTitle
Exit Sub
End If
Items = Split(Items, mySeparator)

Numbers = InputBox("[Step 4 of 5]" _
            & vbCrlf & "Enter the lines number sequence: " _ 
            & vbCrlf & vbCrlf & "Simple example: ""1,10"" Will go from 1 to 10,
no extra zeros" _
            & vbCrLf & vbCrLf & "Other example: ""001,003,011" _
            & vbCrLf & "Will do the odd numbers from 1 to 11, padding to 3
digits",strTitle,"001,005")
If Len(Numbers) = 0 Then 
MsgBox "You must enter some items. Please start the script new.",0, strTitle
Exit Sub
End If
Numbers = Split(Numbers, ",")

Postfix = InputBox("[Step 5 of 5]" _
            & vbCrlf & "Additionally Postfix for the end of each line "_
            & vbCrlf & "Independently from the line set" _
            & vbCrlf & "(leave blank for nothing):",strTitle,"=")

On Error Resume Next
If UBound(Numbers) = 1 Then
StartNumber = Int(Numbers(0))
EndNumber = Int(Numbers(1))
Increment = Sgn(EndNumber-StartNumber)
If Abs(StartNumber)<Abs(EndNumber) Then
Digits = Len(Numbers(0))
Else
Digits = Len(Numbers(1))
End If
ElseIf UBound(Numbers) = 2 Then
StartNumber = Int(Numbers(0))
Increment = Int(Numbers(1))-StartNumber
EndNumber = Int(Numbers(2))
If Sgn(Increment) <> Sgn(EndNumber-StartNumber) Then
MsgBox "Error: Impossible Sequence"
Exit Sub
End If
If Abs(StartNumber)<Abs(EndNumber) Then
Digits = Len(Numbers(0))
Else
Digits = Len(Numbers(2))
End If
Else
MsgBox "Error: Incorrect format of number sequence"
Exit Sub
End If
If Increment = 0 Then
MsgBox "There was an error in your number sequence, or it was too boring for me
to waste my processor time on"
Exit Sub
End If

Dim i, j, Number, Output
i = StartNumber

Output = ""
Do While Sgn(EndNumber-i)*Sgn(Increment) >= 0

If Items(0) = useNumOnly Then
Items(0) = "" 
End If

For j = 0 to UBound(Items)
Number = Right(String(Digits, "0") & CStr(Abs(i)), Digits)
If Sgn(i) < 0 Then Number = "-" & Number
Output = Output & Prefix & Items(j) & Number & Postfix & VbCrLf
Next
Output = Output '& VbCrLf

i = i + Increment
Loop

editor.selText Output

End Sub 


-- 
<http://forum.pspad.com/read.php?2,40623,40652>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem