Error: Undefined Variable using calculation block

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
earthground
Posts: 9
Joined: Sat Sep 08, 2007 8:09 pm

Error: Undefined Variable using calculation block

Post by earthground »

I was building a project earlier using FlowcodeV3, my lab partner and I developed a program that accepts a number as input to Port B from switches. Then the program must divide the number by 3 to find out if the remainder is equal to zero or not. If the remainder=0 the program should display the original input number as output to Port A on the LED's. If the remainder!=0 the program should display all LED's HIGH(lit up).

Here is my concern:

I am using two variables in my program. The first variable is

Code: Select all

inputNumber
which is used for the value entered by the switches on Port B. The second variable is

Code: Select all

remainder
which is used to store the value of the remainder found by dividing

Code: Select all

inputNumber MOD 3
.

In my calculation block I entered:

Code: Select all

remainder = inputNumber MOD 3 
, then pressed ok to get an error saying that one of the variables is undefined.

In the Input block I established the above variables and used

Code: Select all

inputNumber
.

My partner did everything the same way and his program worked flawlessly. But on my machine I could not get past the calculation block due to this variable problem. Are there any likely causes of this problem?

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Are you sure you spelled the variable names correctly (they are not case sensitive)?

And are you sure the variables have been defined ok? And that they are not string variables?

You can enter variables into calculations using the "variables..." button in the calculation window and then clicking the "use variable" button. Doing this will ensure that the variables exist and that they are spelt correctly.

If you are still having problems, please send your program to us and we'll have a look.

earthground
Posts: 9
Joined: Sat Sep 08, 2007 8:09 pm

Post by earthground »

I tried defining both variables in my first input block and pressed to use the

Code: Select all

inputNumber
(for the input). Setting it up this way, my calculation block gave me the error stating that I had an undefined variable. So, then I tried the only other way I could think of which was to define the variable

Code: Select all

remainder
by itself in the calculation block's variables menu, and having the

Code: Select all

inputNmuber
variable set up and used by the input block. Both ways gave me the same error message saying that I had the undefined variable.

My calculation block consists of

Code: Select all

remainder=inputNumberMOD3
. I have class again tomorrow and I am going to try again using a different machine to see if maybe there is something wrong with the computer I was working on.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

Make sure you have spaces around the "MOD" operator.

i.e., instead of

Code: Select all

remainder=inputNumberMOD3 
use

Code: Select all

remainder = inputNumber MOD 3

earthground
Posts: 9
Joined: Sat Sep 08, 2007 8:09 pm

Post by earthground »

Hey I went to the lab today and got the program working. For some reason the calculation block was saying that I had an undefined variable, yet when I proceeded ahaed to putting the rest of the program together and went back to re=enter the calculation block, it accepted it. I'm not sure why but I'm glad that I was able to get the program to work finally.

earthground
Posts: 9
Joined: Sat Sep 08, 2007 8:09 pm

MOD Space

Post by earthground »

Thanks for that tip. It works great.

Post Reply