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

Username:   Password: 
 RegisterRegister   
 Calling procedures
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
Ktomislav




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




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




PostPosted: 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.
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: