Q(uick)BASIC Keyword: BYVAL
Quick View
BYVAL Keyword
The BYVAL attribute in the parameter list of a DECLARE statement passes the value of the specified variable to the procedure. BYVAL cannot be applied to string parameters
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- BYVAL variable [AS type]
Description/Parameter(s)
The BYVAL attribute in the parameter list of a DECLARE statement causes the value of the specified variable to be passed to the procedure, rather than the variable's address. BYVAL can only be used in DECLARE statements for non-BASIC procedures, and cannot be applied to string parameters.
See also:
Syntax
- BYVAL variable [AS type]
Description/Parameter(s)
The BYVAL attribute in the parameter list of a DECLARE statement passes the value of the specified variable to the procedure. BYVAL cannot be applied to string parameters.
Example
This example uses the DECLARE statement to use a C function in a BASIC program. The BASIC program calls the function addone, which uses C argument passing and takes a single integer argument passed by value.
Note: To run this program, you must separately compile the C function and place it in a Quick library or link it to the BASIC program.
DEFINT A-Z
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 argument. */
'
'int far addone(int n)
'{
' return(n+1);
'}