Microsoft KB Archive/27300

= Passing Basic Array of Fixed-Length Strings to C =

Article ID: 27300

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q27300



SUMMARY
The following example demonstrates how to pass an array of fixed-length strings from compiled Basic to Microsoft C.

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 StringFar CDECL (_       length%,_        num%,_        BYVAL p3o AS INTEGER,_        BYVAL p3s AS INTEGER) CLS DIM array(10) AS STRING * 10 length% = 10 num% = 3 FOR i = 0 TO 10 array(i) = STRING$(9, 65 + i) + CHR$(0) NEXT i CALL StringFar(length%, num%, VARPTR(array(0)), VARSEG(array(0))) END

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

void StringFar(len,num,array) int *len; int *num; char far *array; {   int i;    printf(&quot;The string length is : %d \n\n&quot;,*len); printf(&quot;The number of elements is : %d \n\n&quot;,*num); printf(&quot; Index       String\n&quot;); for (i=0;i < *num; i++) {        printf(&quot;  %2d         %s\n&quot;,i,array); array=array+*len; }; }
 * 1) include 

OUTPUT
The string length is : 10

The number of elements is : 3

Index       String 0        AAAAAAAAA 1        BBBBBBBBB 2        CCCCCCCCC

Additional query words: QuickBas BasicCom

Keywords: KB27300

-

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

© Microsoft Corporation. All rights reserved.