
-----------------------------------
jbiz
Sun Jan 20, 2008 10:54 pm

procedure inside a procedure?
-----------------------------------
when creating buttons, i can create a button fine, and can get this to go to a new page, but whenever i try to create a button on that new page, it says "procedure's may only be declared at the program, module, or monitor level" How do you get around this?

For example :
(this is when it screws up)

import GUI
var mainbutton, pepsibutton, starPic : int
procedure maincourses
    cls
    var font4 : int
    font4 := Font.New ("BinnerD:16")
    assert font4 > 0
    Font.Draw ("What would you like?", 240, 450, font4, blue)
    Font.Free (font4)

    procedure pepsi
        put "Pepsi"
    end pepsi

end maincourses

mainbutton := GUI.CreatePictureButton (50, 50, starPic, maincourses)

pepsibutton := GUI.CreatePictureButton (275, 150, starPic, pepsi)

-----------------------------------
Tony
Sun Jan 20, 2008 11:17 pm

Re: procedure inside a procedure?
-----------------------------------
How do you get around this?
You simply don't put procedures inside other procedures.

-----------------------------------
jbiz
Sun Jan 20, 2008 11:22 pm

Re: procedure inside a procedure?
-----------------------------------
is there another way to do what i'm trying to do then?
or should i just go to an if statement?

-----------------------------------
OneOffDriveByPoster
Sun Jan 20, 2008 11:41 pm

Re: procedure inside a procedure?
-----------------------------------
is there another way to do what i'm trying to do then?
or should i just go to an if statement?What is your point for having a procedure inside the other one?  Do you want the "inner" procedure to access the variables of the "outer" procedure?  Are you trying to create a scope or namespace?

-----------------------------------
jbiz
Sun Jan 20, 2008 11:58 pm

Re: procedure inside a procedure?
-----------------------------------
I'm trying to create buttons..
trying to have several main buttons 
and then once one of the main buttons is clicked, 
another menu with further button options is available to be chosen

-----------------------------------
Tony
Mon Jan 21, 2008 12:00 am

RE:procedure inside a procedure?
-----------------------------------
That doesn't actually require you to have procedures inside of other procedures. A button can point to any procedure within its scope.

-----------------------------------
jbiz
Mon Jan 21, 2008 12:01 am

Re: procedure inside a procedure?
-----------------------------------
sorry?
please explain..

-----------------------------------
Tony
Mon Jan 21, 2008 12:43 am

RE:procedure inside a procedure?
-----------------------------------

import GUI 

procedure maincourses 
   ...
end maincourses 

procedure pepsi 
   put "Pepsi" 
end pepsi

mainbutton := GUI.CreatePictureButton (50, 50, starPic, maincourses) 

pepsibutton := GUI.CreatePictureButton (275, 150, starPic, pepsi)


-----------------------------------
CodeMonkey2000
Mon Jan 21, 2008 12:04 pm

RE:procedure inside a procedure?
-----------------------------------
Are you learning procedures and GUI by yourself? Or did your teacher go through this with you?

-----------------------------------
jbiz
Mon Jan 21, 2008 7:19 pm

Re: procedure inside a procedure?
-----------------------------------
basically just by myself..

and tony, i think i get what you're saying, but won't that just display all of the buttons on a single page?

im trying to have : once a button is clicked, a new page with more buttons is available

-----------------------------------
Tony
Mon Jan 21, 2008 9:41 pm

RE:procedure inside a procedure?
-----------------------------------
you can create buttons inside procedures, but the procedure that the button links to can be elsewhere.

You can also enable/disable/hide buttons so that only the right content appears on each "page"
