enko Posted March 30, 2004 Posted March 30, 2004 Was wondering if its possible to pass integers or variables through the command line, like: Program.exe -name enko -pin 0001 -age 89 -sex male then $name $pin $age & $sex would be those. Is this possible, if so how?
Guest rathore Posted March 30, 2004 Posted March 30, 2004 its possible using the array $CMDLINE $CMDLINE[0] stores the no. of parameters passed & $CMDLINE[1] & $CMDLINE[2] & so on store the parameter.
enko Posted March 30, 2004 Author Posted March 30, 2004 Program.exe -name enko -pin 0001 -age 89 -sex male so $CMDLINE[0] would = 4, $CMDLINE[1] = enko, $CMDLINE[2] = 0001 and so on? what if like there isnt a $CMDLINE[4]?
Helge Posted March 30, 2004 Posted March 30, 2004 Correct ! what if like there isnt a $CMDLINE[4]?What ?
Developers Jos Posted March 30, 2004 Developers Posted March 30, 2004 (edited) Nope.... $CMDLINE[0] = 8 $CMDLINE[1] = -name $CMDLINE[2] = enko $CMDLINE[3] = -pin $CMDLINE[4] = 0001 this is an example script you could use to test for commandline parameters: $BATCH = 0 $INSTALL=0 $NAME = "" $ADDR = "" $V_ARG = "Valid Arguments are:" & @LF & _ " /batch - text to explain option." & @LF & _ " /install - text to explain option." & @LF & _ " /n NAME - Name." & @LF & _ " /a Address - Address" & @LF For $X = 1 To $CMDLINE[0] $T_VAR = StringLower($CMDLINE[$X]) Select Case $T_VAR = "/batch" $BATCH = 1 Case $T_VAR = "/install" $INSTALL = 1 Case $T_VAR = "/n" $X = $X + 1 $NAME = $CMDLINE[$X] Case $T_VAR = "/a" $X = $X + 1 $ADDR = $CMDLINE[$X] Case Else If $BATCH = 0 Then MsgBox( 1, "Error", "Wrong commandline argument: " & $T_VAR & @LF & $V_ARG,) EndIf Exit EndSelect Next Edited March 30, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now