Getopt

08/14/2013 02:18 Liented#1
Code:
func GetOpt ($option)
  local $i
  for $i = 1 to $CmdLine[0]
    if $CmdLine[$i] == $option Then
    if $i+1 > $CmdLine[0] Then
      return 1
     else
      return $CmdLine[$i+1]
    endif
    endif
  next
  return 0
endfunc
for example

Getopt("/a") Returns 'Hello' if you start the prog using 'filename /a Hello'
Getopt("/a") Returns 'Hell o' if you start the prog using 'filename /a "Hell o" '

Getopt("/x") Returns 1 if you start the prog using 'filename /x'
Getopt("/x") Retuns 0 if you start the prog using 'filename /a /v /c lalala' or no parameters

looks nice until here :D
but Getopt("/a") Retuns '/x' if you start the prog using 'filename /a /x'
ok you can still use 'if Getopt("/a") <> 0 Then...'

did anybody out there do something better?