Registers and the set Command

Autolog provides 10 user-definable registers, called reg(0) through reg(9), which can be used like "integer variables" for storing numbers, counting, and so on. Autolog also provides a "stopwatch" for measuring time called the timer register. Two error registers, called err0 and err1, are used for reporting errors, but cannot be changed directly. Registers are useful for creating intelligent scripts.

Use the set command to set the value of any of the 10 integer registers or the timer:
 

set reg(n) = integer
set timer = number of seconds

You can add (+), subtract (-), multiply (*), and divide (/) integers in a set command. (The results of integer division are truncated.) For example:
 

set reg(1) = reg(1) + 1
set reg(9) = timer/60

You can also use Boolean operators AND (&), OR (|), and exclusive OR (^). The Boolean operators treat integers as an array of bits:
 

set reg(7) = reg(1) & reg(2) | reg(3)

You can use the show reg command to display the contents of the 10 integer registers, the timer, and the error registers.

You can use the integer registers in if commands for the purpose of making decisions. For instance, you could use a register to store the baud rate you want to call at:
 

set reg(3) = 9600

Then you could use the commands

     if reg(3) <= 9600 dial 555-1212
     if reg(3) = 14400 dial 555-1234
     if reg(3) > 28800 dial 555-5678
to dial the modem number appropriate for your baud rate.

The timer register can be used for timing events. For example:

     set timer = 0         ; starts the "stopwatch"
     ztransmit myfile.txt  ; transfer a file
     set reg(2) = timer    ; store the elapsed time in register 2
Here's another example:
set timer = 0                ; start the "stopwatch"
loop:
  if timer > 60 goto give'up ; give up if no response after 1 min.
  say "^M"                   ; send remote system a carriage return
  until "Enter name:" 5      ; wait 5 seconds for sign-on prompt
  if err0 # 0 goto loop      ; if no prompt, try again
  goto sign'on               ; sign on when prompt received
give'up:
  :<No sign-on prompt from remote system.>
  finish
  :X
sign'on:
  ; got sign-on prompt, say name
  say "my name^M"