Miscellaneous Datatypes
From TeamDeveloperWiki
This page covers miscellaneous tips & tricks on datatypes
Contents |
How to get dynamically the type of a variable
At runtime, the function SalCompileAndEvaluate can be used to determine the type of a variable.
Set nType = SalCompileAndEvaluate( sExpression, nError, nErrorPos, nReturn, sReturn, dtReturn, hWndReturn, FALSE, sContext ) If nType = EVAL_Number ! Variable is a Number Else If nType = EVAL_String ! Variable is a String Else if ntype = EVAL_Date ! Variable is a DateTime Else If nType = EVAL_Handle ! Variable is a Handle (window, Sql, File) ELse If nType = EVAL_Template ! sExpression is a template, class Else If nType = 7 ! Variable is an object (UDV). This nType seems to be undocumented
Example
Set nType = SalCompileAndEvaluate( "strTest", nError, nErrorPos, nReturn, sReturn, dtReturn, hWndReturn, FALSE, sContext ) Set nType = SalCompileAndEvaluate( "udvCustomer", nError, nErrorPos, nReturn, sReturn, dtReturn, hWndReturn, FALSE, sContext )
The sContext parameter should be the context handle where the variable resides in.
So if the variable is declared in the current context (where the SalCompileAndEvaluate is called) use
sContext = SalContextCurrent( )

