forlang.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
$INCLUDE
                                             Up Contents Index Back
─────$INCLUDE───────────────────────────────────────────────────────────────
 
     Action
 
     Inserts the contents of a specified text file at the location of the
     $INCLUDE metacommand.
 
     Syntax  $INCLUDE:'filename'
 
     Parameter          Description
 
     filename           Name of the text file to include
 
     Remarks
 
     The argument file name must be a valid file specification.
 
     The compiler considers the contents of the include file to be part
     of the program file and compiles them immediately. At the end of
     the included file, the compiler resumes processing the original
     source file at the line following the $INCLUDE metacommand.
 
     The compiler looks for files in the directory specified by the
     INCLUDE environment variable.
 
     Include files can also contain other $INCLUDE metacommands and
     INCLUDE statements (nested included files). The compiler allows you
     to nest any combination of up to ten $INCLUDE metacommands or
     INCLUDE statements.
 
     This program implements a stack by declaring the common stack
     data in an include file. The contents of the file STKVARS.FOR
     (shown below the following program) are inserted in the source
     code in place of every $INCLUDE metacommand. This guarantees all
     references to common storage for stack variables are consistent.
 
     Example
 
           INTEGER i
           REAL    x
 
     $INCLUDE:'stkvars.for'
 
     C     read in five real numbers:
           DO 100 i = 1, 5
              READ (*, '(F10.5)') x
              CALL Push (x)
       100 CONTINUE
 
     C     write out the numbers in reverse order:
           WRITE (*, *) ' '
           DO 200 i = 1,5
              CALL Pop (x)
              WRITE (*, *) x
       200 CONTINUE
           END
 
           SUBROUTINE Push (x)
     C     Pushes an element x onto the top of the stack.
 
           REAL x
 
     $INCLUDE:'stkvars.for'
 
           top = top + 1
           IF (top .GT. stacksize)  STOP 'Stack overflow'
           stack(top) = x
           END
 
           SUBROUTINE pop(x)
     C     Pops an element from the top of the stack into x.
 
           REAL x
 
     $INCLUDE:'stkvars.for'
 
           IF (top .LE. 0)  STOP 'Stack underflow'
           x   = stack(top)
           top = top - 1
           END
 
     The following is the file STKVARS.FOR:
 
     C     This file contains the declaration of the common block
     C     for a stack implementation. Because this file contains an
     C     assignment statement, it must be included only after all
     C     other specification statements in each program unit.
 
           REAL     stack(500)
           INTEGER  top, stacksize
 
           COMMON  /stackbl/ stack, top
 
           stacksize = 500
                                    -♦-