bas7advr.hlp (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.
CALL, CALLS Statements (Non-BASIC Procedures) Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The CALL and CALLS statements transfer control to a procedure written in
another language. (A different CALL statement is used to transfer
control within a BASIC program.)
 
CALL name [(call-argumentlist)]
  or
name [call-argumentlist]
  or
CALLS name [(calls-argumentlist)]
    ■ If name refers to an assembly-language procedure, it must be a
      name declared with PUBLIC (symbol).
    ■ The call-argumentlist has the following syntax:
 
       Syntax 1 (for non-array arguments):
 
        [[{BYVAL|SEG}] argument] [,[{BYVAL|SEG}] argument]...
 
       Syntax 2 (for array arguments):
 
        [argument()] [, argument()]...
 
        BYVAL       Passes the argument by value rather than by reference
                    (the default is by reference). BYVAL cannot be used
                    if the argument is an array.
        SEG         Passes the argument as a segmented (far) address. SEG
                    cannot be used if the argument is an array.
        argument    A BASIC variable, array, or expression passed to a
                    procedure. Use the first syntax if argument is not
                    an array; use the second if argument is an array.
                    (The array is specified by the array name and a
                    pair or parentheses.) For example:
 
                      DIM IntArray(20) AS INTEGER
                      .
                      .
                      .
                      CALL ShellSort(IntArray() AS INTEGER)
 
    ■ The calls-argumentlist has the following syntax:
 
        [argument] [,argument]...
 
        argument    A BASIC variable or expression. These arguments are
                    passed by reference as far addresses, using the segment
                    and offset of the variable. Whole array arguments
                    cannot be passed by CALLS.
 
Usage Notes
    ■ The result of the BYVAL keyword differs from BASIC's pass by value:
 
        CALL Difference (BYVAL A,(B))
 
        Argument      Result
        ════════      ════════════════════════════════════════════════════
        A             Only the value of A is passed to Difference.
        (B)           Is evaluated, a temporary location is created for
                      the value, and the address of the temporary location
                      is passed to Difference
 
      You can use BASIC's pass by value for an argument, but the procedure
      in the other language must accept an address (because the address of
      the temporary location is passed).
    ■ Be careful using the SEG keyword to pass elements of arrays because
      BASIC may move arrays in memory before the called routine begins
      execution. Anything in an argument list that causes memory movement
      may create problems. You can safely pass variables using SEG if the
      CALL statement's argument list contains only simple variables,
      arithmetic expressions, or arrays indexed without the use of
      intrinsic or defined functions.
    ■ The CALL keyword is optional when you use the CALL statement.
      When you omit CALL, you must declare the procedure in a DECLARE
      statement. When you omit CALL, you omit the parentheses around
      the argument list.
    ■ CALLS is the same as using CALL with a SEG before each argument:
      every argument in a CALLS statement is passed as a segmented address.