Posted: 27th Aug 2011 8:50
When I attempt to declare a variable such as
+ Code Snippet
size as integer = 14-1

the value always comes out to be 0. Is it not possible to calculate a value when declaring a variable?
Posted: 27th Aug 2011 8:55
I don't know the answer to your question, but I would like to know why you need to declare a variable in this way?
Posted: 27th Aug 2011 17:15
It's not that I need to declare it as 14-1, but I need to insert variables into it so it will calculate the values at run time.
For example, this code works and gives me the correct result of 13.
+ Code Snippet
numberOfItems = 14
arraySize = numberOfItems-1



do


    PRINT (arraySize)
    SYNC()


loop


While this code gives me 0.
+ Code Snippet
numberOfItems = 14
arraySize as integer = numberOfItems-1



do


    PRINT (arraySize)
    SYNC()


loop


I'm trying to stick to a style of coding and that's not working out as much as I would like.
Posted: 27th Aug 2011 17:28
Try
+ Code Snippet
global arraysize as integer // optional

numberOfItems = 14
arraySize  = numberOfItems-1



do


    PRINT (arraySize)
    SYNC()


loop

Posted: 27th Aug 2011 17:30
I know that works. It's the whole
arraySize as integer = numberOfItems-1
that doesn't work.
Posted: 30th Aug 2011 2:57
This works.
+ Code Snippet
numberOfItems = 14
arraySize as integer
arraysize=numberOfItems-1
do
    PRINT (arraySize)
    SYNC()
loop

I think it is just trying to cheat, and use one line that is the problem
Posted: 30th Aug 2011 4:09
I don't think you can declare the variable and set a value at the same time, like you do in C, for example

Cheers