ex.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[S] Statement (Non-Basic Procedures) Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the CALL and CALLS statements to pass a Basic array to a
' C function.
 
' Note: To run this program, you must:
' • Compile the C function Separately with the medium-model (/AM) switch
' • Place the object module in a Quick library or link it to the Basic main
'   program
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DEFINT A-Z
 DECLARE SUB AddArr CDECL (SEG Array, SEG Num)
 DIM A(1 TO 100) AS INTEGER
 
 CLS                    ' Clear the screen
 N = 15                 ' Fill the array with the numbers 1 to N
 FOR I = 1 TO N
     A(I) = I
 NEXT I
 
 CALLS AddArr(A(1), N)  ' Call the C function using CALLS the first time
                        ' and increment all array elements by 1
 CALL AddArr(A(1), N)   ' Call the same C function again using CALL and
                        ' increment all array elements by 1
 
 FOR I = 1 TO N         ' Print the modified array; all elements will be
     PRINT A(I),        ' incremented by a total of two - for example,
 NEXT I                 ' what was 1 will now be 3
 END
 
' C Function addarr.
'
' /* Add one to the first num elements of array arr.*/
' void far addarr(arr,num)
' int far *arr;
' int far *num;
' {
'    int i;
'    for(i=0;i<*num;i++) arr[i]++;
' }