Any is a built-in basic type and it behaves like an alias to another ATEasy variable or data element (for example, in a structure). That is, it holds not only 4 bytes of address of a symbol or an object, but also it keeps its data type (and more) information. The following list describes the usage of type Any:
You can set the value of an Any variable by using anyX=&X, anyX will be the alias for X.
You can set the value of alias by using anyX=value. In this case X will have the value (same as X=value) and anyX must have an alias before this statement is used.
Assigning Any variable anyX to another Any variable anyY will set anyX alias value to be the value of the anyY alias.
You can compare two variables of type Any, which are alias to 'compatible' data type. The aliased value will be compared.
Most operators (i.e. And, Or, +, etc) cannot be used with Any variables. You must assign their alias value to other typed variable and then use the operators
You can have an array of Any type. Each array element can be set to set to be an alias of a variable. For example: aAnyArray[2]=&adNum[4] will case the third element of the aAnyArray to be an alias to the fifth element of adNum array.
You can use SizeOf and TypeOf operators to determine the alias size and type. If Any is not assigned yet its size will be 4 and type is Any and it value will be Null. For example anyX=&dDouble, sizeof anyX will be 8 and type of anyX will be "Double".
You can get the true memory address of the Any alias by using &anyX. This can be used for MemoryCopy (since its source and target memory location are defined as DWord and not as Any).
You can check if an Any has an alias by checking anyX <> Null.
The only initial value which is allowed for an Any variable is Null. 0 and 0x0 are allowed as alternative ways of entering the initial value, but the initial value is always displayed as Null.
Any is used in DLL parameters so the user can pass different types of arguments.
During importing a DLL header file, C declaration VOID * will be converted to Var Any.
A Val Any parameter is used when the data value of the argument is to be passed to the DLL procedure. For an example dll procedure "sprintf" expects data values of all different types. You can use for variable numbers of each sprintf item to be of Val Any type. Please refer examples DLLs in "Language.prj" under ATEasy/Examples directory.
A Var Any parameter in a DLL procedure means that the address of the data value is to be passed to the ALL procedure. When an argument is passed to Var Any its memory address is pushed to the stack. For an example, DLL procedure "sscanf" expects an address of (a variable number of) each item. In this case, you must declare as Var Any type. Please refer example "DLLs" in "Language.prj" under ATEasy/Examples directory.
The following is an example of using the Any data type. Assume you have the following DLL procedure:
SendBinaryData (pData, lByteCount): Void
pData Var Any
lByteCount Val Long
If this DLL procedure is called as follows, the procedure will "send" the 8 bytes of the Double variable dValue:
SendBinaryData (dValue, sizeof dValue)
and the following call will "send" the 24 bytes contained in the 2 by 3 array of Float, afArray:
SendBinaryData (afArray, sizeof afArray)
The following examples illustrate Any variables usage :
any1=&a3i ! a3i is an array of Long of size 3
any2=&a3i[0] ! now any2 is pointing to the address of the first element
Suppose ai is an array of at least its size 3. The following assignments are all legal:
any1=ai
any2=7
but the following assignments are illegal (run-time errors):
any1=7 ! 7 is not array
any2=ai ! ai should be a long value
because the right hand sides' data types are not compatible with the left hand sides.
Basic Data Types, Data Conversion, Numeric, Strings, User Defined Date Types