Re: Inform--I need help


Tue, 08 Aug 1995 15:50:01 +0100

Robert A. DeLisle (rad@crl.com) wrote:

> If any beginner has not read the Tutorial, I stongly recommend it.
> I 'logged' it and will print it later for reference..
>
> The kitten example is more fun that the pair of gloves in toyshop.
>
> The 'rtrue/rfalse' is explained very well.

Yes, the tutorial is excellent; it wouldbe a worthwhile addition to the
Designer's Manual I think. Thanks Gareth.

> Now--add the 'for' syntax.
> (I asked my son who programs in anything and he will supply a C manual).
> I do not know C and there must be others. The 'for' loop is
> not the same as BASIC. Unless there is a built in 'delay' routine,
> I would like to use 'for' to put in a brief delay in statements.
> Statement 1 follows the action, a brief delay, statement 2 appears.

You mean like:

[ DelayedMessage i;
print "Blah blah blah...^";
for (i = 0: i <= 1000: i++) { ; }
"... blah blah blah.";
];

Wouldn't this be very system dependent (ie, a slow computer would take far
longer than a zippy one, making it difficult to gauge the requirements of the
`for' loop)? I think what you need is timed input, like:

[ DelayedMessage keypress;
print "Blah blah blah...^";
read_char 1 3 0 keypress;
"... blah blah blah.";
];

The read_char statement will wait until either there is input from the
keyboard (this is the first argument and should always be one), and then
place the ascii value of the key pressed in the variable keypress, or wait
for n seconds (as defined in the second argument -- 3 in this case). Then,
if the third argument is a routine name (preceded by `#r$' which turns it
into a numerical value, as in `#r$DoRoutine') it calls this routine (if it's
0 as above then no routine is called). Control is then passed back to your
code, and everything carries on as usual.

But, bear in mind that some interpreters don't support timed input, and so
will only wait around for a keypress (I don't think any Acorn ones support
it, for instance).

-- 
Jools
  jools@arnod.demon.co.uk