Computer Science Canada

Procedures - ordering.

Author:  pmads [ Mon Dec 15, 2008 5:13 pm ]
Post subject:  Procedures - ordering.

I apologize if this is confusing, i realize i may not have written my code the best way. In my code I have procedures which call on other procedures and i realize that in order for me to do that I need to order them in a way so they are declared before they are called. Just to give a brief idea of what my code is like, its like this
Turing:

procedure save
     ...
     main
end save

procedure addcustomer
      ...
      savebutton := GUI.CreatePictureButton (300, 100, savebutton, save)
end customer

procedure main
proc main
    Pic.Draw (background, 0, -175, picCopy)
    newcustbutton := GUI.CreatePictureButton (50, 200, newcust1, addcustomer)
    viewcustbutton := GUI.CreatePictureButton (343, 200, viewcust, viewcustomer)
    incexpbutton := GUI.CreatePictureButton (639, 200, incexp, incomeexpense)
end main
main



As you can see, the 'main' procedure needs the addcustomer procedure to be above it, the add customer needs the 'save' prcedure to be above it and the save needs the main to be above it. Right now the turing tells me that 'main' has not been declared under the save procedure. Is there any way of calling a procedure when it has not been declared above its calling? I am using GUI so i need to use procedures.

Author:  Tony [ Mon Dec 15, 2008 5:25 pm ]
Post subject:  RE:Procedures - ordering.

look up the documentation for the use of forward

Author:  pmads [ Mon Dec 15, 2008 5:39 pm ]
Post subject:  RE:Procedures - ordering.

Thats exactly what i wanted. Thanks Tony

Author:  Insectoid [ Mon Dec 15, 2008 8:19 pm ]
Post subject:  RE:Procedures - ordering.

procedure main
proc main

Why are you declaring this twice? (unless there is a difference and there is a legit reason)

Author:  pmads [ Tue Dec 16, 2008 1:03 pm ]
Post subject:  RE:Procedures - ordering.

No that was just a typo.


: