
-----------------------------------
chelsee
Sat Dec 09, 2006 8:52 pm

Boolean
-----------------------------------
Im trying to figure out how to use boolean and it isn't working :(  Could someone help me or give me an example code? thanks[color=green][/color]

-----------------------------------
Clayton
Sat Dec 09, 2006 8:55 pm


-----------------------------------
Hello, and welcome to CompSci.ca!

Your question is answered [url=http://www.compsci.ca/v2/viewtopic.php?t=9634]here in the Turing Walkthrough. If you still don't find what you are looking for, keep looking through tutorials in the Turing Walkthrough, or post back here with example code of your problem, as well as a description of the problem.

-----------------------------------
Prince Pwn
Mon Dec 11, 2006 12:18 am


-----------------------------------

var lighton : boolean

lighton := true
if lighton = true then
   put "The light is on."
else
   put "The light is not on."
end if

lighton := false
if lighton = true then
   put "The light is on."
else
   put "The light is not on."
end if 


-----------------------------------
Prince Pwn
Mon Dec 11, 2006 12:23 am


-----------------------------------
Also, I recommend adding break to trace your code so you can see what your program is exactly doing in slow motion.

-----------------------------------
Tony
Mon Dec 11, 2006 9:29 am


-----------------------------------
actually it works like

var lighton : boolean := true

if lighton then
   put "The light is on."
else
   put "The light is not on."
end if 


and I think the following works as well

put "is 2 more than 1? : ", 2 > 1


-----------------------------------
Hackmaster
Mon Dec 11, 2006 8:51 pm


-----------------------------------


and I think the following works as well
Code:

put "is 2 more than 1? : ", 2 > 1 



how would this work, tony? would you put a variable after this to set it to trur? or would this just put true on the screen? or... I don't know... I cuold just be missing the obvious... but... could you explain?
[/quote]

-----------------------------------
Clayton
Mon Dec 11, 2006 8:55 pm


-----------------------------------
because 2 > 1 is a boolean statement (it is either true or false right?) it counts a a boolean. So in this case, true would be output onto the screen.

-----------------------------------
Tony
Mon Dec 11, 2006 9:24 pm


-----------------------------------
Freakman is right. Any boolean operator (1)



maybe? I don't know. maybe someone could explain this concept's uses, because I really can't see how this would help in most programs.

-----------------------------------
Tony
Tue Dec 12, 2006 9:49 am


-----------------------------------
what use is it to ouput a boolean variable to the screen?
What use is it to output any variable to the screen?

-----------------------------------
Clayton
Tue Dec 12, 2006 10:20 am


-----------------------------------
@Hackmaster: can you assign any variable as you did? No, not that way. Instead, you just assign a boolean variable like any other variable.

-----------------------------------
Hackmaster
Tue Dec 12, 2006 2:41 pm


-----------------------------------
Alright, thanks... I just can't really see where it would help in a program, outputting true or false for the user to see.

-----------------------------------
Clayton
Tue Dec 12, 2006 3:56 pm


-----------------------------------
maybe not necessarily for the user to see, but for debugging purposes it is very useful.
