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.
SSEGADD Statement Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'This example uses the SSEGADD function to obtain the BASIC string address of
'a string used by a C procedure. The BASIC program calls the printmessage C
'procedure which, in turn, calls BASIC to obtain the string address.
'Note: To run this program, you must first compile the C procedure (shown
'below in remarks) and incorporate it in a Quick library or link it to the
'compiled BASIC program.
DEFINT A-Z
DECLARE SUB printmessage CDECL (BYVAL farstring AS LONG)
'Create the message as an ASCIIZ string, as required by the C printf
'function.
a$ = "This is a short example of a message" + CHR$(0)
'Call the C procedure with pointers.
CALL printmessage(SSEGADD(a$))
'/* C Routine printmessage */
'/* Prints a BASIC far string on the screen.*/
'
'#include <stdio.h>
'
'/* Define a procedure which inputs a string far pointer */
'void printmessage (char far *farpointer)
' {
' /* print the string addressed by the far pointer */
' printf( "%s\n", farpointer);
' }
'