Next: , Previous: Ratfor, Up: Ratfor


9.1 Ratfor syntax

A sample Ratfor program is

     @r
     @
     @a
     program main
     {
     integer k;
     real fcn, x;
     
     for(k=0; k<10; k++)
             {
             x = fcn(k);
     
             if(x < 0.0)
                     {
                     x = 0.0;
                     break;
                     }
             }
     }

The concluding brace of a function is translated into an END statement. Note the use of semicolons to terminate statements, braces to delimit compound statements, ‘<’ instead of ‘.LT.’, the C-like for construction, and the ‘k++’ expression.

Constructions like ‘k++’ or ‘k -= l + 1’ must be used with great care. They translate to statements involving ‘=’ signs, so they can be used only where simple statements are allowed, not essentially anywhere as in C (for example, they cannot be used as function arguments).