[comp.sys.amiga] c/EVAL for loop counting

ISCOVE%UTOROCI.BITNET@cornellc.cit.cornell.edu (03/09/89)

The Enhancer 1.3 manual p 2-12 gives the following example
for use of "c/EVAL" to count loops in a script:

    .key loop/a
    .bra {
    .ket }
    echo >env:loop {loop}
    lab start
    echo "Loop #" noline
    type env:loop
    eval <env:loop >NIL: to=t:qwe{$$} value2=1 op=-?
    type >env:loop t:qwe{$$}
    IF val $loop GT 0
    skip start back
    endif
    echo "done"

In practice, the example fails when eval is called.  ram:env/loop was
correctly set up beforehand, and ENV: assigned as RAM:ENV.
eval <env:loop - 1 to t:qwe{$$}   also fails.  The following also fails from
the Shell along with numerous permutations:

> setenv loop 5
> type env:loop       ; correctly returns 5
> eval <env:loop + 2  ; returns 0 instead of 7

Can anyone help with the proper syntax here?
Commodore?

Norman Iscove  ISCOVE@UTOROCI.bitnet

adam@cbmvax.UUCP (Adam Levin CATS) (03/10/89)

In article <10437@louie.udel.EDU> ISCOVE%UTOROCI.BITNET@cornellc.cit.cornell.edu writes:
>The Enhancer 1.3 manual p 2-12 gives the following example
>for use of "c/EVAL" to count loops in a script:
(All of script deleted except for offending line)
>    eval <env:loop >NIL: to=t:qwe{$$} value2=1 op=-?
>
>In practice, the example fails when eval is called.  ram:env/loop was
>correctly set up beforehand, and ENV: assigned as RAM:ENV.

There needs to be a space between the minus sign (-) and the question mark (?).
It is hard to judge it in the line as printed, but the space is there.

>eval <env:loop - 1 to t:qwe{$$}   also fails.  The following also fails from
>the Shell along with numerous permutations:
>
>> setenv loop 5
>> type env:loop       ; correctly returns 5
>> eval <env:loop + 2  ; returns 0 instead of 7
>
>Can anyone help with the proper syntax here?
>Commodore?

Use eval <env:loop >NIL: to=* op=+ 2 ?

The question mark, usually used to get the template of the command, is being
used here to make the command get its arguments from standard input.  Usually
standard input will be the console the command is typed in on, but because of
the <env:loop redirection, standard input is taken from env:loop.  However,
env:loop only has one argument in it, so the rest are taken from the command
line.  The >NIL: redirection is used to avoid displaying the template which
the question mark invoked.  However, this means that the result of the command
also gets sent to NIL:.  The "to=*" argument causes the results of the command
to be sent to "*" the console device the command was typed in on.
See how easy computers make things?

>
>Norman Iscove  ISCOVE@UTOROCI.bitnet

Adam


-- 
     Adam Keith Levin  --  CATS   Commodore-Amiga Technical Support
     1200 Wilson Drive / West Chester, PA  19380     (215) 431-9180
     BIX: aklevin        UUCP: ...{amiga|rutgers|uunet}!cbmvax!adam