I'm enjoying this thread! Thanks.

entropyreduction wrote:

> 
> Right, so you want to get all your options into the first
> powerpro argument.  You don't want to parse _all_ the powerpro args, 
> just the first one?  
>  

Actually, in my scriptlet example I was parsing all arguments, but I 
concatenated them into a single string first. I can't think of another 
simple ppro idiom to do that. Can you?

>> but I have no idea of how to use C++ classes from PowerPro. 
> 
> 
> No problem, that's what I do.

Great, I'm relieved!

> 
> Hmm.  Not sure you can  pass a map to a plugin.  I forget, will check 
> it out.
> 

The reason I passed a map to the plugin is primarily to get my output 
values back. I stole this interface idea from Perl. It's very 
convenient. The returned map element keys are named after the syntax 
options, and the corresponding values are set to whatever was parsed. So 
one can script

if(opts["x"])do
  win.debug("option -x (or --xlongform) specified as",opts["x"])
endif

Hmm, unfortunately, I just realized that the map plugin is missing a 
service to determine whether a map KEY exists. Without that service--
which Perl does have--it's impossible to support this interface. Let's 
assume for a moment that there was such a service, map.IsKeyDefined, 
then the right scriptlet would be:

if( map.IsKeyDefined(opts,"x") )do
  win.debug("option -x (or --xlongform) specified as",opts["x"])
endif

Without IsKeyDefined there would be no way for an Options plugin to 
return values for a -y option that doesn't require an argument.

> Failing that, you could pass a single string, made of multiple lines
> (separated by newline), one line per arg
> 

Yes, but how do return values? Possibly in a simple way? I still like 
the Perlish way better, assuming that it's technically feasible in 
PowerPro.

> Or you theree could be
> 
>  options.addIntArg("c", "count", "number", "number of copies to 
> print.")
> 
> Also options.addBoolArg, options.addStringArg....
> 

Yes, this is good, too. Still the key question to me is how to return 
values in a simple way.

>  ; parse script arguments
>> local error = Options.syntax(opts, syntax, args)
>> ; on error print usage message and quit
>> if(error)do
>>   for(i=word(opts["USAGE"]; i>0; i=i-1)do
>>   win.debug(word(opts["USAGE"],i)
>>   quit(-1)
>> endif
> 
> Or the plugin raises a script error dialog if the syntax is wrong?
> 

I hate when PP or plugins raise error dialogs. I want to be able to 
control the user interface of my scripts.

>> ; process options
>> if(opts["x"])do
>>   win.debug("-x", opts["x"], "was specified")
>>   ; etc.
>> endif
>> ; etc.
> 
> Or options.go(theArgsToParse)
>    options.getParsedArg(index) 
> 

Your options.go() is the same as my options.syntax() right?

How does options.getParsedArg(index) work? Is index a number? How do I 
know that index corresponds to -x or -y? I still like the map syntax 
better, if technically feasible, it makes for much more compact PP 
scripts, and it's easy to remember (at least for me with some Perl 
experience).

--sgp



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/JV_rlB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to