Computer Science Canada I need help to make windows appear when the user creates an error |
| Author: | Angafroness [ Mon May 30, 2011 6:47 pm ] |
| Post subject: | I need help to make windows appear when the user creates an error |
%Declaration Section var mainWindow := Window.Open ("position:300;300, graphics:400;400") %This global variable is the user input to the guessing game. var guess : int %This global variable is the answer to the guessing game it is a random number. var answer : int %This global variable is the ammount of tries can be utiized. var tries : int := 0 %This global variable is for the main menu, it is the choice on the menu screen var choice : string (1) %Program title proc title cls locate (1, 33) put "Guessing game" put "" end title %Random number proc randNum randint (answer, 25, 75) end randNum %Pause program %This will pause the program when run. proc pauseProgram %This variable is to create the pause in pauseProgram var reply : string (1) put "Press any key to continue..." .. getch (reply) end pauseProgram %Program Introduction proc introduction title locate (3, 1) put "See if you can guess a number between 25 and 75 in three tries!" randNum pauseProgram end introduction %Procedure main menu proc mainMenu %(changeWindow) title locate (3, 20) put "Enter one of the three options below." put "To start a New game press 1 " put "" put "To continue a game press 2 " put "" put "To exit press 3 " put "" put "Enter your choice here: " .. get choice end mainMenu proc drawWindow2 var windowID2 := Window.Open ("position:200;200, graphics:200;100") Window.Hide (mainWindow) Window.Show (windowID2) Window.SetActive (windowID2) put "You pressed an invalid key. Press any key to continue..." .. loop exit when hasch end loop Window.Show (mainWindow) Window.SetActive (mainWindow) Window.Close (windowID2) end drawWindow2 proc drawWindow1 mainMenu if choice not= "1" and choice not= "2" and choice not= "3" then mainMenu else if choice = "1" or (choice = "2" and tries = 3) then randNum tries := 0 end if end if end drawWindow1 %This procedure will display the main menu %UserInput proc userInput title locate (5, 1) put "Enter a number between 25 and 75: " .. get guess %If the guess is less than 25 and greater then 75 an error message will display. if guess < 25 or guess > 75 then put "" put "Error number out of range! Enter a number between 25 and 75!" pauseProgram userInput end if end userInput %Output and processing proc display title %This will seperate the result displays if guess < answer then put "You guessed: ", guess put "" put "Way down there?" put "" elsif guess > answer then put "You guessed: ", guess put "" put "Come down" put "" else put "Good job! You guessed the number!" end if tries := tries + 1 %Only 3 tries. pauseProgram end display %This is the final screen. proc goodBye %POSSIBLE CREATE ANOTHER WINDOW IF NECESSASY TO 'CLOSE' THE GOODBYE title if choice = "3" then put "Thank you for playing this game." elsif guess = answer then put "Congradulations you guessed right!" else put "You didnt guess the magical number try again!" put "The number was: ", answer end if locate (20, 40) put "Creator: Angelo" end goodBye %Main program introduction %This loop is done to exit the program after three tries and display a goodbye message. loop mainMenu exit when choice = "3" userInput display end loop goodBye %End program |
|
| Author: | apython1992 [ Mon May 30, 2011 6:51 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
While this topic is a little bit more descriptive, don't make separate topics that involve the same problem/issue. So what is working for you, and what isn't? What have you tried? Where are you having your problem? (We won't just blindly debug your code for you) |
|
| Author: | goroyoshi [ Mon May 30, 2011 6:53 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
just delete this ... this is not the right code, im helping him right now |
|
| Author: | Angafroness [ Mon May 30, 2011 6:57 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
i think i should just scratch the code and retry because it might be easier to restart |
|
| Author: | apython1992 [ Mon May 30, 2011 7:02 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
Maybe that's not entirely necessary, but if you choose to do that then I suggest reading up on functions and procedures. Basically, you've defined this drawWindow1 procedure but it is never actually called. Defining a function/procedure doesn't effectively put it to use. |
|
| Author: | goroyoshi [ Mon May 30, 2011 7:06 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
apython, he didn't use the windows properly (theres supposed to be a window for almost every procedure) |
|
| Author: | apython1992 [ Mon May 30, 2011 7:41 pm ] |
| Post subject: | RE:I need help to make windows appear when the user creates an error |
I'm making it clear as to why the windows don't appear. |
|