Microsoft KB Archive/58411: Difference between revisions
(importing KB archive) |
m (Text replacement - "<" to "<") |
||
Line 90: | Line 90: | ||
<br /> | <br /> | ||
TEST.C is as follows: | TEST.C is as follows: | ||
<pre class="codesample"> #include | <pre class="codesample"> #include <stdio.h> | ||
void test(char a, char b) | void test(char a, char b) | ||
{ | { |
Revision as of 09:26, 21 July 2020
Article ID: 58411
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 Q58411
SUMMARY
Microsoft C uses 2 bytes when passing single-byte parameters; therefore, to pass a single-byte data item by value between C and Basic, the Basic parameter must be DECLAREd as an INTEGER.
This information applies to Microsoft QuickBasic Versions 4.0, 4.0b, and 4.5 for MS-DOS, to Microsoft Basic Compiler Versions 6.0 and 6.0b for MS-DOS and MS OS/2, to Microsoft Basic Professional Development System (PDS) Version 7.0 for MS-DOS and MS OS/2, to Microsoft QuickC Versions 2.0 and 2.01 for MS-DOS, and to Microsoft C Compiler Versions 5.0 and 5.1 for MS-DOS and MS OS/2.
MORE INFORMATION
The two programs below demonstrate passing a character by value from Basic to C.
To run the programs, do the following:
- Compile as follows, depending on which language you are using:
Compile in Basic as follows:
BC testb ;
For Microsoft C Versions 5.0 and 5.1, compile as follows:
CL -c -AL test.c ;
For Microsoft QuickC, compile as follows:
QCL -c -AL test.c ;
LINK with the following line:
LINK /NOE testb+test ;
The following program, TESTB.BAS, illustrates passing characters from Basic to C by using the ASCII values and DECLAREing the C char parameter with BYVAL var AS INTEGER:
DECLARE SUB test CDECL (BYVAL a%, BYVAL b%) CALL test(ASC("A"), ASC("B")) END
TEST.C is as follows:
#include <stdio.h> void test(char a, char b) { printf("%c %c\n",a,b); }
When compiled and run, TESTB.EXE displays the following:
A B
Additional query words: QuickBas BasicCom
Keywords: KB58411