
-----------------------------------
Hoshi
Mon Dec 19, 2011 4:57 pm

Syntax Error Help!
-----------------------------------
the for count  command  is not working. Turing says that the variable is not declared. Doesn't the count  command not need to be declared  :?:

-----------------------------------
Insectoid
Mon Dec 19, 2011 5:09 pm

RE:Syntax Error Help!
-----------------------------------
"for count" isn't a command.

"for i : 1..10" is though.

-----------------------------------
Tony
Mon Dec 19, 2011 5:10 pm

RE:Syntax Error Help!
-----------------------------------
refer to examples in turing documentation -- [tdoc]for[/tdoc]

-----------------------------------
Hoshi
Mon Dec 19, 2011 5:28 pm

RE:Syntax Error Help!
-----------------------------------
what is wrong with this 

var depth :int
var sum :int
get depth



for num: 1 .. depth
sum:= depth-3+2/num
exit when sum=num
put sum-num
end for

-----------------------------------
Tony
Mon Dec 19, 2011 5:35 pm

RE:Syntax Error Help!
-----------------------------------
I don't know. What does the compiler say?

-----------------------------------
Hoshi
Mon Dec 19, 2011 8:22 pm

RE:Syntax Error Help!
-----------------------------------
for num it says assigned value is  the wrong type.

-----------------------------------
Insectoid
Mon Dec 19, 2011 8:39 pm

RE:Syntax Error Help!
-----------------------------------
Integers don't like being divided. They love div though.

-----------------------------------
tg851
Wed Dec 21, 2011 11:57 am

RE:Syntax Error Help!
-----------------------------------
div will divide integers.floor,ceil,and round will divide 2 numbers to produce an integer of the result depending on the command

-----------------------------------
chipanpriest
Wed Dec 21, 2011 12:24 pm

RE:Syntax Error Help!
-----------------------------------
its because you are trying to divide an integer, which you cannot do unless you round it. an integer is a whole number, thus if you are dividing 3 by 2, you will get a decimal, which is not an integer

-----------------------------------
Aange10
Wed Dec 21, 2011 12:29 pm

RE:Syntax Error Help!
-----------------------------------
Which just means that you can't divide 3/2 and store it as an integer. 1.5 is not an integer. However, you may store that into a real.

Here is an example of Ceil,Dividing,Div, and floor.



% Diving
put 5 / 2 % = Outputs 2.5 REAL
put 10 / 2 % = Outputs 2 REAL
put 21 / 2 % = Outputs 10.5 REAL
% Div { Divides without computing Remainders }
put 5 div 2 % Outputs 2 INT
put 10 div 2 % Outputs 5 INT
put 21 div 2 % outputs 10 INT
% Round
put round (5 / 2) % Outputs 3 INT
put round (10 / 2) % Outputs 5 INT
put round (21 / 2) % Outputs 11 INT
% Ceil {Rounds UP Always}
put ceil (5 / 2) % Outputs 3 INT
put ceil (10 / 2) % Outputs 5 INT
put ceil (21 / 2) % Outputs 11 INT
% Floor {Rounds Down Always}
put floor (5 / 2) % Outputs 2 INT
put floor (10 / 2) % Outputs 5 INT
put floor (21 / 2) % Outputs 10 INT


-----------------------------------
chipanpriest
Wed Dec 21, 2011 12:35 pm

RE:Syntax Error Help!
-----------------------------------
Yea what he said and actually i didnt know about the ceil and floor commands either so thanks for that :p
