[comp.lang.rexx] No getopt

jimm@amiga.UUCP (Jim Mackraz) (09/20/90)

(Lynn D Newton) writes:
)More language wars.

Yeah, I thought that was pretty amazing.

)However, at this writing I still have no REXX implementation of
)getopts(). I think I will gather all the discussion that has been
)posted and snailmail it to William Hawes, the programmer of
)ARexx, and see if I can convince him to write a getopts() library
)routine for inclusion with ARexx so that all the great number of
)Amiga users who have or will have ARexx (it's bundled with
)version 2.0 of the operating system, for the information of
)readers who are unaware of it), can also have this very valuable
)functionality.

I have not translated my baby getopt() to ARexx, but rather decided to
use the standard Amiga .KEY template format (somewhat extended) for
rexx scripts on the Amiga.  I didn't know you were on an Amiga or
I would have mentioned it sooner.

I have a 'function' kparse.rexx for parsting Amiga .KEY templates.
It's not too wonderful, but handles these specifiers:
	/A - required argument
	/K - keyword required
	/S - switch (bool) argument
	/F - final args (everything until end of list)
	/B - brief format (initial character, or two if first char is '-')
	=  - keyword synonyms

It's written in rexx, isn't too small, and I'm told is somewhat strange.  It
returns a string that you "interpret" to build a stem variable
with the parsed results, as seen above.

For example, my 'mv.rexx' starts out like this:

parse arg inputargs
stempspec = kparse( '-force/sb,files/f', inputargs, 'k' )
interpret stemspec	/* builds stem variable named 'k'	*/
if k.result = 'badargs' then do
    call usage
end

filelist = expand( k.files )		/* expand.rexx does wildcards */

... and later checks the value of k.force (set to either 0 or 1).

I think some of the "non-standard" stuff here was inspired by arp or
hawes' own extensions, but some might be just me.

It also responds to '?' as the sole argument with the little "interactive"
template reminder deal.

Anyway, things like this should probably be in a function library
but if you want the Amiga equivalent of getopt() written in rexx for use
by rexx macros, I can mail this thing to you, or post it if there is
sufficient interest.  It's already posted to bix somewhere (kparse.rexx).

	jimm

-- 
--------------------------------------------------	- opinions by me
"I've got great news.  That gum you like is going to come back in style."
						-the man from another place