Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

how to dim a dimension constant for a program for CR1000


beech Apr 22, 2010 08:06 AM

Hi,

I am actually trying to write a program for the logger CR1000 for reading several light sensors. each light sensor has it is own multiplier. So I need to include (if that is possible)a dimension constant (like multi(x)). I wrote a piece of script, and would be gratefull if some one is able to see whether that is right or need to be modified.


Dim cal(15)
const cal(1)= 53.9
const cal(2)= 53.8
const cal(3)= 54.6
const cal(4)= 53.2
const cal(5)= 53.6
const cal(6)= 56.6
const cal(7)= 53.9
const cal(8)= 57.6
const cal(9)= 54.6
const cal(10)= 53.6
const cal(11)= 53.5
const cal(12)= 53.6
const cal(13)= 57.6
const cal(14)= 53.1
const cal(15)= 53.6


so the question is whether this constant can be called within the program using: cal(2) , for example.
Thanks in advance

* Last updated by: beech on 4/22/2010 @ 6:24 PM *


Dana Apr 22, 2010 06:39 PM

In CRBasic, a Variable is one type of program element and a Constant is another. The code you have written above will not compile.

You can initialize a variable (assign it a value), similar to what you have done above, but removing the Const declaration (e.g., cal(1) = 53.9)

In newer operating systems, you can also initialize the entire array on one line, e.g.,

Dim Cal(15) = {53.9, 53.8, 54.6, 53.2....etc}

Regards,

Dana

Log in or register to post/reply in the forum.