Author |
Message |
pkchris
|
Posted: Wed Dec 14, 2005 6:12 pm Post subject: Returning To Menu From Procedure |
|
|
I'm trying to return to my main menu from a procedure. Could someone please explain to me the best method? My main menu is just a few buttons in the mainline of my program which target the procedures I want to exit.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Paul
|
Posted: Wed Dec 14, 2005 6:52 pm Post subject: (No subject) |
|
|
Could you explain more about what your procedure does, how its coded etc? So we can help you better, a bit of code won't hurt either.
As for now it seems [url=http://www.compsci.ca/v2/viewtopic.php?t=370"]This tutorial[/url] could help you.
|
|
|
|
|
|
pkchris
|
Posted: Wed Dec 14, 2005 10:33 pm Post subject: (No subject) |
|
|
Here's my program so far... It's supposed to simulate a slot machine but it isn't done yet.
Description: |
|
Download |
Filename: |
Slot Machine Test.t |
Filesize: |
3.88 KB |
Downloaded: |
117 Time(s) |
|
|
|
|
|
|
pkchris
|
Posted: Thu Dec 15, 2005 11:34 am Post subject: (No subject) |
|
|
Oops I don't have any comments yet. Here is the basic code that I need help with though. You can still get all of my code from the above attachment.
code: |
import GUI
var winID := Window.Open ("graphics:140;100")
procedure Game %Runs my slots from three processes not included here.
setscreen ("graphics:650;400,nobuttonbar")
locate (20, 16)
put "Push '1' then '2' then '3' to stop the reels."
fork Slot1
fork Slot2
fork Slot3
end Game
var button1 : int := GUI.CreateButton (10, 70, 15, "Start Game", Game)%Game button
var button3 : int := GUI.CreateButton (10, 10, 15, "Quit", GUI.Quit)%Closes Window to Quit
loop
exit when GUI.ProcessEvent
end loop
Window.Close (winID)
|
This game button runs the procedure "Game." After "Game" is done I want to return to my main menu which is the buttons
|
|
|
|
|
|
Taur
|
Posted: Fri Dec 16, 2005 4:23 pm Post subject: (No subject) |
|
|
are slots 1, 2 and 3 processes?
|
|
|
|
|
|
pkchris
|
Posted: Fri Dec 16, 2005 8:20 pm Post subject: (No subject) |
|
|
Yes, so they all activate at the same time... Can you help me?
|
|
|
|
|
|
Taur
|
Posted: Fri Dec 16, 2005 8:59 pm Post subject: (No subject) |
|
|
well I think it might be about that whole processes in turing are bad thing, thier screwed up, I'm not sure how but it's recommended that you don't use them.
|
|
|
|
|
|
pavol
|
Posted: Fri Dec 16, 2005 9:06 pm Post subject: (No subject) |
|
|
try putting your code in a loop that way it will run the main menu again. thats the problem with procedures, they need to be declared before they can be called but what if they rely on each other. theres the problem. i had a problem like this myself once ... and then i gave up. try the loop thing, it might get you somewhere
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
pkchris
|
Posted: Sat Dec 17, 2005 12:11 am Post subject: (No subject) |
|
|
I have been able to do this properly using loops with a case statement main menu, but I'm using buttons and procedures right now. I can't put procedures in into a loop. Also processes are fine to use just like any other coding, except they can interfere with other parts of your programming. I haven't ran into any trouble yet...
|
|
|
|
|
|
pkchris
|
Posted: Mon Dec 19, 2005 6:15 pm Post subject: (No subject) |
|
|
If this is impossible, let me know!!
|
|
|
|
|
|
Albrecd
|
Posted: Mon Dec 19, 2005 6:25 pm Post subject: (No subject) |
|
|
You could put the Menue in a procedure instead of the mainline of the program and then call it in the mainline as well as the place that you are trying to make it work now.
|
|
|
|
|
|
pkchris
|
Posted: Mon Dec 19, 2005 8:52 pm Post subject: (No subject) |
|
|
That was the first thing I tried. I can't do that because my main menu uses buttons which target procedures. So if I did do that I would get the error that I need to define the procedures that my buttons use first. Or if I put my main menu after I create those procedures, it will say I have to declare my main menu first since my other procedures target it.
In simple terms I can't.
|
|
|
|
|
|
Albrecd
|
Posted: Mon Dec 19, 2005 9:03 pm Post subject: (No subject) |
|
|
You could put the whole program in a loop so that when it finishes, it loops back to the menue.
|
|
|
|
|
|
Martin
|
Posted: Mon Dec 19, 2005 9:35 pm Post subject: (No subject) |
|
|
code: |
var MENU : int := 1
var GAME : int := 2
... etc.
var mode : int := 1
loop
if (mode = MENU)
... do menu stuff
if (user clicks play button)
mode := GAME
end if
elsif (mode = GAME)
... do game stuff
elsif (mode = ...)
...
end if
end loop |
|
|
|
|
|
|
pkchris
|
Posted: Wed Dec 21, 2005 11:38 am Post subject: (No subject) |
|
|
My main menu has a quit button in it so it becomes stuck.
|
|
|
|
|
|
|