Random window opening
Author |
Message |
goroyoshi
|
Posted: Thu Jun 09, 2011 6:17 pm Post subject: Random window opening |
|
|
Turing: |
import GUI
%Declaration section
var lesson : int
var mainMenuButton : int
var mainMenuWin, introWin, userInputWin, displayWin : int := 0
var lessonButton : array 1 .. 10 of int
forward proc mainMenu
%Title
proc title
cls
locate (1, maxcol div 2 - 5)
put "Music Theory"
end title
proc redirection1
GUI.CloseWindow (introWin )
mainMenu
end redirection1
proc redirection2
Window.Close (displayWin )
mainMenu
end redirection2
proc redirection3
Window.Close (userInputWin )
mainMenu
end redirection3
%Display
proc display
Window.Hide (mainMenuWin )
displayWin := Window.Open ("position:center;center")
title
if GUI.GetEventWidgetID = lessonButton (1) then
put "you pressed 1"
elsif GUI.GetEventWidgetID = lessonButton (2) then
put "you pressed 2"
elsif GUI.GetEventWidgetID = lessonButton (3) then
put "you pressed 3"
elsif GUI.GetEventWidgetID = lessonButton (4) then
put "you pressed 4"
elsif GUI.GetEventWidgetID = lessonButton (5) then
put "you pressed 5"
elsif GUI.GetEventWidgetID = lessonButton (6) then
put "you pressed 6"
elsif GUI.GetEventWidgetID = lessonButton (7) then
put "you pressed 7"
elsif GUI.GetEventWidgetID = lessonButton (8) then
put "you pressed 8"
elsif GUI.GetEventWidgetID = lessonButton (9) then
put "you pressed 9"
else
put "you pressed 10"
end if
put "prepare to be bored beyond death"
mainMenuButton := GUI.CreateButton (400, 100, 0, "Main Menu", redirection2 )
end display
%User Input
proc userInput
Window.Hide (mainMenuWin )
userInputWin := Window.Open ("position:center;center")
title
put "Make your own quiz"
mainMenuButton := GUI.CreateButton (400, 100, 0, "Main Menu", redirection3 )
end userInput
%Main Menu
body proc mainMenu
var lessonName : array 1 .. 10 of string := init ("Music Notation", "Time Values", "Semitones, Whole Tones and Accidentals",
"Major Scales", "Intervals", "Minor Scales", "Simple Time", "Chords", "Finding the Key of a Melody", "Transposition at the Octave")
GUI.Hide (mainMenuButton )
mainMenuWin := Window.Open ("position:center;center")
title
for x : 1 .. 10
lessonButton (x ) := GUI.CreateButton (100, 350 - x * 25 + 25, 300, "Lesson " + intstr (x ) + ": " + lessonName (x ) + "", display )
end for
var quizButton : int := GUI.CreateButton (0, 0, 0, "QUIZ!!", userInput )
var quitButton : int := GUI.CreateButton (550, 0, 0, "Quit", GUI.Quit)
end mainMenu
%Introduction
proc intro
introWin := Window.Open ("position:center;center")
title
put "This program will test you on music theory."
mainMenuButton := GUI.CreateButton (400, 100, 0, "Continue", redirection1 )
end intro
%Good Bye
proc goodBye
var reply : string (1)
var goodByeWin : int := Window.Open ("position:center;center")
title
put "Bye."
put "Press any key to exit"
getch (reply )
Window.Close (mainMenuWin )
Window.Close (goodByeWin )
end goodBye
intro
loop
exit when GUI.ProcessEvent
end loop
goodBye
|
When i go to the main menu after the introduction, it keeps opening a side window? is this a glitch or is there a way to prevent this? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Raknarg
|
Posted: Thu Jun 09, 2011 8:33 pm Post subject: RE:Random window opening |
|
|
Oh, I think it's because it opens a regular window, then opens a new one... That's my guess, anyways. |
|
|
|
|
|
Raknarg
|
Posted: Thu Jun 09, 2011 8:36 pm Post subject: RE:Random window opening |
|
|
sorry, scratch that, it does it for all the procedures. |
|
|
|
|
|
goroyoshi
|
Posted: Thu Jun 09, 2011 8:47 pm Post subject: RE:Random window opening |
|
|
it shouldn't open the random window in the corner, if i replace Window.Close with Window.Hide, then my program deteriorates over time, it will eventually reach a screen that is in that same position, have what is supposed to be on it but when i press the main menu button everything is closed, turing says it's still running, then when i try to run anything else, turing crashes |
|
|
|
|
|
Tony
|
Posted: Thu Jun 09, 2011 8:58 pm Post subject: RE:Random window opening |
|
|
your redirection# procedures recursively open new "main menu" procedures.
so you have something like: mainMenu inside redirection inside userInput inside mainMenu inside redirection inside.... until you break the stack and crash. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|
|