RATS 11
RATS 11

Miscellaneous /

Compiled Sections and Compile Mode

Home Page

← Previous Next →

Ordinarily, RATS executes each instruction in order, and finishes with one instruction before moving on to the next. (The technical term for this is that RATS in normally in interpreted mode). However, PROCEDUREs, FUNCTIONS, loops (DO, WHILE, etc.), IF-ELSE statements, and the symbols “{”and “}” (which are short for BEGIN and END) all put RATS into compile mode (thus these structures are called compiled sections).

 

In compile mode, RATS “compiles” or processes all instructions in the block, but does not execute them immediately. It only begins executing the block when it encounters an END instruction or “}” symbol signaling an end to the block (or, in the case of procedures, an EXECUTE instruction calling the procedure or for a FUNCTION, which the FUNCTION is used in an expression).

 

As mentioned above, the symbol “{” tells RATS to begin a compiled section. RATS will continue compiling instructions until it sees a matching “}” symbol. These are most commonly used in IF instructions, or with FIND, but you can use them just about anywhere you like.

 

Some of the compiled structures have obvious terminators: PROCEDURE, FUNCTION, DO, DOFOR and LOOP require, by construction, a matching END instruction. IF, WHILE, UNTIL and FIND, on the other hand, can control just a single line (for simplicity) and so don't have an obvious sign that you are finished with the compiled section. For those you can either enclose your compiled section in {...} (equivalently BEGIN and END) or you can just add an END instruction, as the initial IF (or whichever) instruction, outside of a compiled section, automatically adds an implied BEGIN. So the following are equivalent:

 

begin

if trans == 1

   set transfrm nbeg nend = series

else if trans == 2

   set transfrm nbeg nend = log(series)

else

   set transfrm nbeg nend = sqrt(series)

end

 

 

{

if trans == 1

   set transfrm nbeg nend = series

else if trans == 2

   set transfrm nbeg nend = log(series)

else

   set transfrm nbeg nend = sqrt(series)

}

 

if trans == 1

   set transfrm nbeg nend = series

else if trans == 2

   set transfrm nbeg nend = log(series)

else

   set transfrm nbeg nend = sqrt(series)

end if

 

 


Copyright © 2025 Thomas A. Doan