{def
I wrote a PostScript program for parsing command-line switches similar to
how the getopt function of UNIX is doing. I might use it myself in some of
my own programs, but it might be useful for other programmers to use, too. You can also tell me if you have a suggestion for improvement, too.
Long option parameters without = are not implemented, and it will always
use the POSIXLY_CORRECT kind of parsing.
***BEGIN***
% PostScript code for parsing command-line arguments
% (public domain)
On Sunday, August 1, 2021 at 4:03:18 PM UTC-5, ne...@zzo38computer.org.invalid wrote:
I wrote a PostScript program for parsing command-line switches similar to how the getopt function of UNIX is doing. I might use it myself in some of my own programs, but it might be useful for other programmers to use, too. You can also tell me if you have a suggestion for improvement, too.
Long option parameters without = are not implemented, and it will always use the POSIXLY_CORRECT kind of parsing.
***BEGIN***
% PostScript code for parsing command-line argumentsI think this is interesting code (and it's great to see people writing PS!). But I'm not sure if it's actually very useful. If you're using ghostscript, you can combine the ARGUMENTS form with -D definitions, so you
% (public domain)
don't really need to parse any option style syntax from the ARGUMENTS
list. Just define those with -D and use ARGUMENTS for strings
or filenames or whatever.
I started a thread recently listing every way I could think of to pass arguments into a PS program. Lots of them can be combined.
You can even define parameters with regular PS code and concatenate
the files before processing.
I think this is interesting code (and it's great to see people writing PS!). But I'm not sure if it's actually very useful. If you're using ghostscript, you can combine the ARGUMENTS form with -D definitions, so you
don't really need to parse any option style syntax from the ARGUMENTS
list. Just define those with -D and use ARGUMENTS for strings
or filenames or whatever.
While that is true, I don't really like -d and -s for your own program's options; the -d and -s are for setting the options of Ghostscript itself (such as specifying what file or printer to use for graphical output, and some other options).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 89:15:20 |
Calls: | 6,658 |
Files: | 12,203 |
Messages: | 5,334,026 |