Internet PLC Forum

General => Technical support => Topic started by: Jones on March 09, 2003, 09:24:14 AM

Title: Type cast an interger into a CHR
Post by: Jones on March 09, 2003, 09:24:14 AM
I would like to access the 32 bit interger variables in a for loop. Therefore i have to typecast a number into a char. I have tryed to use the function CHR$ in order to access the 32bits variables named A-Z but the compiler will not me do. I can typecast a interger into a char in a setlcd string construction but I can not access the 32 bit variable in this way. Is this a limmitation in the compiler or is is possible do something like this in another way.

  
Title: Re: Type cast an interger into a CHR
Post by: support on March 10, 2003, 07:19:19 AM
The A to Z integers cannot be referenced by Index. It is not supported by the compiler. If you wish to use 32-bit integer array, try the EMLINT[1] to EMLINT[16]. These are 32-bit integer array that you can freely use in your applications.

Unlike C or C++ language, there is no "type casting" support in the TBASIC language. You can still convert between Strings and Integer using the HEX$, STR$, VAL, HEXVAL functions. When a 16-bit number is assigned to a 32-bit variable the contents are converted (and sign-extended) automatically without the need for casting. Likely when you assign a 32-bit number to a 16-bit variable, only the lower 16-bits of the 32-bit number are assigned to the 16-bit variable and the upper 16-bitsare dropped automatically, again no type casting is necessary.