Click or drag to resize

EnforceNumeric Function

X#
Make sure a variable is a numeric.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION EnforceNumeric(
	u REF USUAL
) AS VOID
Request Example View Source

Parameters

u
Type: Usual
The variable to check.
If u is NIL, a value of 0 is assigned to it. If u is not passed by reference and is not a numeric, the error system aborts the program. If u is passed by reference but is not a numeric, the error system is called up and a value of 0 is assigned to u.

Return Value

Type: 
Remarks
Examples
This example uses EnforceNumeric() to ensure that an argument is a numeric, initialized to 0:
X#
1FUNCTION Start()
2    LOCAL nOne
3    LOCAL nTwo
4    LOCAL cName
5    CheckNumbers()
6FUNCTION CheckNumbers(nOne, nTwo)
7    EnforceNumeric(@nOne)    // Assigns 0 since NIL
8    Default(@nTwo, 100)        // Assigns 100 since NIL
See Also