Microsoft KB Archive/48206

= Example of C Functions Returning Numeric Types to Basic =

Article ID: 48206

Article Last Modified on 8/16/2005

-

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
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q48206



SUMMARY
The two programs shown below demonstrate how Microsoft C functions can return common numeric types to Basic.



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 BFUNC.BAS, which invokes several C functions, and prints out the values returned by the functions: DECLARE FUNCTION cintfunc% CDECL DECLARE FUNCTION clongfunc& CDECL DECLARE FUNCTION cdoublefunc# CDECL PRINT &quot;Integer: &quot;; cintfunc PRINT &quot;Long  : &quot;; clongfunc PRINT &quot;Double : &quot;; cdoublefunc The following program is CFUNC.C, which contains several functions called from Basic. These functions return standard numeric types to the calling Basic program. int cintfunc(void)       /* Basic INTEGER */ {  int theint = 32767; return(theint); }

long clongfunc(void)     /* Basic LONG */ {  long thelong = 32769;

return(thelong); }

double cdoublefunc(void) /* Basic DOUBLE */ {  double thedouble = 129381.123; return(thedouble); } To demonstrate these programs from an .EXE program, compile and link as follows: BC BFUNC.BAS; CL /c /AM CFUNC.C;  LINK /NOE BFUNC CFUNC; BFUNC.EXE produces the following output:

Integer: 32767

Long : 32769

Double : 129381.123

Additional query words: QuickBas BasicCom

Keywords: KB48206

-

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

© Microsoft Corporation. All rights reserved.