ARexx rx question 
Author Message
 ARexx rx question

Is there some reason why when I say 'rx bah.rexx a b c', bah.rexx sees
arg() == 1, with the one argument being 'a b c' ??  It's rather annoying
to pass 3 arguments to a script only to have it see them as one argument.
Is there some way to correct this?

(This is v1.15, under AShell or SKSH -- haven't checked the CBM shell,
AmigaDOS 1.3.  In case your mileage varies.)

--------------------------------------------------------------------
    Jeff Van Epps    uunet!amusing!lordbah



Thu, 08 Sep 1994 00:46:13 GMT  
 ARexx rx question

Quote:

>Is there some reason why when I say 'rx bah.rexx a b c', bah.rexx sees
>arg() == 1, with the one argument being 'a b c' ??  It's rather annoying
>to pass 3 arguments to a script only to have it see them as one argument.
>Is there some way to correct this?

What you're describing is actually correct behaviour.  You have to use
commas on a command line to separate arguments, otherwise the rest of
the command line is passed as a single argument.  This is consistent
with how CMS REXX works as well.

(Mind you, "correct" behaviour doesn't necessarily imply "intuitive"
behaviour...)

--

           Unlike the cleaning lady, I have to do Windows.



Fri, 09 Sep 1994 04:10:11 GMT  
 ARexx rx question


:  
: >What you're describing is actually correct behaviour.  You have to use
: >commas on a command line to separate arguments, otherwise the rest of
: >the command line is passed as a single argument.  This is consistent
: >with how CMS REXX works as well.
:  
: That is _not_ how CMS REXX works.  Commas on a command line will themselves
: be taken to be part of a single argument string.  Only commas appearing in
: a Rexx "CALL" instruction or in the argument list to a Rexx function
: reference serve to separate multiple argument strings.

I think that this situation is an outgrowth of REXX's original
environment (i.e., an IBM mainframe O/S.)  In these operating systems,
while a main program can pass multiple arguements to a called routine,
when the O/S invokes a main program the calling conventions used
allow for only a single argument string (sigh.)

========================================================================


The Workstation Group              voice: 800-228-0255
6300 River Road, Suite 700            or  708-696-4800
Rosemont, Illinois  60018            fax: 708-696-2277



Fri, 09 Sep 1994 23:32:06 GMT  
 ARexx rx question

Quote:

>Is there some reason why when I say 'rx bah.rexx a b c', bah.rexx sees
>arg() == 1, with the one argument being 'a b c' ??  It's rather annoying
>to pass 3 arguments to a script only to have it see them as one argument.
>Is there some way to correct this?

In REXX (and ARexx) arguments are never pre-parsed when passed as you
have shown.  The way the code would need to deal with it is to use
PARSE ARG...

For example:

/* Example Rexx Program */
PARSE ARG arg1 arg2 arg3 .   /* Get the first 3 args... */
SAY "Arg1=" arg1
SAY "Arg2=" arg2
SAY "Arg3=" arg3

Now, there are times when the arguments are "preparsed" and that is
when you call a REXX function (which can be written in REXX) with arguments.
That is, when you do:

answer=MyFunction(a,b,c)

But then, you parsed the arguments for REXX and thus there could not be
any worry about how to split up the arguments.

/----------------------------------------------------------------------\
|      /// Michael Sinz  -  Senior Amiga Software Engineer             |
|     ///                   Operating System Development Group         |
|    ///   BIX:  msinz      UUNET:  rutgers!cbmvax!mks                 |
|\\\///                                                                |
| \XX/     Quantum Physics:  The Dreams that Stuff is made of.         |
\----------------------------------------------------------------------/



Fri, 09 Sep 1994 23:47:05 GMT  
 ARexx rx question

Quote:


>>What you're describing is actually correct behaviour.  You have to use
>>commas on a command line to separate arguments, otherwise the rest of
>>the command line is passed as a single argument.  This is consistent
>>with how CMS REXX works as well.

>That is _not_ how CMS REXX works.  Commas on a command line will themselves
>be taken to be part of a single argument string.  Only commas appearing in
>a Rexx "CALL" instruction or in the argument list to a Rexx function
>reference serve to separate multiple argument strings.

ARexx works correctly.  Commas seperate arguments in a list only when
calling a procedure or a function.  Commas used to separate arguments
on the command line are seen as part of the single string parameter passed
to the rexx script.

---



Sat, 10 Sep 1994 04:06:05 GMT  
 ARexx rx question
OK....

+++++++++++++++++++++++++++++

[Temporary:]: rx arg a b c
1 arguments
a b c
[Temporary:]: rx arg a,b,c
1 arguments
a,b,c

/*
 *  arg.rexx
 */

say arg() 'arguments'
do i = 1 to arg()
        say arg(i)
end

++++++++++++++++++++++++++++

So, how does one pass multiple arguments on the command line?

--------------------------------------------------------------------
    Jeff Van Epps    uunet!amusing!lordbah



Sat, 10 Sep 1994 05:59:14 GMT  
 ARexx rx question

Quote:
>OK....

>+++++++++++++++++++++++++++++

>[Temporary:]: rx arg a b c
>1 arguments
>a b c
>[Temporary:]: rx arg a,b,c
>1 arguments
>a,b,c

>/*
> *  arg.rexx
> */

>say arg() 'arguments'
>do i = 1 to arg()
>    say arg(i)
>end

>++++++++++++++++++++++++++++

>So, how does one pass multiple arguments on the command line?

 I think some people are confusing the "command line" with "program line".
When calling a rexx script (the command line), you pass the arguments as a
space seperated list ie:

rx myprog input1 input2 input3 input4

in the rexx program itself, you would use a line like this to accept the
multiple arguments, ie:

PARSE ARG myvar1 myvar2 myvar3 myvar4

this would result in the following

myvar1 = input1
myvar2 = input2
(etc...)

The PARSE command is what doles out the arguments to the variables. Simply
using ARG would result in your getting only one variable assigned a value.

 You can also use ARG(position) in the following manner:

myvar1 = ARG(1)
myvar2 = ARG(2)

As a general rule I use strip() to clean off leading and trailing spaces
on any of the above methods.

Oh, this is with the Amiga version of ARexx, your mileage may vary.



Sat, 10 Sep 1994 09:39:05 GMT  
 ARexx rx question


Quote:
>OK....

>+++++++++++++++++++++++++++++

>[Temporary:]: rx arg a b c
>1 arguments
>a b c
>[Temporary:]: rx arg a,b,c
>1 arguments
>a,b,c

>/*
> *  arg.rexx
> */

>say arg() 'arguments'
>do i = 1 to arg()
>    say arg(i)
>end

>++++++++++++++++++++++++++++

>So, how does one pass multiple arguments on the command line?

>--------------------------------------------------------------------
>    Jeff Van Epps    uunet!amusing!lordbah


Ypu don't.  You only get one argument, which you can parse any way you
want.

Jim McMaster



Sat, 10 Sep 1994 23:38:38 GMT  
 ARexx rx question
...examples deleted

Quote:
>So, how does one pass multiple arguments on the command line?

In the IBM publication VM/ESA Procedures Language VM/REXX Reference,
order number SC24-5466-01, on page 78 note 2 reads:

2. Programs called as commands can have only 0 or 1 argument strings, the
   program has 0 argument strings if it is called with the name only and
   has 1 argument string if anything else (including blanks) is included
   with the command

This is about as close as you can get to a Rexx bible, except for the
"Red" book, as your going to get. While it is true that this is not
an intuitive behavoiur, it is the documented way things work.

Quote:

>--------------------------------------------------------------------
>    Jeff Van Epps    uunet!amusing!lordbah



Amdahl Corp.

Disclaimer: NO this is not Amdahl's opion, it's mine all mine.



Sun, 11 Sep 1994 00:30:57 GMT  
 ARexx rx question

Quote:

>So, how does one pass multiple arguments on the command line?

I might have sent you email about this, but it appears to have fallen in the
bucket.

/* parse args.rexx */

    parse arg commandline           /* get the commandline into a variable */
    args = words(commandline)       /* number of words sperated by spaces  */
    do x = 1 for args               /* for as many words as were found     */
        arg.x = word(commandline,x) /* assign each word to a variable      */
        say arg.x                   /* prove that they are in fact there   */
        end
  exit(0)

--

----------------------------------------------------------------------------



A committee is a cul-de-sac down which ideas are lured and quietly {*filter*}d



Sun, 11 Sep 1994 01:26:48 GMT  
 ARexx rx question

Quote:

> Is there some reason why when I say 'rx bah.rexx a b c', bah.rexx sees
> arg() == 1, with the one argument being 'a b c' ??  It's rather annoying
> to pass 3 arguments to a script only to have it see them as one argument.
> Is there some way to correct this?

> (This is v1.15, under AShell or SKSH -- haven't checked the CBM shell,
> AmigaDOS 1.3.  In case your mileage varies.)

Works like this under CBM shell.  Mind you,  this IS the Documented handling of
initiation parameters!!  (appears in both Bill Hawes Docs and the 2.04 docs).

Cheers


    Lower Hutt,  New Zealand     3:771/220.5



Sun, 11 Sep 1994 17:46:05 GMT  
 ARexx rx question

Quote:

> OK....

> +++++++++++++++++++++++++++++

> [Temporary:]: rx arg a b c
> 1 arguments
> a b c
> [Temporary:]: rx arg a,b,c
> 1 arguments
> a,b,c

> /*
>  *  arg.rexx
>  */

> say arg() 'arguments'
> do i = 1 to arg()
>    say arg(i)
> end

> ++++++++++++++++++++++++++++

> So, how does one pass multiple arguments on the command line?

Here's a small, useless, Arexx routine that parses arguments.

/*rexx*/
/* Chew - chew through space in nK blocks */
/* Dac. May 1991 */

PARSE ARG name','Limit','fillchar','List

IF ((LENGTH(name) = 0) | (DATATYPE(Limit,NUMERIC) = 0)) THEN DO
  SAY "Chew: Usage -- Chew name,number,fillchar,list"
  SAY " "
  SAY "This program chews through file space."
  SAY "List is optional, but if specified indicates progress"
  SAY "Fillchar is optional, and defaults to '0'"
  SAY "Space is chewed up in 1024 byte blocks."
  EXIT
END

IF (LENGTH(fillchar) = 0)
  THEN Filler = "0"
ELSE DO
  Filler = LEFT(FILLCHAR,1)
  say "Fill character is '"filler"'"
END

SAY "Computing a 1K block of zeroes"

block = Filler
DO loop = 1 TO 10          /* 2^10 == 1024 */
  block=block||block
END

SELECT
  WHEN (limit > 128)  THEN  CALL calcblock(5)
  WHEN (limit > 64)   THEN  CALL calcblock(4)
  WHEN (limit > 32)   THEN  CALL calcblock(3)
  WHEN (limit > 16)   THEN  CALL calcblock(2)
  OTHERWISE CALL calcblock(1)
END

SAY "writing to file "name

outputted = 0
CALL OPEN(outputfile,name,'W')
DO loop = 1 TO newLimit
   IF (LENGTH(list) > 0) THEN DO
      outputted = outputted + LENGTH(bigblock)
      say "Outputting bytecount" outputted "block number" loop
   END
   WRITECH(outputfile,bigblock)
END
WRITECH(outputfile,remainblock)
CALL CLOSE(outputfile)

SAY "Completed - " Limit"K written to file "name
EXIT

/*** Calc blocksizes ********************************************************/

calcblock:

PARSE ARG power

bigblock    = block                   /* base size is 1K */
remainblock = ""                      /* remain size is zero*/

SAY "Writing out file in " 2 ** power||"K chunks"
DO loop = 1 TO power               /* effectively 2**power*/
   bigblock=bigblock||bigblock     /* double size of string each time*/
END

newlimit = limit %  (2 ** power)   /* number of chunks */
remain   = limit // (2 ** power)   /* remainder to do */
IF (remain > 0) THEN DO
  DO loop = 1 TO remain
    remainblock= remainblock||block /* calculate remainder block*/
  END
END
RETURN
----------------------------cut here-----------------------------

It's all in the PARSE action.

Dac
--
munnari!labtam!eyrie!prolix!dac      David Andrew Clayton.           // _| _  _





Sun, 11 Sep 1994 18:50:38 GMT  
 ARexx rx question
Quote:

>...examples deleted

>>So, how does one pass multiple arguments on the command line?

>In the IBM publication VM/ESA Procedures Language VM/REXX Reference,
>order number SC24-5466-01, on page 78 note 2 reads:

>2. Programs called as commands can have only 0 or 1 argument strings, the

             ^^^^^^^^^^^^^^^^^^
Quote:
>   program has 0 argument strings if it is called with the name only and
>   has 1 argument string if anything else (including blanks) is included
>   with the command

Just because you are calling a rexx program from the command line does NOT
mean it MUST be called as a command.  I have used this on occasion.

rx "'rexx_function'( arg1, arg2, ... )"
or the equivalent
rx '"rexx_function"( arg1, arg2, ... )'

Both the single and double quotes are needed with the above formats.  You
could probably get this to work with only single or double quotes, but I
haven't bothered to try.

[... deleted ...]

Quote:
>>--------------------------------------------------------------------
>>    Jeff Van Epps    uunet!amusing!lordbah


>Amdahl Corp.

>Disclaimer: NO this is not Amdahl's opion, it's mine all mine.


(AMiga Users of Calgary)         AMUCexpress BBS - 650 meg PD Software
                           (403) 282-5137/5171/5224/5238 3/12/24/24 MNP bps


Sun, 11 Sep 1994 20:53:58 GMT  
 ARexx rx question

Quote:
>So, how does one pass multiple arguments on the command line?

On a related note, has anyone found a good way (on the Amiga) to
pass an arbitrary list of filenames to a rexx script?  My scripts
always {*filter*}on names with spaces in them (No, I don't tend to use
names with spaces, but some vendors seem to think they're a good
idea).  Any suggestions?

+=======================================+===============================+
| "Nearly any man can handle adversity, | Dave Love                     |

|  give him power." - Abraham Lincoln   | <insert std. disclaimer here> |
+=======================================+===============================+



Mon, 12 Sep 1994 00:26:55 GMT  
 ARexx rx question

Quote:


}>So, how does one pass multiple arguments on the command line?
}>
}On a related note, has anyone found a good way (on the Amiga) to
}pass an arbitrary list of filenames to a rexx script?  My scripts
}always {*filter*}on names with spaces in them (No, I don't tend to use
}names with spaces, but some vendors seem to think they're a good
}idea).  Any suggestions?

Why not delimit them with commas on the command line and then split them that
way [basically ignoring spaces, other than to trim the stuff inbetween
commas].

A different, but related question: is there a way to do *wildcards* via the
command line.  I've often wished I could write a REXX script to take a
command line like:
    rx myscript #?.rexx
or some such...  I've hacked this in the past by addressing a command to the
shell doing an appropraite "LIST" command to a dummy file and then reading
that back in and parsing it, but it seems like an awful kludge...

  /Bernie\



Mon, 12 Sep 1994 00:45:50 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. ARexx rx question

2. AREXX: rx named address

3. OREXX vs PCDOS 7 REXX and RX*.RX util

4. ARexx port <-> ARexx port

5. Questions to Dr. Rx

6. ARexx question

7. ARexx question

8. AREXX legal question

9. Questions about ARexx Systems Library

10. Further to my Arexx question;

11. ARexx Questions

12. AREXX error trapping question

 

 
Powered by phpBB® Forum Software