Re: Larkin, Power BASIC cannot be THAT good:



"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

--
Deep Friar: a very philosophical monk.
Website: http://webpages.charter.net/dawill/tmoranwms


.



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)
  • Re: my reminders dont work
    ... I was able to fix the problem once I ran the proper command line ... or in combination with the other command line switches that I had previously ... > <<I know that you really do get people that are stupid enough to not have ... > made it past the point of checking to see if my speakers were turned on?>> ...
    (microsoft.public.outlook)