Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Article Q27324
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
Passing Numeric Variables between Basic and C by Far Reference - Q27324
The following example demonstrates how to pass numeric values from
compiled Basic to Microsoft C by far reference.
This information applies to the Standard and Professional Editions of
Microsoft Visual Basic version 1.0 for MS-DOS and to Microsoft C
Compiler version 7.0.
To compile this example in Visual Basic for MS-DOS, execute the
following commands:
BC BMODULE.BAS;
CL -c -AM CMODULE.C
LINK BMODULE.OBJ CMODULE.OBJ;
Basic Program
-------------
DECLARE SUB NumericFar CDECL (_
BYVAL p1o AS INTEGER, BYVAL p1s AS INTEGER,_
BYVAL p2o AS INTEGER, BYVAL p2s AS INTEGER,_
BYVAL p3o AS INTEGER, BYVAL p3s AS INTEGER,_
BYVAL p4o AS INTEGER, BYVAL p4s AS INTEGER)
a% = 32767
b& = 32769
c! = 123.312
d# = 129381.333#
CLS
CALL NumericFar(VARPTR(a%), VARSEG(a%),_
VARPTR(b&), VARSEG(b&),_
VARPTR(c!), VARSEG(c!),_
VARPTR(d#), VARSEG(d#))
LOCATE 5, 1
END
C Routine
---------
#include <stdio.h>
void NumericFar(int far *a, long far *b, float far *c, double far *d)
{
printf("INTEGER %d\", *a);
printf("LONG %ld\", *b);
printf("FLOAT %f\", *c);
printf("DOUBLE %lf\", *d);
}
Output
------
INTEGER 32767
LONG 32769
FLOAT 123.311996
DOUBLE 129381.333000