SRL Archive - Help and Support

Out of Proc Range


Smartzkid

2009-03-05 17:53:56

Hey guys, I'm getting an Out of Proc Range error in a script trying to call a procedure that's assigned during runtime. I don't recall how to resolve this error, any insight?

bullzeye95

2009-03-05 17:56:26

Can you give any code? I can't seem to make an "out of proc range" error.

Smartzkid

2009-03-05 18:14:33

Eugh. I found the error, but I don't think SCAR can do what I want it to…


program Example;
var
theProc: procedure;

procedure ProcToCall;
begin
writeln('Success!');
end;

procedure SetProc(proc: procedure);
begin
theProc := proc;
end;

procedure CallProc;
begin
theProc();
end;

begin
SetProc(@ProcToCall);
CallProc;
end.

EDIT: Ehh, whatever. I got around it using ThreadSafeCall… not quite what I wanted, but it does the job perfectly.

bullzeye95

2009-03-05 18:26:34

program Example;
var
theProc: procedure;

procedure ProcToCall;
begin
writeln('Success!');
end;

procedure SetProc(proc: procedure);
begin
theProc := variant(proc);
end;

procedure CallProc;
begin
theProc();
end;

begin
SetProc(@ProcToCall);
CallProc;
end.
That what you need?

Smartzkid

2009-03-05 18:29:30

Dayumm… What exactly does that do? Nice, thanks!

bullzeye95

2009-03-05 18:33:13

I just figured out that you can typecast it as a "___pointer" instead of a variant. So I guess typecasting it as a variant re-typecasted it as a ___pointer.

Smartzkid

2009-03-05 18:46:16

Well, I probably wont end up using that, I just realized I need a way to pass parameters as well, but thanks anyways, I'm sure the knowledge will eventually come in handy. Repped.