Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what
Author |
Message |
Sceyef
|
Posted: Fri Dec 12, 2014 11:09 am Post subject: Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what |
|
|
What is it you are trying to achieve?
Fix an error with windows
What is the problem you are having?
Error message: Window with ID of 1 is closed.
Describe what you have tried to solve this problem
idk
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
%This program makes you guess a random number from 50 and 100
import GUI
%Declaration (Global variables)
var guess, counter, number, choice : int
choice := 0
%Pause Program until you hit a key
proc pauseProgram
/*var reply : string (1)
put ""
put "Press any key to continue..." ..
getch (reply)*/
var continue := GUI.CreateButton (0, 0, 0, "Continue", GUI.Quit)
GUI.ResetQuit
loop
exit when GUI.ProcessEvent
end loop
GUI.Hide (continue )
end pauseProgram
%Program Title
proc title
cls
locate (1, 33)
put "Guessing Game"
put ""
end title
%Generate a random integer from 50 to 100
proc randInt
randint (number, 50, 100)
end randInt
proc choice1
choice := 1
GUI.Quit
end choice1
proc choice2
choice := 2
GUI.Quit
end choice2
%Introduction
proc intro
title
put "Try to guess a number from 50 to 100!"
pauseProgram
counter := 0
end intro
procedure errorWindow (option : int)
if (option = 1) then
var winID1 := Window.Open ("position:900;300, graphics:250;100")
Window.Show (winID1 )
Window.SetActive (winID1 )
put "Please enter either 1 or 2."
put "Press any key to continue: " ..
loop
exit when hasch
end loop
Window.Close (winID1 )
elsif (option = 2) then
var winID2 := Window.Open ("position:900;300, graphics:400;100")
Window.Show (winID2 )
Window.SetActive (winID2 )
put "Please enter a number between 50 and 100."
pauseProgram
loop
exit when GUI.ProcessEvent
end loop
Window.Close (winID2 )
end if
end errorWindow
%menu
proc mainMenu
title
if counter = 0 or guess = number then
randInt
put "Main Menu"
var start : int := GUI.CreateButton (0, 350, 0, "Start Game", choice1 )
var exitgame : int := GUI.CreateButton (0, 300, 0, "Exit", choice2 )
GUI.ResetQuit
loop
exit when GUI.ProcessEvent
end loop
GUI.Hide(exitgame )
GUI.Hide(start )
elsif counter >= 3 then
counter := 0
mainMenu
end if
end mainMenu
%User Input
proc userInput
title
put ""
put "Enter a number from 50 to 100:" ..
get guess
if guess < 50 and counter not= 3 or guess > 100 or guess < 0 then
errorWindow (2)
userInput
end if
counter + = 1
end userInput
%Processing and Output
proc display
put ""
if guess = number then
%when you win with a correct answer
put "Congratulations, your answer, ", guess, ", is correct."
elsif counter = 3 and guess not= number then
%When you run out of tries and didnt win
put "You're out of tries. You lose. The answer was ", number, "."
elsif number > guess and guess >= 50 then
%incorrect guess, but you still have tries left
put "Higher!"
elsif number < guess and guess <= 100 then
put "Lower!"
end if
pauseProgram
end display
%End Message
proc goodBye
put ""
put "By Kayton Yan"
pauseProgram
Window.Hide (defWinID )
end goodBye
%Main
intro
loop
mainMenu
if choice = 1 then
userInput
end if
exit when choice = 2
display
end loop
goodBye
%end of program
|
Please specify what version of Turing you are using
The latest one. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Zren
|
Posted: Sat Dec 13, 2014 12:06 am Post subject: RE:Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what |
|
|
Which line is causing the error? |
|
|
|
|
|
Sceyef
|
Posted: Sun Dec 14, 2014 12:33 pm Post subject: RE:Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what |
|
|
When the error appears, it opens up WidgetModule.tu
So It gives the error message in THAT thing.
I screwed up something with GUI i think
heres a screenshot of error
http://prntscr.com/5gs12p
HELPFAST |
|
|
|
|
|
Dreadnought
|
Posted: Sun Dec 14, 2014 2:55 pm Post subject: Re: Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what |
|
|
The GUI module keeps track of all the windows in which there are widgets. If you close one of these windows without telling the GUI module it will still try to check for events from these widgets (even if there aren't any widgets in that window). To signal to the GUI module that a window is being closed use Gui.CloseWindow instead of Window.Close. |
|
|
|
|
|
Sceyef
|
Posted: Fri Dec 19, 2014 7:14 pm Post subject: RE:Omg buttons and windows pls help window 1 closed error but window 1 cannot be closed? what |
|
|
...Oh.
wow
im bad at this
damn |
|
|
|
|
|
|
|