Author Topic: Type cast an interger into a CHR  (Read 10215 times)

Jones

  • Newbie
  • Posts: 2
  • I love YaBB 1G - SP1!
    • View Profile
Type cast an interger into a CHR
« 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.

  
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: Type cast an interger into a CHR
« Reply #1 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.
« Last Edit: December 31, 1969, 04:00:00 PM by 1076562000 »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS