WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Parse Variable Commandline Parameters


I have created some code to help with parsing the commandline parameters and assigning them to variables. This allows for dynamic parameters and to be entered in any order. Feel free to use it. If you make any improvements please post it back here for people to use. Thanks
pn=param0
p1=param%pn%

f1 = "-v"
f2 = "-t"
f3 = "-i"
f4 = "-s"
f5 = "-d"
f6 = "-u"
f7 = "-p"
f8 = "-l"
f9 = ""

fn = 9
f0 = f%fn%

pr = fn

count = pn

If pn > fn
Message("Guess What!", "You're a choad!")
Exit
EndIf

While @TRUE
If pn == 0
Break
Else
GoSub PARAMPARSER
fn = 9
pn = pn - 1
p1=param%pn%
EndIf
EndWhile

Message("You're Parameters are:", "Ver: %pra1%%@CRLF%Type: %pra2%%@CRLF%IP: %pra3%%@CRLF%Src: %pra4%%@CRLF%Dest: %pra5%%@CRLF%Usrname: %pra6%%@CRLF%Pwd: %pra7%%@CRLF%Log: %pra8%")

Exit

:PARAMPARSER

While @TRUE
If fn == 0
Break
EndIf

length = StrLen(p1)
start = 1

r1 = StrScan(p1, "=", start, @FWDSCAN)
fr = StrSub(p1, 1, r1 - 1)

If fr == "%f0%"
pra%fn% = StrSub(p1, r1 + 1, length)
EndIf

fn = fn - 1
f0 = f%fn%
EndWhile

Return

Article ID:   W17234
File Created: 2007:07:03:14:28:54
Last Updated: 2007:07:03:14:28:54