Re: Larkin, Power BASIC cannot be THAT good:



On Sun, 07 Jun 2009 12:30:22 -0700, John Larkin <jjSNIPlarkin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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.

Sheesh. It's a phone call for you. The 70's want their interpreted language
technology back.
.



Relevant Pages

  • Re: Larkin, Power BASIC cannot be THAT good:
    ... it's up to you to play with it, which is usually tokenization first ... arguments is an arbitrary string which may contain spaces, ... and not useful for more than two character switches, ... particular program, switches could go anywhere in the command line, before ...
    (sci.electronics.design)
  • Re: Larkin, Power BASIC cannot be THAT good:
    ... it's up to you to play with it, which is usually tokenization first ... arguments is an arbitrary string which may contain spaces, ... and not useful for more than two character switches, ... particular program, switches could go anywhere in the command line, before ...
    (sci.electronics.design)
  • Re: Windows Xp Cmd Problem.
    ... Starts a new instance of the MS-DOS command interpreter. ... /C string Carries out the command specified by string, ... Type pause (we need to pause this as cmd runs and exits quickly) ... Shouldn't string execute with just cmd without the switches? ...
    (microsoft.public.windowsxp.general)
  • Re: How to: Create a script stringing 5 win updates, install, w/o rebo
    ... | I have been challanged with the task of creating a single script that will ... | string 5 together with no reboots. ... switch parameter and see what switches are availble. ... Then use a scripting language that will run the first command and wait until it has ...
    (microsoft.public.windows.server.scripting)
  • TIP #185: Null Handling
    ... nulls, and command modifications for manipulating them. ... Tcl deals with strings, the universal medium for representing data. ... is know and it is an empty string, but if a respondent forgets to give ...
    (comp.lang.tcl)