|
Calling Procedures Written in Other Languages |
"strlen"(). This ensures the routine's
upper and lower case formatting is preserved.
count%) is passed by
its value. A string is passed by reference (a pointer to its text). Every other number
is a REAL, and a REAL reaches the routine as a C double: by reference by
default — a pointer to a double holding the value, and whatever the
routine writes there comes back into the variable — or, written
by value, the double itself (see the example below). A C int
parameter takes an integer variable: 34 written plainly is a REAL. To pass
an integer by reference (the pointer to it, so the routine can write into it), use the
by ref option:
An array cannot be passed to a DLL routine. An array name,
array name, name() and an array element such as
codes%(2) are all compile-time errors. To hand a routine one element,
copy it into a variable of the same type, pass the variable, and copy it back if
the routine writes to it:
When a routine is called, it may also return a value. The variable
_integer will hold this value if the routine returns an integer.
If the routine returns a pointer to a null-terminated character string
(char*), you can call the routine with the prefix
char*. After the routine completes, _string$ will
contain a copy of the returned string.
For example:
This demonstrates how _string$ automatically holds the returned string
when the routine is called with the char* prefix.
A routine that returns a double is called with the prefix double
in the same way: afterwards _real holds the result, to the 15 significant
digits a double carries. C's math routines take their doubles by value, so those
REALs are written by value; a routine that writes a double through a
pointer (a double * parameter) gets a REAL passed the default way:
CSTRING$ is the other way to the same text: after a call made WITHOUT the
char* prefix, _integer holds the returned pointer as a number, and
cstring$ (no arguments) returns the null-terminated string at that address.
Use it when you want the address as well as the text, or decided on the prefix too late.
A null pointer (0) gives an empty string; a value that is not the address of readable memory
-- _integer after strlen, say -- raises the catchable exception
Bad CHAR* pointer (4011) rather than reading garbage.
msvcrt.dll library and
calls the strlen and _getcwd functions/routines.
msvcrt.dll) or
thoroughly validated custom DLLs.
library and call statements."strlen"())
to preserve case sensitivity.double — by reference (a
double *) by default, the double itself when written
by value.by ref on an integer variable when the routine
writes into it.name() and an
element such as codes%(2) are compile-time errors —
copy the element into a variable of its type, pass that, and copy it
back._integer.char* string, prefix the
call with char*; the result is stored in
_string$.double, prefix the call with
double; the result is stored in _real.strlen and _getcwd from
msvcrt.dll.|
Hide Description
|
|
|
Enter or modify the code below, and then click on RUN |
|
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |