Computer Science Canada


Author:  Thuged_Out_G [ Thu Dec 11, 2003 4:36 pm ]
Post subject:  procedures

is it possible to add your own procedures to turing, so they are always declared and can be used in program by calling them?

for example, Draw.Line procedure is already made, you just have to call it....can i do this with one of the procedures i have made?

Author:  AsianSensation [ Thu Dec 11, 2003 4:48 pm ]
Post subject: 

sure, compile a list of whatever stuff you need, and then just include the file in the beginning of your program, acts like a header file.

If im not mistaken, then there are some useful functions already made that you can include here at compsci.

btw, to include, type it


Author:  DanShadow [ Thu Dec 11, 2003 5:10 pm ]
Post subject:  ..

I know what im about to do is kind of like helping him cheat...but it isnt really much to cheat here it is. This code will be able to call upon a "draw_line" procedure as many times as needed, so its looped to prove that point. I hope this helps

var x, y, x2, y2 : int := 0

%Makes a procedure that clears the screen, and draws a line
procedure draw_line
    Draw.FillBox (0, 0, maxx, maxy, 0)
    Draw.Line (x, y, x2, y2, 255)
end draw_line

    %Asks user for (x,y) values of the line
    locate (1, 1)
    put "Enter the first x and y co-ordinates seperated by a space: "
    get x
    get y
    put "Enter the second x and y co-ordinates seperated by a space: "
    get x2
    get y2

    %Runs the draw_line procedure, and draws the line

end loop

Author:  Thuged_Out_G [ Thu Dec 11, 2003 10:53 pm ]
Post subject: 

ok dan, i know how to make procedures and call them
what i was asking was:
i was wonering if it is possible tomake a procedure, and save it somewhere so i can call it in any program withhout declaring the draw procedures already available in turing, you just have to call it possible to make my own procedures, and add them to turing somehow?

Author:  AsianSensation [ Thu Dec 11, 2003 11:16 pm ]
Post subject: 

yes, use


write a bunch of procedures, save it as some file, and then at the beginning of your new program, do this

include "header.t"

that's the easiest way.

Other ways would be including changing Turing's system files and whatnot, and I think that's called software piracy Wink

Author:  DanShadow [ Fri Dec 12, 2003 4:16 pm ]
Post subject: 

Ohhh...he wants to include procedures from file...make more specific questions, heh. Well yeah, use "include" to include procedures from disk.