How can i determine who called the Showme Procedure?
procedure Showme(str:string);
begin
ShowMessage(str);
end;
procedure btnclick(sender:TObject);
begin
Showme("test");
end;
procedure btn2click(sender:TObject);
begin
Showme("test");
end;
Edit : The Confusion
Showme(654, '654'); // procedure name, string
Showme(654, '564');
There’s no built-in way for one procedure to know which procedure called it. You can use stack tracing if you really need to know, but that sort of data is really only needed for debugging. For actual execution, what matters is the data that’s passed to the routines, not where it came from. That’s one of the basic principles of structured programming. If two different routines call the same procedure with the same data, it should treat them both the same.
What exactly are you doing where you need to be able to tell the difference? There might be a simpler way to accomplish it.