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

Username:   Password: 
 RegisterRegister   
 procedure inside a procedure?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jbiz




PostPosted: 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)
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jbiz




PostPosted: 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?
OneOffDriveByPoster




PostPosted: 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?
jbiz




PostPosted: 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
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jbiz




PostPosted: Mon Jan 21, 2008 12:01 am   Post subject: Re: procedure inside a procedure?

sorry?
please explain..
Tony




PostPosted: 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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: 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?
jbiz




PostPosted: 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
Tony




PostPosted: 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"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 11 Posts ]
Jump to:   


Style:  
Search: