CALL, CALLS Statements (Non-BASIC Procedures) ---------------------------------------------------------------------------- Action Transfer control to a procedure written in another language. To invoke a BASIC procedure, use the CALL statement (BASIC). Syntax 1 CALL name -( call-argumentlist)- Syntax 2 name - call-argumentlist- Syntax 3 CALLS name -( calls-argumentlist)- Remarks 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. For more information about invoking procedures without the CALL keyword, see Chapter 2, "SUB and FUNCTION Procedures" in the Programmer's Guide. 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. The CALL and CALLS statements use the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- name The name of the non-BASIC procedure being called. call-argumentlist The variables, arrays, or expressions passed to the procedure. calls-argumentlist The variables or expressions CALLS passes to the procedure. The call-argumentlist has two forms of syntax. In the first form, argument is a variable. --{BYVAL|SEG}-argument- -,-{BYVAL|SEG}-argument-... If argument is an array, parentheses are required. -argument-( )-- -, argument -( )--... The following list describes the parts of call-argumentlist. ----------------------------------------------------------------------------- Part Description ---------------------------------------------------------------------------- BYVAL Indicates the argument is passed by value rather than by near reference (the default is by reference). BYVAL cannot be used if the argument is an array. SEG Passes the argument as a segmented Part Description ---------------------------------------------------------------------------- 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 of parentheses. For example. DIM IntArray(20) AS INTEGER . . . CALL ShellSort(IntArray) AS INTEGER The argument calls-argumentlist has the following syntax, where argument is a BASIC variable or expression. - argument- -, argument-... 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. The result of the BYVAL keyword differs from BASIC's pass by value. CALL Difference (BYVAL A,(B)) For the first argument, only the value of A is passed to Difference. In contrast, (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). Note If the argument name refers to an assembly-language procedure, it must be a name declared with PUBLIC (symbol). 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. See Also CALL (BASIC); DECLARE (BASIC); DECLARE (Non-BASIC) Example See the VARPTR function programming example, which uses a CALL statement to invoke a C function.