Sign in to follow this  
Followers 0
nobbe

command line parameters

4 posts in this topic

some may find this useful to invoke a program with multiple parameters

CODE
;<exefilename> -t test -m lala

$ret = _ReadCmdLine("t");

MsgBox(0, "ret", $ret)

$ret = _ReadCmdLine("m");

MsgBox(0, "ret", $ret)

;

; read the command line parameters and return value

;

; options are separated by "-"

;

Func _ReadCmdLine($switch)

If $CmdLine[0] > 0 Then

$Cmdopt = StringSplit($CmdLineRaw, "-") ; options are separated by "-"

; _ArrayDisplay($Cmdopt, "options")

; start with 2

For $I = 2 To UBound($Cmdopt) - 1 ;

$param = StringLeft($Cmdopt[$I], 1) ; "f" - 1 char

; value is now rest of switch

$value = StringRight($Cmdopt[$I], StringLen($Cmdopt[$I]) - 1) ; take rest as value

$value = StringStripWS($value, 3);

; found it ??

If $param = $switch And $value <> "" Then

Return $value

EndIf ; value F?

Next ; all params

EndIf

Return 0; default

EndFunc ;==>_ReadCmdLine

Share this post


Link to post
Share on other sites



How about reading all the commands in at once and returning a multidimensional array with the values and their switches.

Share this post


Link to post
Share on other sites

How about reading all the commands in at once and returning a multidimensional array with the values and their switches.

Yes, arrays are our friends! They're always easy to deal with :rolleyes:

Kurt


Awaiting Diablo III..

Share this post


Link to post
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
Sign in to follow this  
Followers 0