wat is boolean?
Author |
Message |
meidan
|
Posted: Wed Jun 14, 2006 10:43 pm Post subject: wat is boolean? |
|
|
when something doesnt work and boolean says on the buttom, what does that mean? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
MysticVegeta
|
Posted: Wed Jun 14, 2006 11:00 pm Post subject: (No subject) |
|
|
Check the Turing Walkthrough for a complete explanation.
var bool : boolean
Simple declaration of a boolean.
they hold true or false values, for eg:
put 1=1. So thats true
put 1=2. Thats false
Could be interpreted as some other way:
bool := 1=1
put bool (outputs true)
bool := 1=2
put bool (outputs false) |
|
|
|
|
|
Ninja
|
Posted: Wed Jun 14, 2006 11:16 pm Post subject: (No subject) |
|
|
Ya if you get an error at the bottom saying Warning something something and then it says it needs to be a boolean but run anyway, its usually when u assign your boolean variable with a : . For a boolean you have to assign like var x := 5 for example, but when ure actually assigning someting as a boolean you do var : <varname> := boolean. When you do a program where you read a text file and a user types stuff in and you have to write the code to find the item, thats where you use var found : boolean := false |
|
|
|
|
|
[Gandalf]
|
Posted: Wed Jun 14, 2006 11:22 pm Post subject: (No subject) |
|
|
Why don't you give us an example of code which causes this to happen? Without that, it's hard to tell exactly what about 'boolean' you need help with. A general explanation is always good, but it will probably not be enough for you to understand your specific problem.
Is the error message saying "if must be boolean type"? Or "boolean expression expected"? In that case, you will need to replace whatever you currently have with an expression that will return a boolean value. |
|
|
|
|
|
Ninja
|
Posted: Thu Jun 15, 2006 9:01 am Post subject: (No subject) |
|
|
here is the code i was talking about.
code: |
var numbers : array 1 .. 10 of string
var found : boolean := false
var item : string
var filenumber : int
var x : int := 0
open : filenumber, "M:\\drawer.txt", get
assert filenumber > 0
loop
get : filenumber, skip
exit when eof (filenumber)
x := x + 1
get : filenumber, numbers (x)
end loop
close : filenumber
found := false
loop
found := false
put "What are you looking for? " ..
get item : *
for i : 1 .. 10
if numbers (i) = item then
found := true
exit
end if
end for
if found = true then
put item, " is in the drawer"
else
put item, " is not in the drawer"
end if
end loop |
|
|
|
|
|
|
Clayton
|
Posted: Thu Jun 15, 2006 9:20 am Post subject: (No subject) |
|
|
what is skip? you dont seem to have declared it, which may be what is causing your problem, also, i see that you are making your program a bit more dynamic by not using a hardcoded for loop, y not go all the way and use flexible arrays , if you are unfamiliar with them, or asking urself wth im talking about, go throught the Turing Walkthrough and check out the tut written on flexy arrays |
|
|
|
|
|
Ninja
|
Posted: Thu Jun 15, 2006 4:20 pm Post subject: (No subject) |
|
|
skip is a built in command in turing |
|
|
|
|
|
MysticVegeta
|
Posted: Thu Jun 15, 2006 7:04 pm Post subject: (No subject) |
|
|
More precisely, skip is a turing keyword.
@SuperFreak: He was just demonstrating an example for booleans not on how to use arrays, I dont think it is hard coded at all, but it is "wrong" in a sense since he doesnt know there will be 10 things in the text file and with 11 files, it will cause an error of arrays. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Ninja
|
Posted: Thu Jun 15, 2006 7:47 pm Post subject: (No subject) |
|
|
I know what u mean bro, the problem was that when our teacher gave us that question, and actually all the array based questions, he specifically gave us the length of the array, thats why its hardcoded . He said that we have to make that text file and we HAVE to code it to read 10 items. |
|
|
|
|
|
Clayton
|
Posted: Thu Jun 15, 2006 9:12 pm Post subject: (No subject) |
|
|
well i learned something new today i didnt know skip was a command, and i dont know what it does but whatever, research for later
@Ninja: not to be mean or whatever, but why not surprise your teacher and show him what you have taught yourself and help other kids in your class? even if you have to make a version 2 to hand in (the one with the hardcoded values) just do one to show how much more dynamic that the proggie could have been |
|
|
|
|
|
Ninja
|
Posted: Thu Jun 15, 2006 10:17 pm Post subject: (No subject) |
|
|
It's cool bro, i did that lol but he was like, nah im just gonna mark the other one.He is lazy like that lol. Thats why he takes 2 months to mark 3 chapters lol |
|
|
|
|
|
[Gandalf]
|
Posted: Sat Jun 17, 2006 10:46 pm Post subject: (No subject) |
|
|
skip just puts a newline wherever you put it. For example, the following are all equivalent:
|
|
|
|
|
|
|
|