Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > C

CDECL

Scroll Prev Top Next More

Use the CDECL 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.

 

CDECL

 

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 CDECL Command

 

CDECL 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 CDECL 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.

 

 

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.

 

CDECL 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.

 

CDECL 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.

 

CDECL 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.

 

CDECL FUNCTION 'somefunction' ( INTEGER ) : VARCHAR(nn)

 

 

Examples:

 

Function Declarations:

 

CDECL FUNCTION 'FunctionName' ( INTEGER ) : INTEGER

 

CDECL FUNCTION 'FunctionName' ALIAS 'FunctionAliasName' (PTR DOUBLE) : DOUBLE

 

Procedure Declarations:

 

CDECL VOID 'FunctionOrProcedureThatHasNoReturnValue' ( PTR TEXT (SIZE))