possible "Get Calling Function Name/ idx"?
#1

is it possible to get the name/idx of the function
that calls into another function?


example
pawn Код:
forward func1();
public func1()
{
    otherFunc();
}

forward func2();
public func2()
{
    otherFunc();
}

otherFunc()
{
    //some code to get func1's or func2's name or idx
    printf("Called from function Name %s",funcName);
}
im sure it wont look like that but that was my poor excuse for the example.
I also assume these will have to be public functions.

even if i can get the funcidx like this then i could use a list of function names to check against.
Reply
#2

Maybe something like this:

pawn Код:
forward func1();
public func1()
{
    otherFunc(1);
}

forward func2();
public func2()
{
    otherFunc(2);
}

otherFunc(functionID)
{
    //some code to get func1's or func2's name or idx
    if(functionID == 1)  print("Called from function Name func1");
   if(functionID == 2)  print("Called from function Name func2");
}
I don't think it's possible any other way.
Reply
#3

yeah not really what i was looking for.


im digging in the pawn ref and implementer's guide to see what i find.
Reply
#4

first off thanks for the response.

The reason behind this is a logging system,
My goal WAS to add the calling functions name within the log.
I wanted the log function to be generic for use across the mode but I do think
it will end up to complex and i could just pass the func name to the log manually when its called.
So instead of being lazy....
I have already began to rethink this hole process.



~j5
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)