Internet PLC Forum

General => Technical support => Topic started by: Lorne Van Dusen on February 22, 2017, 01:58:34 PM

Title: Variables
Post by: Lorne Van Dusen on February 22, 2017, 01:58:34 PM
While I was viewing all the resent posts I figured I should ask the one question that has been confusing me when it comes to the variables in the TRi PLC
You have A to Z, you have A# to Z# and you have A$ to Z$
I am confused about A to Z
If I understand correctly  A# to Z# are for storing floating point numbers
and A$ to Z$ are mainly for storing ASCII strings

Do they take up the same memory locations?
Can you use A to Z as well as A# to Z# and A$ to Z$ within the same program or would there be a conflict ?

Lorne
Title: Re:Variables
Post by: support on February 22, 2017, 10:21:04 PM
A to Z, A# to Z# and A$ to Z$ are different variables and they occupy different memory space inside the PLC. Yes they can appear in the same program and within the same custom function without any conflict.

Note that TBASIC does not automatically convert string type to numeric type (integer and floating points are both numeric). But there are functions that allow you to convert from one variable type to another variable type. E.g. STR$(n), HEX$(n), VAL(n) HEXVAL(n).  A# to Z# can be assigned to A to Z with some loss of precision.

E.g.   A = Z#*1.2345/A#   ' the floating point computation result is converted to integer and assigned to A.
Title: Re:Variables
Post by: Lorne Van Dusen on February 23, 2017, 06:50:08 AM
Thanks I now understand.
I actually thought that A$ & A# were in the same memory area and that the $ or the # just told the program what format to use.