Computer Science Canada

Subprograms

Author:  jedi-bob [ 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.

Author:  Tony [ Thu Jan 22, 2004 10:56 am ]
Post 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

Author:  jedi-bob [ Thu Jan 22, 2004 10:58 am ]
Post subject: 

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

ex: procedure animation.t

Author:  Tony [ Thu Jan 22, 2004 11:02 am ]
Post 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

Author:  jedi-bob [ Thu Jan 22, 2004 11:17 am ]
Post subject: 

thanks very much

Author:  jedi-bob [ Thu Jan 22, 2004 2:59 pm ]
Post subject: 

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

Author:  santabruzer [ Thu Jan 22, 2004 3:02 pm ]
Post subject: 

watch tony's spelling..
*cough* include animation.t *cough*...

Author:  jedi-bob [ Thu Jan 22, 2004 3:15 pm ]
Post subject: 

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

Author:  sport [ Thu Jan 22, 2004 3:18 pm ]
Post subject: 

Sure, post the code

Author:  jedi-bob [ Thu Jan 22, 2004 3:37 pm ]
Post 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.

Author:  santabruzer [ Thu Jan 22, 2004 3:41 pm ]
Post subject: 

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

Author:  jedi-bob [ Thu Jan 22, 2004 3:45 pm ]
Post 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"

Author:  vinkster [ Thu Jan 22, 2004 6:17 pm ]
Post 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..........

Author:  santabruzer [ Thu Jan 22, 2004 6:21 pm ]
Post subject: 

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

Author:  shorthair [ Thu Jan 22, 2004 6:28 pm ]
Post 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

Author:  Cervantes [ Thu Jan 22, 2004 6:35 pm ]
Post subject: 

interesting rank Razz

i haven't ever had to use include or anything but I'll make a suggestion:
make sure your two turing files are in the same directory.

Cheers

Author:  vinkster [ Thu Jan 22, 2004 10:04 pm ]
Post subject: 

yeah got to love getting banned and then un-banned.....lol.............and on the first post too......

......yeah if you want a seperate file a module is the best thing to use.........

Author:  vinkster [ Thu Jan 22, 2004 10:12 pm ]
Post subject: 

sorry for the double post but im just a lamer i dont know better........ Rolling Eyes

this might help ya out
modules
[code]module BOX
export largebox
procedure largebox
drawfillbox (10, 10, 60, 60, 7)
end largebox
end BOX
BOX.largebox
[/code]

Author:  Boarder16 [ Thu Jan 22, 2004 10:21 pm ]
Post subject: 

i'd make a suggestion but i know nothign of this you talk about lol....i need 100 posts...!!!!! 8)


: