Jump to content

Command Line?


enko
 Share

Recommended Posts

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?

Link to comment
Share on other sites

Guest rathore

its possible using the array $CMDLINE

$CMDLINE[0] stores the no. of parameters passed & $CMDLINE[1] & $CMDLINE[2] & so on store the parameter.

Link to comment
Share on other sites

  • Developers

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 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.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...