Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
202 user(s) are online (185 user(s) are browsing Forums)

Members: 1
Guests: 201

NinjaCyborg, more...

Support us!

Headlines

 
  Register To Post  

Need an example ARexx script with arguments
Not too shy to talk
Not too shy to talk


See User information
I want to run an Arexx script and pass strings to it.

rx myscript.rexx "This is a test" "jahc" "sound effects.wav"

then..
the script would do (for example)

/* test arguments */
SAY arg1
SAY "my name is" arg2
PLAYSOUND arg3

Ignore the quasi ARexx stuff.. but if someone could provide an example, that would be great. :)

Go to top
Re: Need an example ARexx script with arguments
Just can't stay away
Just can't stay away


See User information
@jahc

Don't kid yourself; You knew it'd be me who'd respond first :)


/* Test arguments */
Parse Args Arg1 Arg2 Arg3

SAY Arg1
SAY "My name is" Arg2
PLAYSOUND Arg3
Exit


However Arg1 is just the first word, Arg2 is the second word, Arg3 is the third word.

You could do this instead:

/* Test arguments */
Parse Args Args
Parse Var Args B1"'"Arg1"'"B2"'"Arg2"'"B3"'"Arg3"'"B4

SAY Arg1
SAY "My name is" Arg2
PLAYSOUND Arg3
Exit


... but then that REQUIRES using apostraphes.

Like RX whatever.rexx 'hello test' 'blah blah' 'something something'


B1 just means "Blank 1".. It's a variable that isn't going to be used, but necessary anyway.

Give me a moment and i'll code up exactly what you're after.

Go to top
Re: Need an example ARexx script with arguments
Just can't stay away
Just can't stay away


See User information
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

Go to top
Re: Need an example ARexx script with arguments
Just can't stay away
Just can't stay away


See User information
rexxdossupport.library has a ReadArgs() function to simplify this, however that library doesn't come with the OS. Depends if you want to add another requirement or not.

I can make a function that does the same stuff without having to use any 3rd party libraries.


Edited by MickJT on 2009/10/21 13:34:33
Edited by MickJT on 2009/10/21 13:35:41
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project