Microsoft KB Archive/27325

= Example Passing Near Numeric Variables between Basic and C =

Article ID: 27325

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q27325



SUMMARY
The two programs shown below demonstrate how numeric variables can be passed from compiled Basic to Microsoft C by near 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
The following Basic program is BNUMNEAR.BAS, which passes each of the standard numeric types to a C subroutine: DECLARE SUB NumericNear CDECL (a%,b&,c!,d#) a% = 32767 b& = 32769 c! = 123.312 d# = 129381.333# CLS CALL NumericNear(a%, b&, c!, d#) END The following program is CNUMNEAR.C, which prints out the standard numeric values passed from Basic: void NumericNear(a, b, c, d)  int near *a; long near *b; float near *c; double near *d; {   printf(&quot;INTEGER %d  \n&quot;, *a); printf(&quot;LONG   %ld \n&quot;, *b); printf(&quot;FLOAT  %f  \n&quot;, *c); printf(&quot;DOUBLE %lf \n&quot;, *d); } To demonstrate these programs from an .EXE program, compile and link as follows:
 * 1) include 

BC BNUMNEAR.BAS;

CL /c /AM CNUMNEAR.C; < for Microsoft C Optimizing Compiler >

or

QCL /c /AM CNUMNEAR.C; < for Microsoft QuickC Compiler >

LINK /NOE BNUMNEAR CNUMNEAR;

BNUMNEAR.EXE produces the following output:

INTEGER 32767

LONG 32769

FLOAT 123.311996

DOUBLE 129381.333000

Additional query words: QuickBas BasicCom

Keywords: KB27325

-

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

© Microsoft Corporation. All rights reserved.