
-----------------------------------
Sceyef
Fri Dec 12, 2014 11:09 am

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)

%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 