Re: Larkin, Power BASIC cannot be THAT good:
- From: John Larkin <jjSNIPlarkin@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 07 Jun 2009 12:30:22 -0700
On Sun, 7 Jun 2009 11:22:04 -0500, "Tim Williams"
<tmoranwms@xxxxxxxxxxx> wrote:
"Nobody" <nobody@xxxxxxxxxxx> wrote in message
news:pan.2009.06.07.13.30.02.406000@xxxxxxxxxxxxxx
In MS-DOS, it's even easier: you get one string up to 127 characters
long.
it's up to you to play with it, which is usually tokenization first
(which
is just what the C compiler does when it cooks up your args).
This can be a nuisance, as the program's documentation tends to document
its behaviour in terms of distinct arguments, without documenting how the
string is parsed into arguments. This can be an issue if one of the
arguments is an arbitrary string which may contain spaces, quotes etc.
In those cases, either the string would have to go at the end (how else can
you tell it's an arbitrary string?), or it would have to be encapsulated
somehow (such as quotes).
Last time I wrote a command line parser, I happened to be writing in
assembly. There, it grabbed a byte, checked if it was a token, delimiter or
switch (i.e., "/"). If it was a switch, it scanned for the WORD "?/" or
etc. (being that endianness actually reads "/?" as "?/". Odd at a glance,
and not useful for more than two character switches, but interesting in its
own way.) After each switch was found, a flag was set indicating it had
been found, and therefore should not be checked for again. In that
particular program, switches could go anywhere in the command line, before
or after the argument. The first token found that wasn't a switch was
copied as the argument (path, in this case); any subsequent arguments were
ignored.
Meanwhile, in QBasic, I've done plenty of command lines, but since COMMAND$
is so temping, and because QB sadly doesn't provide any tokenizing
functions, I usually just go lame and do something like OPEN COMMAND$ FOR
INPUT AS #1, no switches at all. OTOH, in C, you get all parameters
tokenized already, so it's quite easy to look at them in order. That's kind
of nice. (Hmm, if QB had the foresight, it could be COMMAND$(n) instead!)
Tim
PowerBasic (the console compiler version) has a couple of nice
built-in PARSE commands.
John
.
- Follow-Ups:
- Re: Larkin, Power BASIC cannot be THAT good:
- From: AZ Nomad
- Re: Larkin, Power BASIC cannot be THAT good:
- References:
- Re: Larkin, Power BASIC cannot be THAT good:
- From: Jasen Betts
- Re: Larkin, Power BASIC cannot be THAT good:
- From: Tim Williams
- Re: Larkin, Power BASIC cannot be THAT good:
- From: Nobody
- Re: Larkin, Power BASIC cannot be THAT good:
- From: Tim Williams
- Re: Larkin, Power BASIC cannot be THAT good:
- Prev by Date: Re: Readout pin on oscilloscope probes
- Next by Date: Re: Readout pin on oscilloscope probes
- Previous by thread: Re: Larkin, Power BASIC cannot be THAT good:
- Next by thread: Re: Larkin, Power BASIC cannot be THAT good:
- Index(es):
Relevant Pages
|