SRL Archive - OSR Help

Gather proc/func name


P1ng

2012-08-19 23:15:04

I've got a generic termination script but I want it to write a line of what procedure/function it was in when it terminated.

procedure QuitScript(Active: Boolean);
begin
NextPlayer(Active);
WriteLn('Script stopped @' + ProcedureName);
if AllPlayersInactive then
TerminateScript;
end;

Now, obviously at present this won't work unless I store ProcedureName at the beginning of every proc/func, was just wondering if there might be an easier way to do this?

Nebula

2012-08-19 23:17:40

Make another procedure including QuickScript with a procedure name parameter and then put that as an "add on terminate". I think this would work but idk im high

P1ng

2012-08-19 23:22:10

I already have another procedure for addonterminate that frees all information etc. But I don't know how I'd gather the procedure name that it was last in short of adding
ProcedureName := ''; to the beginning of all of my procedures.

BraK

2012-08-20 00:04:28

Idea.

  • Make a global Var that is a String.
  • Make the first procedure in the script a simple writeln.
  • Var 
    Error : String;

    Procedure TermDebug;
    begin
    Writeln('Script terminated because of ' + Error + '.');
    end;
  • Then at the start of each function/procedure make a change to the Error string with the procedures name. such as:
  • Procedure Flyaway;
    begin
    Error := 'FlyAway';//Changing the error.
    StartRunning;
    FlapWings;
    TakeOff;
    End;
  • Finally add the TermDebug to your AddonTerminate;

This should work.

E: For those that care I might start making a Simba Forms Basics tut soon. It won't cover anything advanced though.

P1ng

2012-08-20 00:47:59

Yeah, that's what I am doing at present.
Thanks guys :) Was kind of hoping there might be another way to do it, no biggie.