procedure inside a procedure?
Author |
Message |
jbiz
|
Posted: Sun Jan 20, 2008 10:54 pm Post subject: 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) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sun Jan 20, 2008 11:17 pm Post subject: Re: procedure inside a procedure? |
|
|
jbiz @ Sun Jan 20, 2008 10:54 pm wrote: How do you get around this?
You simply don't put procedures inside other procedures. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
jbiz
|
Posted: Sun Jan 20, 2008 11:22 pm Post subject: 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? |
|
|
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Sun Jan 20, 2008 11:41 pm Post subject: Re: procedure inside a procedure? |
|
|
jbiz @ Sun Jan 20, 2008 11:22 pm wrote: 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? |
|
|
|
|
![](images/spacer.gif) |
jbiz
|
Posted: Sun Jan 20, 2008 11:58 pm Post subject: 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 |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Jan 21, 2008 12:00 am Post subject: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
jbiz
|
Posted: Mon Jan 21, 2008 12:01 am Post subject: Re: procedure inside a procedure? |
|
|
sorry?
please explain.. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Jan 21, 2008 12:43 am Post subject: RE:procedure inside a procedure? |
|
|
code: |
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)
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Mon Jan 21, 2008 12:04 pm Post subject: RE:procedure inside a procedure? |
|
|
Are you learning procedures and GUI by yourself? Or did your teacher go through this with you? |
|
|
|
|
![](images/spacer.gif) |
jbiz
|
Posted: Mon Jan 21, 2008 7:19 pm Post subject: 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 |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Jan 21, 2008 9:41 pm Post subject: 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" |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|
|