Use the STDCALL command to call to a function or procedure as an external function declaration. Once the function or procedure name is declared, the DLCALL function may be used.
Options
ALIAS AliasName
Specifies an alias name for the function.
datatype
Specifies an R:BASE data type.
FUNCTION
Specifies that a function is declared.
FunctionName
Specifies the function name.
FunctionOrProcedureName
Specifies the function or procedure name.
PTR
Specifies a data type pointer.
(size)
Defines the length for the TEXT or VARCHAR data type. Defines the precision and scale of a column of the DECIMAL or NUMERIC data type, if not the default of precision 9 and scale 0 (9,0).
VOID
Specifies that the function does not return a value.
About the STDCALL Command
STDCALL is a declaration in the R:BASE environment to set a reference (access) to the function.
Calls from any DLL must be declared at least once in the R:BASE session from which they will be referenced. The STDCALL declaration should be in a startup location for the R:BASE application. There is no limit to the number of declarations, but only make declarations that the application will use. Calling conventions specify how arguments are passed to a function, and how return values are passed back out of a function.
For best results, TEXT and VARCHAR data should be passed with the PTR (pointer) attribute. Any VARCHAR data type larger than 32K as a parameter, MUST be passed with the PTR attribute. It is important that the SIZE parameter on TEXT and VARCHAR be specified to avoid creating excess buffer space that has to be created from the declaration. The VARCHAR data type as a Return Value is restricted to 32K, but any SIZE up to 256MB can be passed as a pointer to the R:BASE variable. Modification of the data passed as pointer must be on the data pointed to.
STDCALL and CDECL are available as external function declaration commands. There is no performance difference between the two commands. When using CDECL, the calling program pushes the parameters on the stack and clears the stack on return. When using STDCALL, the calling program pushes the parameters on the stack but the called program clears the stack before doing the return. Choosing one over the other would depend on what style the DLL code being called is using.
Notes:
•The (size) parameter applies to TEXT and VARCHAR data types
•Parameters in the declaration are in the "reverse" order from the actual function or procedure in the DLL
•Parameters can be 0 to n parameters of any R:BASE data type
•Function names are case sensitive in the STDCALL or CDECL command declaration ONLY. The case must match the casing used in the DLL.
•The case is insensitive when used in the DLCALL function.
Considerations:
If the function is declared as follows, then nn is less than or equal to 256 megabytes.
STDCALL FUNCTION 'somefunction' ( PTR VARCHAR (nn)) : INTEGER
If the function is declared as follows, the buffer for VARCHAR will have default size equal to 256MB because the size is omitted. It is advised to avoid this declaration use, unless that is the actual size of the data to be passed.
STDCALL FUNCTION 'somefunction' ( PTR VARCHAR ) : INTEGER
If the function is declared as follows, the buffer for VARCHAR will have default size equal to 32 kilobytes because the size is omitted.
STDCALL FUNCTION 'somefunction' ( INTEGER ) : VARCHAR
If the function is declared as follows, nn bytes less than or equal to 32 kilobytes will be returned because the size is specified. When the size is specified, the data is passed as a parameter or as a return value will be truncated to the size value, if the data is greater than the size.
STDCALL FUNCTION 'somefunction' ( INTEGER ) : VARCHAR(nn)
Examples:
Function Declarations:
STDCALL FUNCTION 'Num2WrdSTD' ( PTR INTEGER, PTR TEXT, DOUBLE ) : INTEGER
STDCALL FUNCTION 'MultIntSTD' ( INTEGER ) : INTEGER
STDCALL FUNCTION 'LCaseByVALSTD' ( PTR TEXT ) : TEXT
Procedure Declarations:
STDCALL VOID 'LCaseByREFSTD' ( PTR TEXT )
STDCALL VOID 'FunctionOrProcedureThatHasNoReturnValue' ( PTR TEXT (SIZE))
Windows API Declaration:
STDCALL FUNCTION 'GetCurrentDirectoryA' ALIAS 'GetCurrentDir' ( PTR TEXT, INTEGER ) : INTEGER
See Also: