Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 program proplem!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nin




PostPosted: Tue Jan 09, 2007 9:45 pm   Post subject: program proplem!

my program is suppose to let the user guess between the numbers 10 and 65 and when the user puts in a number that is less than or above the numbers 10 and 65 it will show an error message (error messages do not count as tries). When i ran my program it paused when it was only my first try Neutral. After it paused i closed the window and it started to say : An error was found in "WidgetModule.tu".
my code is below:
__________________________________________________________________________

code:
%Set screen up
import GUI

%Declaration Section
var mainWin := Window.Open ("graphic: 640;200")
var key : string (1)
var number, randomNum : int
var try : int := 3
var mainMenuBtn, playBtn, quitBtn : int := 0

%Title
proc title
    locate (1, 34)
    put "Guessing Game"
end title

%Introduction
proc introduction
    GUI.Refresh
    title
    locate (3, 1)
    put "This program will allow you to guess a number between 10 and 65."
    GUI.Show (mainMenuBtn)
    GUI.Hide (playBtn)
    GUI.Hide (quitBtn)
end introduction

%Main Menu
proc mainMenu
    cls
    GUI.Hide (mainMenuBtn)
    GUI.Show (playBtn)
    GUI.Show (quitBtn)
    title
    locate (3, 1)
    put "Select a button to proceed to the destination you desire."
    GUI.Refresh
end mainMenu

%Random Number
proc randNum
    randint (randomNum, 10, 65)
end randNum

%User input's error message
proc errorMessage
    var windID1 := Window.Open ("position:300;300,graphics: 330;100")
    locate (1, 1)
    put "Please enter a number between 10 and 65."
    locate (5, 1)
    put "To proceed, please press any key" ..
    loop
        exit when hasch
    end loop
    Window.Close (windID1)
end errorMessage

%User Input
proc userInput
    cls
    introduction
    GUI.Hide (mainMenuBtn)
    randNum
    try := 3
    loop
        locate (7, 1)
        put ""
        put ""
        put ""
        locate (7, 1)
        put "Enter a number between 10 and 65: " ..
        get number
        if number < 10 or number > 65 then
            errorMessage
            userInput
        end if
        try := try - 1
        locate (8, 1)
        put "Tries remaining ", try
        if try = 0 then
            cls
            locate (12, 28)
            put "Sorry but you used all your tries"
            delay (3000)
            cls
            GUI.Show (mainMenuBtn)
            exit
        end if
        locate (9, 1)
        if number = randomNum then
            put "Good Job!"
            delay (1000)
        elsif number < randomNum then
            put "Your guess is too low!"
            delay (1000)
        else
            put "Your guess is too high!"
            exit
        end if
    end loop
end userInput

%Good Bye
proc goodBye
    var windID2 := Window.Open ("graphics:640;400")
    Window.Close (mainWin)
    locate (12, 25)
    put "This program was brought to you by:"
    locate (13, 35)
    put "******** *******"
    locate (14, 39)
    put "Goodbye!"
    delay (2500)
    Window.Close (windID2)
end goodBye

%Buttons
mainMenuBtn := GUI.CreateButtonFull (260, 160, 0, "Main Menu", mainMenu, 0, '^M', false)
playBtn := GUI.CreateButtonFull (282, 220, 0, "Play Game", userInput, 0, '^P', false)
quitBtn := GUI.CreateButton (300, 130, 0, "Exit", GUI.Quit)

%Main Program
introduction
loop
    exit when GUI.ProcessEvent
end loop
goodBye

%End of program
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Tue Jan 09, 2007 9:54 pm   Post subject: Re: program proplem!

Funny it works fine for me...
nin




PostPosted: Tue Jan 09, 2007 9:56 pm   Post subject: Re: program proplem!

but wen i tried it at skool and at home it did the same thing =/
Clayton




PostPosted: Tue Jan 09, 2007 9:59 pm   Post subject: Re: program proplem!

what was the exact error you got in the WidgetModule? also, it might be helpful if you tell us what version of Turing you are using.
neufelni




PostPosted: Tue Jan 09, 2007 10:15 pm   Post subject: RE:program proplem!

It works on for me about half the time. Sometimes it works fine but sometimes after I guess wrong, the program just stops doing anything rather than clearing the screen and letting me guess again.
nin




PostPosted: Wed Jan 10, 2007 8:46 am   Post subject: Re: program proplem!

im using turing 4.0.5
and on the widget thing the error that was highlighted was "delay (3)" and the error that was said at the buttom was "Program interrupted"
nin




PostPosted: Wed Jan 10, 2007 8:49 am   Post subject: Re: RE:program proplem!

Nick @ Tue Jan 09, 2007 10:15 pm wrote:
It works on for me about half the time. Sometimes it works fine but sometimes after I guess wrong, the program just stops doing anything rather than clearing the screen and letting me guess again.


yeah i agree wit him..
ericfourfour




PostPosted: Wed Jan 10, 2007 5:04 pm   Post subject: Re: program proplem!

You get that error because you closed the run window. The most likely place for your program to stop is at a delay because that is where it spends most of its time.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: