Microsoft KB Archive/27298

= Passing Basic Array of Long Integers to C by Far Reference =

Article ID: 27298

Article Last Modified on 11/21/2006



This article was previously published under Q27298



SUMMARY
The following example demonstrates how to pass an array of long integers from compiled Basic to Microsoft C by far reference.

This information about inter-language calling applies to QuickBasic Versions 4.00, 4.00b, and 4.50 for MS-DOS and to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2.



MORE INFORMATION
For more information about passing other types of parameters between Basic and C, and a list of which Basic and C versions are compatible with each other, query in the Microsoft Knowledge Base using the following word:

BAS2C

Code Example
REM ===== Basic PROGRAM =====

DECLARE SUB LongArray CDECL (_           BYVAL p1 AS INTEGER,_            BYVAL p2 AS INTEGER) DEFINT A-Z DIM i AS LONG DIM array(10) AS LONG CLS FOR i = 1 TO 10 array(i) = i + 100 NEXT i 'Array must be a FAR pointer, so offset and segment must be passed: CALL LongArray(VARPTR(array(0)), VARSEG(array(0))) LOCATE 15, 1 PRINT &quot;Back in Basic&quot; FOR i = 1 TO 10 PRINT i, array(i) NEXT i END

/* ===== C ROUTINES ===== */

void LongArray(array) long far *array; {   int i;    printf(&quot;Index         Value\n&quot;); for (i=0;i < 11; i++) {        printf(&quot;  %d          %ld\n&quot;,i,array[i]); array[i]=array[i]+100; }; }
 * 1) include 

OUTPUT
Index        Value 0         0  1          101  2          102  3          103  4          104  5          105  6          106  7          107  8          108  9          109  10          110

Back in Basic 1            201 2             202 3             203 4             204 5             205 6             206 7             207 8             208 9             209 10            210

Additional query words: QuickBas BasicCom

Keywords: KB27298

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.