FLECS Version 22H(126) _____ _______ ________ FORTRAN Language with Extended Control Structures _______ ________ ____ ________ _______ __________ Executing FLECS _________ _____ To execute FLECS, type... .R FLECS _______ *command-line ____________ "command-line" may be in any of the following forms: O,L,I=S/sw -> From .FLX input source file "S"... output .FTX file if "O" is present, output .FLL file if "L" is present, output .FIN file if "I" is present, and list errors to the TT: S/sw -> equivalent to O,L=S above ^Z -> terminate execution ^C -> terminate execution immediately Each file specification may have the form... dev:file.ext Symbol Meaning Default ------ ------- ------- dev: device DK: file file name none (input), input "file" (output) .ext extension .FLX for FLECS source (input) .FTX for FORTRAN source (output) .FLL for listing (output) .FIN for indented source (output) /sw is an optional list of switches from the following: Switch Meaning ------ ------- /C Include comment lines in generated FORTRAN file. /D Translate debugging lines with "D" in column 1 as normal FLECS statements (normally these lines are completely ignored). /L Include FLECS listing line #'s in columns 75-80 of generated FORTRAN file. /N Generate a new indented source file. FLECS Statement Syntax _____ _________ ______ keyword (specification) scope where... "keyword" indicates the structure type "specification" depends on keyword given "scope" the statement(s) controlled The scope FLECS structures may have two forms: keyword (specification) statement keyword (specification) . statement-1 . statement-2 : : . statement-n ...FIN Note: In the second example above, the user need not indent statements 1 to n, nor type the dots; the FIN statement is part of the FLECS structured statement's syntax and is required, however. The indentation and bracket drawn with dots appears only in the FLECS listing file and is provided to aid the programmer in recognizing the scope of the various structured statements coded. Each line of the user's code (the .FLX input file) should begin at the normal FORTRAN-IV column 7 position (unless a tab (^I) is used) and should not be indented. Note: Any line in a FLECS program may optionally end with a comment in the standard form allowed by RT-11 FORTRAN, i.e., with an exclamation point followed by text to be taken as a comment. Thus the full form for FLECS structured statements is: keyword (specification) scope !comment FLECS Control Structures _____ _______ __________ Legend: ______ [L] = Logical expression [E] = Expression (any type) [I] = DO iteration specification [#] = Loop nesting level $ = Scope, 1 or more statement Alternative Structures: ___________ __________ WHEN ( [L] ) $1 ELSE $2 IF ( [L] ) $ UNLESS ( [L] ) $ or IF ( [L] ) THEN $1 ELSE $2 -------------- ------------------ -------------------- | | | v v v /-\ T /-\ F T /-\ F <[L]>---+ <[L]>---+ +---<[L]>---+ \-/ | \-/ | | \-/ | | v | v v v F | $ T | $ $1 $2 | | | | | | |<----+ |<----+ +---->+<----+ | | | v v v Alternative Structures (continued): ___________ __________ ___________ CONDITIONAL SELECT ( [E] ) . ( [L1] ) $1 . ( [E1] ) $1 . ( [L2] ) $2 . ( [E2] ) $2 . . . . . . . ( [Ln] ) $n . ( [En] ) $n ...FIN ...FIN -------------------- -------------------- | | v v /-\ /-\ / \ T /[E]\ T <[L1] >--->$1-->+ < .EQ.>--->$1-->+ \ / | \[E1]/ | \-/ | \-/ | | | | | F | | F | | v | v | /-\ | /-\ | / \ T | /[E]\ T | <[L2] >--->$2-->+ < .EQ.>--->$2-->+ \ / | \[E2]/ | \-/ | \-/ | | | | | F | | F | | ~ ~ ~ ~ : : : : ~ ~ ~ ~ | | | | v | v | /-\ | /-\ | / \ T | /[E]\ T | <[Ln] >--->$n-->+ < .EQ.>--->$n-->+ \ / | \[En]/ | \-/ | \-/ | | | | | F | | F | | |<-----------+ |<-----------+ | | v v Note: OTHERWISE may be used in CONDITIONAL and SELECT statements as a final condition which is "always .TRUE.". Repetitive Structures: __________ __________ WHILE ( [L] ) $ REPEAT WHILE ( [L] ) $ ------------------ ------------------------- | | | +-----+ v | F /-\ T F /-\ T | +---<[L]>---+ +---<[L]>-->| | \-/ | | \-/ | | ^ | | ^ | | | v | | v | | $ | | $ | | | | | | | +-----+ | +-----+ | | +-----+ +-----+ | | v v UNTIL ( [L] ) $ REPEAT UNTIL ( [L] ) $ ------------------ ------------------------- | | | +-----+ v | T /-\ F T /-\ F | +---<[L]>---+ +---<[L]>-->| | \-/ | | \-/ | | ^ | | ^ | | | v | | v | | $ | | $ | | | | | | | +-----+ | +-----+ | | +-----+ +-----+ | | v v Repetitive Structures (continued): __________ __________ ___________ LOOP (init;[L];incr) $ REPEAT LOOP (init;[L];incr) $ ------------------------ ------------------------------- | | | +-----+ v | init v | init v | F /-\ T F /-\ T | +---<[L]>---+ +---<[L]>-->| | \-/ | | \-/ | | ^ | | ^ | | | v | | v | incr $ | incr $ | ^ | | ^ | | | | | | | | +-----+ | +-----+ | | +-----+ +-----+ | | v v [ REPEAT ] LOOP DO ( [I] ) $ ------------------ ------------------------- | | | +-----+ | | v Fail/-\Suc | +-----+ +---<[I]>-->| ^ | | \-/ | | | | ^ | | v | | v | $ | | $ | | | | | +-----+ | +-----+ | +-----+ | v Branch Statements: ______ __________ NEXT [ [#] ] BREAK [ [#] ] ------------------ --------------------- | | v v /-\ /-\ +---< >----+ +---< >----+ | \-/ | | \-/ | | ^ | | ^ | | | | | | | | | NEXT v | BREAK v | |<=====$ |<===========$ | | | | | | | +------+ | +------+ | | +-----+ +-----+ | | v v Internal Procedures: ________ __________ procedure-name TO procedure-name $ ---------------- --------------------- | | +-----+ | | | v ---+ v procedure-name $ | <--+ | | | | | +-----+ v Note: Place a RETURN, STOP, or CALL EXIT statement ahead of the first TO statement. FLECS Statement Extensions _____ _________ __________ RETURN Statement: ______ _________ RETURN ( [E] ) ...which will automatically set the function name equal to the value of the expression [E] and return to the invoking proceedure, thus returning a value of [E] as the value of the function. Note: This statement format is only valid (recognized) in external function-subroutines; found anywhere else, it will remain unchanged in the output file. INCLUDE Statement: _______ _________ INCLUDE "filespec" ...where the defaults for the file specification are device DK: and extension .FLX. This statement causes the entire contents of the file specified to appear as if it was input at the point where the INCLUDE statement is encountered. INCLUDE'd files may be nested to a maximum of 5 levels, and any included statements will appear in the FLECS listing file. STRING Statement: ______ _________ 1) STRING variable (#-chars) 2) STRING variable 'text' The two forms of the STRING statement given above have been added to FLECS to aid in the use of "FLECS-format" strings in FLECS programs. This format uses an integer array to store strings with the current length of the string in the first word and the text of the string packed in A2 format in the remainder of the array. In addition, one extra character is allocated at the end of each RT-11 string to allow the user to null terminate the string for compatibility with SYSLIB. Thus, the first form above may be used to dimension an integer array with 1 + the number of words necessary to store the given number of characters. The second form uses the length of the text specified as the length of the string and will both dimension the integer array and initialize the string to the specified text. The text string is a standard FORTRAN literal and embedded single quotes (') may be represented as usual by two single quotes (''). String declarations of either type may appear separated by commas in the same statement, but the STRING statement, like all FLECS statements, may not be continued to a new line--only one line of text is allowed per STRING statement. FLECS System Commands: _____ ______ ________ $ [ ] $TRUE Sets the value of the specified argument, a conditional translation flag, to TRUE (maximum 10 flags). $FALSE Sets the value of the specified argument to FALSE. $IF Turns on translation of subsequent input source lines only if the specified argument is TRUE. $UNLESS Turns on translation of subsequent input source lines only if the specified argument is FALSE. $FIN Cancels effect of most recent $IF or $UNLESS, restores the decision to translate or not to its previous value. $DEFINE Defines its first argument as a symbol which is to be replaced by its second argument whenever found in the input file. $PAGE Output a form feed to the listing file (does not take an argument). $[NO]LIST Turn off (on) output to the listing file. FLECS Restrictions _____ ____________ 1. Do not use statement numbers of the form 3xxxx or variables of the form I3xxxx, as these are created and used by FLECS. 2. FLECS structured statements may not be continued to a second line. Statements not processed by FLECS, however, may be continued in the normal manner of FORTRAN-IV. 3. Blanks are NOT TRANSPARENT to FLECS. This means that while "D O" is valid for the keyword "DO" in FORTRAN-IV, it is not valid in FLECS. All FLECS keywords are reserved and may not be used as variable names. 4. Any statements which are not recognized by FLECS (eg., assignments, FORMATs, ENCODE/DECODEs, PARAMETERs, etc.) are passed unchanged to FORTRAN. Such statements are assumed to be executable by FLECS and must be placed only where executable statements may appear. For example, the following code is in error... WHEN (X.EQ.0) TYPE 1 1 FORMAT (1X,'Division by Zero') ELSE Z=Y/X ...since the ELSE statement must be the first "executable" statement after the scope of the preceding WHEN statement. The correct code, in this case, would be... WHEN (X.EQ.0) . TYPE 1 1 . FORMAT (1X,'Division by Zero') ...FIN ELSE Z=Y/X 5. FLECS control phrases may not contain parentheses inside Hollerith literals. Z=Y/X ...since the ELSE statement must be the first "executable" statement after the scope of the preceding WHEN statement. The correct code, in this case, would be... WHEN (X.EQ.0)