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

Username:   Password: 
 RegisterRegister   
 Need Help with Shopping Program (GUI Interface)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bradb




PostPosted: Fri Dec 31, 2010 9:22 pm   Post subject: Need Help with Shopping Program (GUI Interface)

Hi

Am having trouble getting this program to work, I am in grade 9 and it is my first attempt to use turing


What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>



grants fender guitar shop.t
 Description:

Download
 Filename:  grants fender guitar shop.t
 Filesize:  2.14 KB
 Downloaded:  115 Time(s)


grants fender guitar shop.t
 Description:
my attempt at a shopping program

Download
 Filename:  grants fender guitar shop.t
 Filesize:  2.14 KB
 Downloaded:  111 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Dec 31, 2010 9:43 pm   Post subject: RE:Need Help with Shopping Program (GUI Interface)

This is a pretty good start for first time using Turing.

It looks like the program just gets stuck in this loop
Turing:

%starts mouse locator loop
loop
    mousewhere (xmouse, ymouse, button)
    if button = 1 and 200 <= xmouse and xmouse <= 260 and 300 <= ymouse and ymouse <= 320 then
        cls

        drawfillbox (0, 0, maxx, maxy, red)
        %draws clickable box on to the screen

        locatexy (1, 350)
        put "this is the price of our stratacaster guitars, click on it to buy it"
        drawbox (200, 300, 260, 320, black)
        locatexy (210, 310)
        put "stratocaster - $1300"
    end if
end loop

There is no exit, it will just loop forever, checking for a button press, even though you have already drawn the next screen/page. Buttons and pages are known to be difficult to setup correctly. You have the right ideas, just have to be careful about figuring out just exactly in which loop the code is running.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bradb




PostPosted: Fri Dec 31, 2010 10:31 pm   Post subject: Re: Need Help with Shopping Program (GUI Interface)

thanks for the help, I really appreciate it

I'm not sure where to put the exit, I tried and exit right after the end if, but no luck

What does an exit statement look like?

thnks


Grant
Tony




PostPosted: Fri Dec 31, 2010 10:39 pm   Post subject: RE:Need Help with Shopping Program (GUI Interface)

Turing's documentation -- exit

Keep in mind that when a loop exits, the code flow jumps to the "end loop" point and continues from there, _but_ the old page will still be drawn on the screen until the code gets to the drawing part.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bradb




PostPosted: Fri Dec 31, 2010 11:24 pm   Post subject: Re: Need Help with Shopping Program (GUI Interface)

Sorry I still can't figure out what the exit statement needs to look like. My parents are trying to help me with this and they can't either. Do you have any more suggestions Question
Tony




PostPosted: Fri Dec 31, 2010 11:32 pm   Post subject: RE:Need Help with Shopping Program (GUI Interface)

It will probably look something like
Turing:

if button = 1 and ... % same way you do all other buttons
    exit
end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bradb




PostPosted: Sat Jan 01, 2011 12:08 am   Post subject: Re: Need Help with Shopping Program (GUI Interface)

Thank you. You have been a big help.
Happy New Year!
TokenHerbz




PostPosted: Sat Jan 01, 2011 2:32 am   Post subject: RE:Need Help with Shopping Program (GUI Interface)

could also go like
code:

exit when var = this
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: