I'm a Failure at Case Statements
Author |
Message |
Fail@ICS
|
Posted: Mon May 24, 2010 11:57 am Post subject: I'm a Failure at Case Statements |
|
|
Hey guys:D
So I'm a failure at turing and everything so I was hoping for a bit of help.
I'm supposed to create a slideshow of some sort using turing right. And so I have done a menu page/table of contents page, whatever you wanna call it. I've put an A (then -name of topic), B (then name of topic),C (then name of topic) and so on. So for instance if my slideshow was on sports, A-could be hockey, B-could be basketball, C- rugby and yeah, you get the point:)
Now I want it so that whichever alphabet the user types from A,B,C,D etc, the information within is displayed. I think I need like case statements or if statements for it. I have no idea what to do though. So for instance if the user clicks A, the information for hockey is displayed. I have pictures too and I don't know if case statements display the pictures and stuff. I think it only displays text. Please help someone:( |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Mon May 24, 2010 12:19 pm Post subject: RE:I\'m a Failure at Case Statements |
|
|
You should have a procedure that displays stuff, and have the case statement call the procedure.
code: |
proc drawStuff
Pic.Draw ("pic.bmp", x, y, picMerge)
end drawStuff
case input
label "A" : drawStuff
end case
|
My syntax is off but you get the idea. |
|
|
|
|
![](images/spacer.gif) |
Fail@ICS
|
Posted: Mon May 24, 2010 12:42 pm Post subject: Re: I'm a Failure at Case Statements |
|
|
Dude you're awesome. Thanks a lot for the effort:) But for some reason I still don't get it:( |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon May 24, 2010 12:45 pm Post subject: RE:I\'m a Failure at Case Statements |
|
|
Sure, no problem. What part do you still have trouble with? Can you get an example, such as the one Insectoid is talking about, to work and understand what is going on? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Tue May 25, 2010 7:14 am Post subject: Re: I'm a Failure at Case Statements |
|
|
Ok, if you want to do loads of stuff in one option of a case statement, you'll need to create a procedure to contain all that stuff within one of those options.
Say that you choose hockey (represented by A in the case statement).
Turing: |
proc hockeyProcedure
/*display all the stuff here*/
end proc
case input
label "A" : hockeyProcedure
end case
|
You can have pictures or anything you want inside that procedure that you call when using the case. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Tue May 25, 2010 5:36 pm Post subject: RE:I\'m a Failure at Case Statements |
|
|
I can't help but wonder if you even read any posts other than the first...You damn near copied my code snippet exactly. |
|
|
|
|
![](images/spacer.gif) |
supaphreek
|
Posted: Wed Jun 02, 2010 8:29 am Post subject: RE:I\'m a Failure at Case Statements |
|
|
Well, im not the best at turing but what you could do is draw an A using the drawfont command, then use
Mouse.Where (x,y,button)
if x > (the the left coordinate of the A) and x < (the right coordinate of A) and y > the bottom coordinate of a) and y < (the top coordinate of A) and button = 1 then
put "Hockey...."
end if
As for the when theyre typing it. You could just use getchar
sooo itd be like this
var a : char
a := getchar
if a = "a" or a = "A" then
put "hockey"
end if
BTW, you have to loop BOTH of these |
|
|
|
|
![](images/spacer.gif) |
|
|