Computer Science Canada

hastch problem.

Author:  jasonhan416 [ Thu Dec 18, 2008 7:36 pm ]
Post subject:  hastch problem.

Turing:
%Set screen up
import GUI
setscreen ("nocursor")
setscreen ("noecho")
% Declaration Section
var number, choice : int
var window : int
var reply : string (1)
var finish : boolean := false
var mainWin := Window.Open ("position:300;300, graphics: 640;400")
%Title
procedure title
    cls
    locate (1, 33)
    put "Guessing Game 2"
end title

% Introduction
procedure introduction
    locate (1, 33)
    put "Guessing Game 2"
    locate (4, 15)
    put "See if you can guess a number between 10 to 30."
end introduction

%Pause Program
procedure pauseProgram
    put ""
    locate (8, 15)
    put "Press any key to continue.." ..
    getch (reply)
end pauseProgram

% Goodbye Screen
procedure goodBye
    title
    locate (4, 24)
    put "This program was Written by:"
    locate (6, 33)
    put "Jason Han"
    locate (7, 33)
    put "Thank you for playing!"
    pauseProgram
    finish := true
    delay (1000)
    Window.Close (window)
end goodBye

% User Input
procedure userInput
    title
    locate (5, 26)
    put "Please enter a number between 10 and 30: " ..
    put ""
    locate (5, 67)
    get number
    if number > 30 then
        title
        locate (6, 15)
        put "You didn't enter an number between 10 and 30! Pelase try again!"
        pauseProgram
        userInput
    elsif number < 10 then
        title
        locate (6, 15)
        put "You didn't enter an number between 10 and 30! Pelase try again!"
        pauseProgram
        userInput
    end if
end userInput

%Another window
procedure drawWindow2
    var winID2 := Window.Open ("position: 300;300, graphics:300;200")
    Window.Hide (mainWin)
    Window.Show (winID2)
    Window.SetActive (winID2)
    locate (5, 1)
    put "Sorry, please enter a number 1 or 2. Please try again!"
    loop
        exit when hasch
    end loop
    Window.Close (winID2)
end drawWindow2

% Main Menu
procedure mainMenu
    title
    locate (4, 26)
    put "(1) Play game"
    locate (6, 26)
    put "(2) Quit"
    locate (8, 26)
    put "Enter 1 or 2 to continue.. " ..
    get choice
    if choice = 1 then
        finish := false
    elsif choice = 2 then
        cls
        finish := true
        goodBye
    elsif choice not= 1 or choice not= 2 then
        title
        Window.Show (mainWin)
        Window.SetActive (mainWin)
        drawWindow2
        mainMenu
    end if
end mainMenu

% Processing and Output
procedure display
    if number > 15 then
        locate (7, 26)
        put "Too high. Please try again!"
        pauseProgram
    elsif number < 15 then
        locate (7, 26)
        put "Too low. Please try again!"
        pauseProgram
    elsif number = 15 then
        locate (7, 26)
        put "You got it!"
        pauseProgram
        finish := true
    end if
end display

% Main Program
introduction
pauseProgram
loop
    mainMenu
    userInput
    display
    exit when finish
end loop
goodBye
%End Program

basically the program suppose to make anotehr window for error message. right now i only did for the main menu error traps.
My question is.. is there a way to make another window without using hastch because that command makes the [] thing goes away.


Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="Turing"]Code Here[/syntax]


: