Just can't stay away
Joined: 2009/4/28 4:57 Last Login
: Yesterday 13:22
From Adelaide, Australia
Group:
Registered Users
|
Test this one. I think there is an easier way to do it, but i've never had to bother parsing arguments as accurately as this before.
This still isn't going to work for stuff like hello="something here" Nor will it work if quotes are mismatched.
Both can fixed up if you need to do handle that type of thing.
Example: RX args.rexx "hello test" testing123 "this is a test"
Output:
hello test testing123 this is a test
/**/ Parse Arg Args
Call ParseArgs() SAY Arg.1 SAY Arg.2 SAY Arg.3 Exit
ParseArgs: i2=1 DO i=1 TO Words(Args) IF Left(Word(Args,i),1)=d2c(34) THEN DO Arg=SubStr(SubWord(Args,i),2) Pos=Pos(d2c(34),Arg) Arg.i2=Left(Arg,Pos-1) Words=Words(Arg.i2) i2=i2+1 i=i+Words-1 End ELSE DO Arg.i2=Word(Args,i) i2=i2+1 End End Return 0
|