--- In [EMAIL PROTECTED], sgp <[EMAIL PROTECTED]> wrote:
>
> I want to be able to call powerpro scripts the same way I call C
> programs or sh scripts, that is intermixing unix-style long/short
> options, and printing a usage message on syntax errors.
>
> Examples:
> (from a script file) Do(".script","-x 1 --longoption=yes")
> (from cli) c:\> ppbang .script("--longoption=yes -x1")
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?
> The stuff that is covered in the links you mention is very powerful
and
> certainly can support option parsing, but I have no idea of how to
use
> C++ classes from PowerPro.
No problem, that's what I do.
> Whatever the solution, it has to conform to
> ordinary PowerPro idioms. For instance, suppose that there was a
new
> Options plugin, then I'd expect to use it more or less like this
>
> local opts=map.create(11) ;; max 10 options + usage string
> local syntax="-x{num} --longoption{string}" ;; see NOTE below
> local args=""
> local i
> ; concatenate arg() vector
> for(i=1; arg(i) && i<=8; i=i+1)
> args=args++" "++arg(i)
> endfor
Hmm. Not sure you can pass a map to a plugin. I forget, will check
it out.
Failing that, you could pass a single string, made of multiple lines
(separated by newline), one line per arg
Or you theree could be
options.addIntArg("c", "count", "number", "number of copies to
print.")
Also options.addBoolArg, options.addStringArg....
; 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?
> ; process options
> if(opts["x"])do
> win.debug("-x", opts["x"], "was specified")
> ; etc.
> endif
> ; etc.
Or options.go(theArgsToParse)
options.getParsedArg(index)
> NOTE: I oversimplified my syntax definition lines. In reality, I'd
like
> to see the same kind of flexibility that those C++ parsing classes
> offer, with ways to define the alternative short and long form for
the
> same option, and a standard way to retrieve its value as indexed by
the
> short-form option label.
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/