Show/Hide Toolbars

XSharp

The following pseudo functions are supported by the X# compiler

 

Function

Description

PCOUNT()

This pseudo function is only available in methods or functions with a CLIPPER calling convention.
It returns the number of argument passed to the function. The function does not expect and does not allow any arguments.
Not available in Core.

ARGCOUNT()

This pseudo function returns the number of arguments defined for the current method or function.

_GETMPARAM() and _GETFPARAM()

These pseudo functions are only available in methods or functions with a CLIPPER calling convention.
You can use them to retrieve a function parameter by position. You must pass a numeric expression to these functions. If you pass a number that is larger than the actual number of parameters at runtime then you will get an array access exception.
Not available in Core.

String2Psz() and Cast2Psz()

These pseudo functions are used to convert DotNet strings to unmanaged Ansi PSZ strings. Not only is a PSZ created, but the functions also change the code generation and set up code to clear the allocated PSZ variable on exit of the function in which they are created.
Not available in Core.

ALTD()

This function will insert a call to System.Diagnostics.Debugger.Break inside a check to see if the debugger is attached (System.Diagnostics.Debugger.IsAttached)

_GetInst()

This function will return the module handle for the current module. Behind the scenes this is translated to System.Runtime.InteropServices.Marshal.GetHINSTANCE(TypeOf(FunctionsClass):Module)

PCALL() and CCALL()

The methods are used to call an API function for a strongly typed PTR.
The function expects a first parameter of type PTR and the other parameters must match the parameters defined in the function to which the typed PTR points
The compiler creates a delegate with the proper prototype and uses Marshal.GetDelegateForFunctionPointer() to call the function.

PCallNative<Type>() and CCallNative<Type>()

The methods are used to call an API function for an untyped PTR

The function expects a generic type parameter which indicates the return type and a first parameter of type PTR. Other parameters are allowed and must not point to managed memory.

The compiler creates a delegate with the proper prototype and uses Marshal.GetDelegateForFunctionPointer() to call the function.

_ARGS()

This pseudo function returns is replaced by the compiler to a reference to the generated array of parameters for functions/methods with clipper calling convention

SLen()

This function is translated by the compiler to a call of the Length property of the string, with a built-in check for NULL.

Chr(), _Chr()

When the numeric parameter of this function is a literal number between 0 and 127 then the compiler replaces the function call with a literal string with a character of that value. Larger values are not converted at compile time but at runtime because these numbers are codepage dependent.
So an expression like
"Hello world"+Chr(13)+Chr(10)
will be translated into a literal string containing "Hello world" followed by the CRLF characters (the compiler concatenates the strings at compile time).