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

Username:   Password: 
 RegisterRegister   
 Subprograms
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jedi-bob




PostPosted: Thu Jan 22, 2004 10:38 am   Post subject: Subprograms

how do they work? Can i make an animation a subprogram, so that i don't need the 300+ animation lines in my main program?

PS- i checked the tutorials and there is nothing of that nature in there. Also i need help urgently am not currently in compsci class.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Jan 22, 2004 10:56 am   Post subject: (No subject)

eh, sure... you could do that.
code:

procedure animate
put "animating...
end animate

...
%this is your main program
%you can always call your procedure whenever you need it

animate
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jedi-bob




PostPosted: Thu Jan 22, 2004 10:58 am   Post subject: (No subject)

when i call my animation can it be a seperate file??

ex: procedure animation.t
Tony




PostPosted: Thu Jan 22, 2004 11:02 am   Post subject: (No subject)

eh... no... what you do in your separate file is have it like
code:

%this is file animation.t

procedure animation
put "animate"
end animation


now in your main file you place
code:

include animation.t


at the very top of the program so that the procedure will be included.

Edit: go easy on my spelling, pff
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jedi-bob




PostPosted: Thu Jan 22, 2004 11:17 am   Post subject: (No subject)

thanks very much
jedi-bob




PostPosted: Thu Jan 22, 2004 2:59 pm   Post subject: (No subject)

I keep getting an error in my main program saying:
illegal include statement
santabruzer




PostPosted: Thu Jan 22, 2004 3:02 pm   Post subject: (No subject)

watch tony's spelling..
*cough* include animation.t *cough*...
jedi-bob




PostPosted: Thu Jan 22, 2004 3:15 pm   Post subject: (No subject)

i checked the spelling, but i get the same error. Would you like to see the code?
sport




PostPosted: Thu Jan 22, 2004 3:18 pm   Post subject: (No subject)

Sure, post the code
jedi-bob




PostPosted: Thu Jan 22, 2004 3:37 pm   Post subject: (No subject)

its pretty long, and i don't know how to get it in the neat box like other people do so i just attached it.


level-test.t
 Description:

Download
 Filename:  level-test.t
 Filesize:  1.88 KB
 Downloaded:  176 Time(s)


animation.t
 Description:

Download
 Filename:  animation.t
 Filesize:  8.97 KB
 Downloaded:  167 Time(s)

santabruzer




PostPosted: Thu Jan 22, 2004 3:41 pm   Post subject: (No subject)

err.. you forgot the " " ".. the quotes basically.. it should be
code:
include "animation.t"
jedi-bob




PostPosted: Thu Jan 22, 2004 3:45 pm   Post subject: (No subject)

i put them in but when i try run it, the code of animation.t opens and procedure is highlighted and it says, "procedures may only be declared at the program, module, or monitor level"
vinkster




PostPosted: Thu Jan 22, 2004 6:17 pm   Post subject: (No subject)

procedures cannot be called from a different file, you can either call it in the animation.t or not use that file and copy and paste that code to the top of your other file..........
santabruzer




PostPosted: Thu Jan 22, 2004 6:21 pm   Post subject: (No subject)

why don't you make a module on your other file, and export the procedure
shorthair




PostPosted: Thu Jan 22, 2004 6:28 pm   Post subject: (No subject)

WOW the lamer has somethig good to say , now isnt that a change , i thin kan apologie to compsci is in order , and mabye Dan might me nice enough to take your lamer away , well mabye you will have to keep up the good behaviour
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 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: