[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] ProgramArgs problem
From: |
Christoph Schlegel |
Subject: |
Re: [Gm2] ProgramArgs problem |
Date: |
Sun, 7 Apr 2013 10:12:58 +0200 |
Hello Carl,
thank you, of course it does help - the missing call to NextArg must have been
gone by accident... and I read the snippet more than once but didn't see the
error. Yes, one up in the list of unterminated loops.
Skipping over your remarks about the toolname itself there is a new problem now
as the program
cid:=ProgramArgs.ArgChan();
WHILE ProgramArgs.IsArgPresent() DO
TextIO.ReadToken(cid,str);
STextIO.WriteString(str);
STextIO.WriteLn;
ProgramArgs.NextArg();
END; (* WHILE *)
now outputs empty lines. Providing one argument I get two empty lines but no
printed argument. From the number of lines it seems the toolname is the first
argument.
I think p1 Modula-2 also doesn't skip the toolname
(http://modula2.awiedemann.de/manual/lib1.html#L1_3_7).
Regards,
Christoph
On Sat, 6 Apr 2013 18:11:39 -0700 (PDT)
Carl Glassberg <address@hidden> wrote:
> Greetings:
>
> I wonder if you need to call ProgramArgs.NextArg() within the loop, so you
> can process all the named arguments? A simple mistake, I have by mistake
> created my share of loops that don't terminate!
>
> Also, if in Unix-like operating system, the command-line tool-name is always
> the first argument, don't you need to call ProgramArgs.NextArg() before the
> loop to skip the program name? This depends on the implementation because I
> know that ADW/Stony Brook m2 already skips over the tool name so you don't
> call NextArg before the loop.
>
> Also, I have sample text filters that process named input files in a loop but
> I only call ProgramArgs.ArgChan() after first checking if there is an
> argument (after skipping the toolname itself just before the loop.
>
> See Google Code under the name "m2-text-filters" at
> <http://code.google.com/p/m2-text-filters/> and each filter has its own Wiki
> page with the source.
> I have not tried these filters using Gm2, only p1 Modula2.
>
> I don't know if this will help.
>
> Sincerely
> Carl Glassberg
> ---
>
>
--
Christoph Schlegel <address@hidden>