Computer Science Canada

Useful Functions and procedures...

Author:  Homer_simpson [ Thu May 08, 2003 8:28 pm ]
Post subject:  Useful Functions and procedures...

Ok all the programming masters submit your useful procedures and functions here.....

Author:  Homer_simpson [ Thu May 08, 2003 8:38 pm ]
Post subject: 

Homer's first function submittion:

Ever wanted to have one command delayed in a loop and not stop other commands from running here's the function u need

code:
function timedelay (var r : int, t : int) : boolean
    var tt : int
    clock (tt)
    if r = 0 then
    clock(r)
    result false
    end if
    if tt - r >= t then
        r := tt
        result true
    else
        result false
    end if
end timedelay


and here's an example of it in use
code:
View.Set ("offscreenonly")
var time1, i, r : int := 0


loop
    if timedelay (time1, 1000) then
        i += 1
        % the rest of program is going on while the commands in this loop only work once every second
    end if

    r += 10
    drawfillarc (320, 200, 150, 150, r, r + 10, 9)
    locate (1, 1)
    put i, " seconds"
    View.Update
    cls
end loop

Author:  Catalyst [ Thu May 08, 2003 9:28 pm ]
Post subject: 

i hav a library i compiled of useful fucntion/procs a while ago so i wouldnt have to hunt for them (note: not all are made by me)

Ive got this posted in submissions since there is no attachments in source Sad

MOD EDIT: I attached the file, and I'm see if I can let users attach files over here - Tony

Author:  Homer_simpson [ Thu May 08, 2003 9:36 pm ]
Post subject: 

wow cool functions but why didn't u send them here as an attachment?

Author:  Catalyst [ Thu May 08, 2003 9:38 pm ]
Post subject: 

doesnt let you put attachments in source/tutorials

Author:  Homer_simpson [ Thu May 08, 2003 10:16 pm ]
Post subject: 

Doh!!! i am so very stupid... =(
Thx tony...


: