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

Username:   Password: 
 RegisterRegister   
 Procedures won't take me back to main menu
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
syntax0r




PostPosted: Thu May 05, 2005 9:23 pm   Post subject: Procedures won't take me back to main menu

Im building a big project for my Compsci class, and I have started making an idea of how my main menu will function.

code:


import GUI in "%oot/support/lib/GUI"

View.Set ("graphics:vga")

var choice, age : int

proc changeAge
    age := 0
end changeAge

procedure doNewGame
    cls
    put "Put actual Game here..."
    changeAge
    put "hit 1 " ..
    get choice
    case choice of
        label 1 :
            put "hello, I am ", age, " years old."
        label :
            put "not yet define"
    end case

end doNewGame

procedure doOptions
    cls
    put "Put option menu here"
end doOptions


procedure doAbout
    var window := Window.Open ("graphics:200;200,position:truemiddle")
    put "Put Menu about"

    put "hit 0 to exit"
    var a : string (1)
    get a
    if a = "1" then
    Window.Close  (window)
else
 .......%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% For instance, I would like to have a link taking me back to my created buttons. I tried many ways, and I can't get back to my orignial.
    end if


end doAbout




var newGame : int := GUI.CreateButton (maxx div 2, 250, 0, "New Game", doNewGame)
var options : int := GUI.CreateButton (maxx div 2, 200, 0, "Options", doOptions)
var about : int := GUI.CreateButton (maxx div 2, 150, 0, "About", doAbout)

loop
    exit when GUI.ProcessEvent
end loop



I commented where my problem is.

Basically, it goes like this.

I create some GUI buttons to make a menu. Clicking on the button will result in a procedure being executed.

For example, I click on "Options" and on the options submenu, I have button linking me back to my main menu.

When I try to do something like this, I always end up with a process name not being declared. I tried making the "create GUI buttons" in to a procedure, so then when I click "return to main menu" on any submenu screen. However, that created an conflict.

I know Im doing something wrong, as I've seen more complex programs in Turing have a main menu and sub menus that all work as a family.

Im new to Turing's proc, fnc other non-linear ways of creating Turing programs. So I dont have a mindset on this non-linear programming.

Any comments/tips/suggestions would greatly be appreciated!
Sponsor
Sponsor
Sponsor
sponsor
syntax0r




PostPosted: Fri May 06, 2005 8:13 pm   Post subject: (No subject)

Ok, maybe I was rather vague. Here's a more defined thing I want to accomplish.

code:

import GUI

View.Set ("graphics:750;510,nobuttonbar")
GUI.SetBackgroundColor (79)
var lineFrame : int
var ch : string (1) %% Getch
var fontMainMenu : int := Font.New ("Palatino:24:Bold,Italic")

lineFrame := GUI.CreateFrame (maxx div 2 - 200, 100, 555, 400, 2)
Font.Draw ("Main Menu", maxx div 2 - 90, maxy div 2 + 90, fontMainMenu, black)





proc doSomething
    cls
    put "Hit 0 to return"
    getch (ch)
    if ch = "0" then
        %%% I'd like to return to main menu, where all the buttons are, but I can't
        put "I'd like to return to main menu, where all the buttons are, but I can't"
    end if
end doSomething


%Buttons
var buttonNewGame : int := GUI.CreateButton (maxx div 2 - 65, maxy div 2 + 30, 0, "New Game", doSomething)
var buttonSave : int := GUI.CreateButton (maxx div 2 - 50, maxy div 2, 0, "Save", doSomething)
var buttonLoad : int := GUI.CreateButton (maxx div 2 - 50, maxy div 2 - 30, 0, "Load", doSomething)
var buttonInstructions : int := GUI.CreateButton (maxx div 2 - 67, maxy div 2 - 60, 0, "Instructions", doSomething)
var buttonAbout : int := GUI.CreateButton (maxx div 2 - 53, maxy div 2 - 90, 0, "About", doSomething)
var buttonQuit : int := GUI.CreateButton (maxx div 2 - 51, maxy div 2 - 120, 0, "Quit", GUI.Quit)


%CODE%


loop
    exit when GUI.ProcessEvent
end loop


Run it, see what I mean. I hope there's a way to get out of this ugly mess!
Tony




PostPosted: Sat May 07, 2005 1:31 pm   Post subject: (No subject)

well you cls the screen. Why would you clear the screen? Clearly you have to draw it back.

I donno, try something like
Turing:

loop
    exit when GUI.ProcessEvent
    View.Update
end loop

or be creative
syntax0r




PostPosted: Sat May 07, 2005 8:01 pm   Post subject: (No subject)

I clear the screen so I can put new content. It's like opening a new page. I think it has to do with the buttons (my problem). I have to declare a proc within a button, which makes things so hard.
Tony




PostPosted: Sat May 07, 2005 8:59 pm   Post subject: (No subject)

that's right. Now when you go back to the menu, you have to once again clear the screen and draw the content
syntax0r




PostPosted: Sat May 07, 2005 10:46 pm   Post subject: (No subject)

Oh really? Hehehe, Didn't think of that! How foolish of me.

Thanks! What sucks is that my code will get quite excessive.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: