rexx -a (rexx program) "argument containing spaces" two three
but I cannot get this to work as described. It seems that the only
way I can accomplish passing several arguments where one or more of
the arguments might contain spaces is by running a batch file to
assign the argument values to environment variables, remove the
leading and trailing double quotes from each variable, and then
invoking the Rexx program from the batch file and having the Rexx
program read the argument values from the environment variables.
Surely there must be some reasonable way to enable the Rexx program
to parse the arguments directly from the command line. Any tips and
suggestions will be gratefully appreciated.
Phil Robyn
Univ. of California, Berkeley
WinNT 4.0 SP6a
if left(uparg, 1)='"' then parse var uparg '"'thedir'"' .
else parse var uparg thedir .
and then move onto the next thing you are looking for. In the case of
switches getting the piece of data after it with spaces...
switchpos=wordpos('/D', uparg)
if switchpos>0 then do
if left(word(uparg, switchpos+1), 1)='"' then parse var uparg . '/D'
'"'thedir'"' .
else parse var uparg . '/D' thedir .
end
else /* logic for setting default values for non specified switches...
*/
Basically, process for one piece of data / type of data at a time. To
bring in multiple dirs before switches the logic gets a bit longer to
break apart which ones are in quotes, which are not. If you throw away
the quotes like you talked about, then you've lost your place holders as
to what things are really one string with spaces, and which are their
own single word parm strings.
Hope that helps.
--
Michael Lueck
Lueck Data Systems
Remove the upper case letters NOSPAM to contact me directly.
I can't get the preceding to work in Regina Rexx, as the double quotes
are evidently stripped out of the command-line arguments before the
contents of the command line is passed to my program.
So how can one say, 'just give me the command line as is'? I can't
attempt to apply your technique of looking for a leading double quote
if the double quotes have been removed from the argument.
>
> and then move onto the next thing you are looking for. In the case of
> switches getting the piece of data after it with spaces...
>
> switchpos=wordpos('/D', uparg)
> if switchpos>0 then do
> if left(word(uparg, switchpos+1), 1)='"' then parse var uparg . '/D'
> '"'thedir'"' .
> else parse var uparg . '/D' thedir .
> end
> else /* logic for setting default values for non specified switches...
> */
>
> Basically, process for one piece of data / type of data at a time. To
> bring in multiple dirs before switches the logic gets a bit longer to
> break apart which ones are in quotes, which are not. If you throw away
> the quotes like you talked about, then you've lost your place holders as
> to what things are really one string with spaces, and which are their
> own single word parm strings.
>
> Hope that helps.
>
> --
> Michael Lueck
> Lueck Data Systems
>
> Remove the upper case letters NOSPAM to contact me directly.
If I throw away the quotes in a batch file and assign the arguments to
NT environment variables, it seems FAR easier to deal with multiple arguments
(in this case, file names) that may or may not be enclosed in double quotes
in the batch file than in the rexx exec:
<NT 4.0> c:\cmd>rlist test\rlist.cmd
=====begin c:\cmd\test\rlist.cmd====================
01. @echo off
02. ::
03. :: invokes listfile.rexx
04. ::
05. setlocal
06. set RL_INFILE=%1
07. if defined RL_INFILE (
08. set RL_INFILE=%RL_INFILE:"=%
09. ) else (
10. set RL_INFILE=?
11. )
12. set RL_OUTFILE=%2
13. if defined RL_OUTFILE set RL_OUTFILE=%RL_OUTFILE:"=%
14. set RL_MODE=%3
15. rexx listfile dosargs
=====end c:\cmd\test\rlist.cmd====================
<NT 4.0> c:\cmd>rlist \rexx\listfile.rexx
=====begin c:\rexx\listfile.rexx====================
01. /* Rexx - lists the specified file with line numbers */
02. /* If you specify an output file, the listing will be */
03. /* written to the specified file. A third optional */
04. /* argument (mode) of 'append' will cause the current */
05. /* output to be appended to the output file; otherwise, */
06. /* the output file will be overwritten if it exists. */
07. /***********************************************************/
08. endofhelp = 7
09. parse arg input
10. if input = 'dosargs'
11. then do
12. infile = value(RL_INFILE , , 'SYSTEM')
13. outfile = value(RL_OUTFILE , , 'SYSTEM')
14. mode = value(RL_MODE , , 'SYSTEM')
15. end
16. else parse arg infile outfile mode
17. if infile = '' then infile = '?'
18. if index('help HELP ? -? /?', infile) > 0
19. then do
20. say sourceline(endofhelp)
21. do i = 1 to endofhelp
22. say sourceline(i)
23. end
24. exit
25. end
26. fullname = STREAM(infile, 'C', 'QUERY EXISTS')
27. if fullname = ''
28. then do
29. say 'File' infile 'does not exist.'
30. exit
31. end
32. recs = lines(infile, c)
33. if outfile ^= ''
34. then do
35. if mode ^= ''
36. then mode = translate(mode)
37. if mode ^= 'APPEND'
38. then do
39. if stream(outfile, 'C', 'QUERY EXISTS') ^= ''
40. then address system 'del "'outfile'"'
41. end
42. end
43. pad = '1' || substr('00000',1,length(recs))
44. if outfile = ''
45. then say '=====begin 'fullname'===================='
46. else rc = lineout(outfile, '=====begin 'fullname'====================')
47. ctr = 0
48. do while lines(infile) > 0
49. ctr = ctr + 1
50. number = ctr + pad
51. if outfile = ''
52. then say substr(number,2). linein(infile)
53. else rc = lineout(outfile, substr(number,2). linein(infile))
54. end
55. if outfile = ''
56. then say '=====end 'fullname'===================='
57. else rc = lineout(outfile, '=====end 'fullname'====================')
58. exit
=====end c:\rexx\listfile.rexx====================
<NT 4.0> c:\cmd>rlist c:\cmd\test\rlist.cmd "c:\temp\some new outfile.txt"
<NT 4.0> c:\cmd>type "c:\temp\some new outfile.txt"
=====begin c:\cmd\test\rlist.cmd====================
01. @echo off
02. ::
03. :: invokes listfile.rexx
04. ::
05. setlocal
06. set RL_INFILE=%1
07. if defined RL_INFILE (
08. set RL_INFILE=%RL_INFILE:"=%
09. ) else (
10. set RL_INFILE=?
11. )
12. set RL_OUTFILE=%2
13. if defined RL_OUTFILE set RL_OUTFILE=%RL_OUTFILE:"=%
14. set RL_MODE=%3
15. rexx listfile dosargs
=====end c:\cmd\test\rlist.cmd====================
<NT 4.0> c:\cmd>rlist "c:\temp\my other test file.txt" "c:\temp\some new outfile.txt" append
<NT 4.0> c:\cmd>type "c:\temp\some new outfile.txt"
=====begin c:\cmd\test\rlist.cmd====================
01. @echo off
02. ::
03. :: invokes listfile.rexx
04. ::
05. setlocal
06. set RL_INFILE=%1
07. if defined RL_INFILE (
08. set RL_INFILE=%RL_INFILE:"=%
09. ) else (
10. set RL_INFILE=?
11. )
12. set RL_OUTFILE=%2
13. if defined RL_OUTFILE set RL_OUTFILE=%RL_OUTFILE:"=%
14. set RL_MODE=%3
15. rexx listfile dosargs
=====end c:\cmd\test\rlist.cmd====================
=====begin c:\temp\my other test file.txt====================
01. . <DIR> 04-10-1999 12:41p
02. .. <DIR> 04-10-1999 12:41p
03. XLIB <DIR> 04-10-1999 12:41p
04. CTM <DIR> 04-10-1999 12:41p
05. DATETABL <DIR> 04-10-1999 12:41p
06. FBACKUP <DIR> 04-10-1999 12:41p
07. FICHE <DIR> 04-10-1999 12:41p
08. FILEXFER <DIR> 04-10-1999 12:41p
09. MCL <DIR> 04-10-1999 12:41p
10. MVSXLIB <DIR> 04-10-1999 12:42p
11. NTLIB <DIR> 04-10-1999 12:42p
12. SAVEOLD <DIR> 04-10-1999 12:42p
13. TLIB <DIR> 04-10-1999 12:42p
14. XINVC <DIR> 04-10-1999 12:42p
15. CASXLIB <DIR> 04-10-1999 12:42p
=====end c:\temp\my other test file.txt====================
--
u n z i p m y a d d r e s s t o s e n d e - m a i l
: rexx -a (rexx program) "argument containing spaces" two three
: but I cannot get this to work as described. It seems that the only
Which version of Regina are you running ? This capability is only available
in Regina 3.0 or above (not that there is anything above 3.0 at the moment).
: way I can accomplish passing several arguments where one or more of
: the arguments might contain spaces is by running a batch file to
: assign the argument values to environment variables, remove the
: leading and trailing double quotes from each variable, and then
: invoking the Rexx program from the batch file and having the Rexx
: program read the argument values from the environment variables.
: Surely there must be some reasonable way to enable the Rexx program
: to parse the arguments directly from the command line. Any tips and
: suggestions will be gratefully appreciated.
: Phil Robyn
: Univ. of California, Berkeley
: WinNT 4.0 SP6a
--
Cheers, Mark
---------------------------------------------------------------------------
* Mark Hessling, M.Hes...@qut.edu.au http://www.lightlink.com/hessling/
* Author of THE; a Free XEDIT/KEDIT editor, Rexx/SQL, Rexx/Curses, Rexx/Wrapper
* Maintainer of PDCurses: Public Domain Curses and, Regina Rexx interpreter
* Use Rexx? join the Rexx Language Association: http://www.rexxla.org
> You may want to check out Reginald. It uses an entirely different
> frontend that does not use spaces to separate arguments. It uses an
> unquoted comma to separate each arg.
Sounds like Reginald is getting less and less Rexx-like as time goes by.
It may be neat to make such changes, but will sure be a PAIN to pick up
code and move it to other OS's / other Rexx implementations.
> I can't get the preceding to work in Regina Rexx, as the double quotes
> are evidently stripped out of the command-line arguments before the
> contents of the command line is passed to my program.
Well, whip up a little Rexx program to do this...
parse arg theargs
say theargs
to see if you are getting what you expect to be getting. If not, send
along something and I will check it on Object Rexx.
Oh, and grabbing the command line args should be one of the first things
you do in the main program... from there I pass them to a parm check
area for processing... check out CUR / Object CUR at my web site for
some ideas on processing the program parms.
Anyway, if there is a difference then either send it directly to Mark,
or maybe he will be kind enough to notice this thread and explain any
difference found.
Hope that helps!
> >Michael Lueck <Nmlu...@SlueckPdataAsystemsM.com> Sounds like Reginald
> >is getting less and less Rexx-like as time goes by. It may be neat to
> >make such changes, but will sure be a PAIN to pick up code and move it
> >to other OS's / other Rexx implementations.
> What code are you talking about? There is no code here. We're talking
> about invoking the REXX interpreter from the command line (Reginald
> also supports invoking the interpreter just by clicking on Script
> Launcher's icon and picking out your script and typing the desired
> args into the "File Dialog")
Jeff, are you saying that the "entirely different frontend" is the
alternative where you type args into the "File Dialog"? If a user wants
to pass three arguments, each with embedded spaces, do they type those
values into three separate fields on your system's dialog? If they do
then it is easy to see how Reginald can keep them separate and pass them
in to an invoked exec. But if the user has to type those three values
into a single field on your dialog, how on earth can Reginald decide how
the argumenst are delimited?
--
Jeremy C B Nicoll - my opinions are my own.
That does sound like a beastly Windows idea. M$ers don't get the idea
that true automation and mangement is to be able to do EVERYTHING via
scripts, not clicking, selecting, and typing in parms.
What you mentioned was is that you get a comma delimited set of parms...
so someone writes code that expects the commas, how in the heck will
that code port to Rexx?
Jeff, did you ever think of starting comp.lang.reginald?
>> But if the user has to type those three values into a single field on
>> your dialog, how on earth can Reginald decide how the argumenst are
>> delimited?
> By the presense of unquoted commas. When you invoke a REXX subroutine
> or function, do you not separate the arguments using unquoted commas?
Yes I do. But separation of arguments by commas in function-call syntax
is not at all the same thing as delimiting portions of literal text with
literal commas. I've seen several rexx programmers very confused because
they didn't know the difference between:
parse arg a,b,c
parse var whatever a","b","c
In the rexx implementations I've used, a call of the 'myexec' rexx exec
with some following text, like:
myexec some,text typed in after, the exec on the command line
passes a single argument to the exec, containing the literal text:
"some,text typed in after, the exec on the command line"
Is Reginald doing something else?