Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 If statement, needs a boolean type
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HaVoC




PostPosted: Wed Nov 12, 2003 4:08 pm   Post subject: If statement, needs a boolean type

I'm trying to make a simple calculator. Just with 2 numbers and 4 operations. +,-,*,/

My if statement is this

if
op:= +
ans:= num1+num2
end if

Except it says my if statement needs type boolean? What do I do?
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Wed Nov 12, 2003 5:18 pm   Post subject: (No subject)

HaVoC wrote:

Except it says my if statement needs type boolean? What do I do?

it says it needs type boolean because if statements use boolean (true or false) comparisons and execute a specified section of code if it is true and another section of code (if specified) if it's false.

:= is for assigning values to variables
= is for comparing variables

thus, your if statement should read:
code:

if op = "+" then
    ans := num1+num2
end if

thats assuming your code has a string variable called op that you use to get input from the user ("+", "-", "*", "/")
Chimaera




PostPosted: Wed Nov 12, 2003 7:37 pm   Post subject: (No subject)

Quote:
thus, your if statement should read:
Code:

if op = "+"
ans := num1+num2
end if


You mean
code:

If op = "+" then
ans:=num1+num2
end if


Wink
Mazer




PostPosted: Wed Nov 12, 2003 8:13 pm   Post subject: (No subject)

lol, what are you talking about, chimaera? you shouldn't go around quoting people and then changing the text in the quote. Wink
Chimaera




PostPosted: Wed Nov 12, 2003 8:17 pm   Post subject: (No subject)

What?! Me change words around?!

I may be old, blind, a communist, stupid and change words around while you're not looking but I'm not a porn star! XD


I spy with my little eye
Quote:
Last edited by Mazer on Wed Nov 12, 2003 8:11 pm; edited 1 time in total
Mazer




PostPosted: Wed Nov 12, 2003 9:13 pm   Post subject: (No subject)

man... there needs to be a "shifty eyes" emoticon or something... i mean... i um.. well you see i... Shoting

Chimaera wrote:

I may be old, blind, a communist, stupid and change words around while you're not looking but I'm not a porn star! XD


liar! i saw the pictures! i saw the movies! i saw the used condoms! (P.S. ewww)
compudave




PostPosted: Wed Nov 12, 2003 11:05 pm   Post subject: (No subject)

Mazer wrote:
liar! i saw the pictures! i saw the movies! i saw the used condoms! (P.S. ewww)


Laughing lmao, funny but dude that's gross... Laughing
HaVoC




PostPosted: Thu Nov 13, 2003 11:07 am   Post subject: (No subject)

Ok, well, I fixed it before I looked at this post. My tech teacher helped me out. Anyways, thanks, it helped in the long run. Though I had to set the ans variable to 'real' before I could do division. Can anyone tell me how to go about making an interface?
Sponsor
Sponsor
Sponsor
sponsor
Chimaera




PostPosted: Thu Nov 13, 2003 9:06 pm   Post subject: (No subject)

what sort of interface are you looking for? GUI? Text? Or do you want there to be boxes that you click on and text boxes for you to type in?
HaVoC




PostPosted: Thu Nov 13, 2003 9:38 pm   Post subject: (No subject)

Well, a GUI would be nice, but before I do that, what is the code to implement a BMP?

Do you know a place, with a list of ALL commands, and their descriptions?
AsianSensation




PostPosted: Thu Nov 13, 2003 9:46 pm   Post subject: (No subject)

it's called the turing help files, lol Laughing

F10 button
Tony




PostPosted: Thu Nov 13, 2003 9:47 pm   Post subject: (No subject)

there's a tutorial on importing pictures into turing in TUTORIALS section. As for all commands... help file (F10 in turing) is helpful at times.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
HaVoC




PostPosted: Fri Nov 14, 2003 9:32 pm   Post subject: (No subject)

All that did was enable tracing
Dan




PostPosted: Mon Nov 17, 2003 4:42 pm   Post subject: (No subject)

HaVoC wrote:
All that did was enable tracing


I dont what verson of turing you have but in all the ones i have used have F10 bring up the help file if they have it and the F9 birngs up the help file for the slected worad.

if you have one of the erail versons of turing 4.x you may have to get the upgrade from the holth group web site to get the help files
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
HaVoC




PostPosted: Tue Nov 18, 2003 8:46 pm   Post subject: (No subject)

What's the Holth Group URL?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: