qb45advr.hlp (Topic list)
DECLARE (Non-BASIC Procedure) Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
DECLARE (Non-BASIC Procedure) Statement Programming Example
 
The following example shows a BASIC program that calls a short C
function. The C program would be separately compiled and stored in a
Quick library or explicitly linked to form the .EXE file.
 
'*** Programming example: DECLARE (Non-BASIC procedure) ***
'
' Do not attempt to run this program unless you have already
' separately compiled the C function and placed it in a
' Quick library or linked it to the BASIC program.
'
DEFINT a-z
' The function addone uses C argument passing and takes
' a single integer argument passed by value.
DECLARE FUNCTION addone CDECL (BYVAL n AS INTEGER)
 
INPUT x
y=addone(x)
PRINT "x and y are ";x;y
 
END
 
 /* C function addone. Returns one more than the value of its
     integer argument. */
int far addone(n)
int n;
{
   return(++n);
}