; GetNextParm - by Dave Laundon
;   Processes the next parameter, which may be quoted, from the string on the
;   top of the stack.
; Usage:
;   Push <parameters>
;   Call GetNextParm
;   Pop <next parameter>
;   Pop <remaining parameters>
Function GetNextParm
  Exch $0
  Push $1
  Push $9
  Push $8
  StrCpy $1 ""

; Trim leading space
TrimLeading:
  StrCpy $9 $0 1
  StrCmp $9 "" Done
  StrCmp $9 '"' DelimitQuote
  StrCmp $9 " " "" DelimitSpace
  StrCpy $0 $0 "" 1
  Goto TrimLeading

; Begin a quote-delimited parameter
DelimitQuote:
  StrCpy $0 $0 "" 1
  Goto CopyParm

; Begin a space-delimited parameter
DelimitSpace:
  StrCpy $9 " "

; Extract the parameter
CopyParm:
  StrCpy $8 $0 1
  StrCmp $8 "" Done
  StrCpy $0 $0 "" 1
  StrCmp $8 $9 Done
  StrCpy $1 $1$8
  Goto CopyParm

Done:
  Pop $8
  Pop $9
  Exch $1
  Exch
  Exch $0
  Exch
FunctionEnd
--------------------------------------------------------------------------------
e.g. code:
--------------------------------------------------------------------------------
  Push $CMDLINE
  Call GetNextParm
  Pop $0 ; exe name
  StrCpy $9 "" ; /S flag

ParmsLoop:
  Call GetNextParm
  Pop $0
  StrCmp $0 "" ParmsDone ; No more parms
  StrCpy $1 $0 2
  StrCmp $1 "_=" ParmsDone ; No more /useful/ parms
  StrCmp $0 "/S" ParmSlashS
  Goto ParmsLoop

ParmSlashS:
  StrCpy $9 "Y"
  Goto ParmsLoop

ParmsDone:
  Pop $0 ; Tidy the stack
  StrCmp $9 "Y" Silent NotSilent
etc...
--------------------------------------------------------------------------------


