HP3000-L Archives

June 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Glenn Cole <[log in to unmask]>
Reply To:
Date:
Wed, 16 Jun 1999 12:00:39 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
Tad Bochan writes:

> The standard template for reading a file
> is as follows,
>
> setvar n finfo(hpstdin,"eof")
> while setvar(n,n-1)>=0 and setvar(rec,input())>=""
>    echo ![rec]
> endwhile

Thank you for providing this!  I had managed to forget this
(as well as how to safely get an ANYPARM value into a CI var). :(

> The finfo tells you how many records are in HPSTDIN,
> and the command file just counts down until all
> records are processed..

And a very handy var this is, which I had managed somehow to forget!
Obviously, you can use this to tell whether or not input comes from
$STDIN, a tidbit that I did not know.

What a day for learning! :)


However, I should also point out that the 'while' statement above
will *not* work correctly if the command file is run from within MPEX.

Yes, as great a tool as MPEX is, I feel compelled to point out examples
that fail because of MPEX's lack of short-circuit evaluation.  That is,
even though MPE and Qedit both will terminate the 'while' when the first
condition fails (because it's an AND, and 'false AND something' always
evaluates to false, so there's no need to evaluate the second condition).
Unfortunately, MPEX will try the setvar anyway, and fail.

--Glenn

.......................................................................

Item Subject: cc:Mail Text

ATOM RSS1 RSS2