Script Syntax
Please read first the introduction to Scripts.

Lets speak about the script syntax.
I means the syntax of what you can find into script_xxx files...

rules


Object in scripts

You can have as many object you want in script, each of them will be placed into the stack.
for deep details about object syntax see object syntax.
in general object start with a \type example, \1 123 is a number (type 1). general view
object syntax alternate syntax
numbers (123) \1 123 123
strings \4 .... "string"
lists \6 nb ... none
array \7 nb ... none
complexs \8 ... none

Action in scripts

If you want to perform one action, you have to start the line with \!
example : \! SWAP

If you want to execute serverall RPL action, you can use \> syntax
example
\>
SWAP
DUP
+
SWAP
\x
is the same as
\! SWAP
\! DUP
\! +
\! SWAP
Note, if you use the Alternate Script System you just need to type { swap dup + swap } and use list->script to get your script. but in this case you have the version with \!.

To end a \> you must use \x

Loops

The syntax is as follow :
\@ FOR
...
\@ INDEX
..
\@ NEXT
\@ FOR wait for two numbers from stack (from to)
\@ INDEX return to stack the index
\@ NEXT end the loop
in Alternate script system, you just have to type for index and next, the function list->script will add all necessery \@. example :
in alternate script system in script
{ 1 5 for index ^2 next 5 ->list }
1
5
\@ FOR
\@ INDEX
\! ^2
\@ NEXT
5
\! ->list	
result is {1 4 9 16 25}, as expected...

Nested loops

You can have nested loop,
in this case, you may need to get outer indexes...

the \@ INDEX always give inner index !
You can use accumulator A,B and C to get them.. (see sTO_A and RCL_A) example
1
5
\@ FOR
\@ INDEX
\! STO_A
10
20
\@ FOR
\! RCL_A
\@ INDEX
\! R->C
\@ NEXT
\@ NEXT
the red loop is the outer-loop (1 to 5)

We store the outer index in A (STO_A)



We run inner-loop (10 to 20).

outer-index is RCL_A
inner-index is \@ INDEX
we can create a complex (for example)


This script create complex number like this (x;y) x is from 1 to 5 and y from 10 to 20.

you can have serveral loop level, (up to 4, which should be enough) by using A B and C accumulators.
you can also use :
  • stack (not very easy)
  • or, VARs (STO and Exec) not very fast because of file manipulation
  • Special

    You can place comments by using \# at the beginig of the line.
    ex :
    \#this script perform a md5 on the file "myfile"
    "myfile"
    \! FileRead
    \! md5