Microsoft KB Archive/27303

= Passing Basic 2-Dimension INTEGER Array to C by Far Reference =

Article ID: 27303

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q27303



SUMMARY
The following example demonstrates how to pass a two-dimensional array of 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 TwoIntArray CDECL (_           BYVAL p1o AS INTEGER,_            BYVAL p1s AS INTEGER) CLS DIM x(4, 4) AS INTEGER FOR i = 0 TO 4 FOR j = 0 TO 4 x(i, j) = i * j  NEXT j NEXT i CALL TwoIntArray(VARPTR(x(0, 0)), VARSEG(x(0, 0))) END

/* ===== C ROUTINE ===== */

struct two_int_array{ int a[5][5]; };
 * 1) include 

void TwoIntArray(x) struct two_int_array far *x; /* Note: The array does not have to be in a struct. */ {    int i,j; for (i=0;i<5;i++) {      for (j=0;j<5;j++) {         printf(&quot;  %3d   &quot;,x->a[i][j]); };      printf(&quot;\n&quot;); }; }

OUTPUT
0      0       0       0       0    0       1       2       3       4    0       2       4       6       8    0       3       6       9      12    0       4       8      12      16

Additional query words: QuickBas BasicCom

Keywords: KB27303

-

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

© Microsoft Corporation. All rights reserved.