Computer Science Canada

Calling procedures

Author:  Ktomislav [ Fri Sep 12, 2008 4:50 pm ]
Post subject:  Calling procedures

To be clear, here is the code. And please tell me why isn't it working.
code:

procedure p1
    p2
end p1
procedure p2
    put "Hello"
end p2

p1

Author:  Tony [ Fri Sep 12, 2008 5:18 pm ]
Post subject:  RE:Calling procedures

because when p1 calls p2, p2 has not been decleared yet, so it doesn't know about it (procedural programming and all that).

You can rearrange the order of procedures, but sometimes you might get loops. There's a forward keyword and function prototyping that solves that problem.

Author:  Ktomislav [ Fri Sep 12, 2008 5:25 pm ]
Post subject:  Re: Calling procedures

Thanks a lot! I just couldn't find out how to do that.


: