Computer Science Canada

Array of proc help

Author:  Shamikh [ Mon Jun 02, 2008 5:05 pm ]
Post subject:  Array of proc help

I need to create an array of procs.

var lol : array 0..5 of proc
lol(1):= ole

put lol(1)




procedure ole
put "ole"
end ole


but it wont work. it says 1 needs to be an identifier any help?

Author:  richcash [ Mon Jun 02, 2008 5:14 pm ]
Post subject:  RE:Array of proc help

You have to declare the procedure before you assign it to your array.

Author:  Shamikh [ Mon Jun 02, 2008 5:16 pm ]
Post subject:  RE:Array of proc help

How do i do that?

Author:  richcash [ Mon Jun 02, 2008 5:23 pm ]
Post subject:  Re: Array of proc help

By putting your procedure before the line(s) where you initialize your array. (You can declare the body of your procedure later if you use the forward and body keywords.) For example :
Turing:
var lol : array 0 .. 5 of proc p
procedure ole
    put "ole"
end ole
lol (1) := ole


And upon further inspection of your code :
You need to put an identifier for your array of procedures as I did above.
Turing:
var lol : array 0 .. 5 of proc p


And also you can't put a procedure. You call a procedure. If you want a subprogram that returns a result you have to use a function.


: