Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-03

Determining procedure's name

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wimpie Nortje

Hello everybody,

Is there a macro or function that gives the current procedure's name?

E.g.

procedure TClass.SomeProc;
begin
  writeln(Format('This procedure's name is %s', [THE_MACRO]));
end;

should print

This procedure's name is TClass.SomeProc

or

This procedure's name is SomeProc

Jonas Maebe
to Wimpie Nortje
Wimpie Nortje wrote
Is there a macro or function that gives the current procedure's name?

There is a function, but only for methods:

      class function TObject.MethodName(address : pointer) : shortstring;

Simply pass the address of a method as argument. There is no macro.

Jonas

Mattias Gaertner
to Wimpie Nortje: Is there a macro or function that gives the current procedure's name? E.g. procedure…
Show quoted text 10 lines
Hello everybody, Is there a macro or function that gives the current procedure's name? E.g. procedure TClass.SomeProc; begin writeln(Format('This procedure's name is %s', [THE_MACRO])); end;

If you use Lazarus you can create a code template. Then you can type w plus Ctrl+J and you will get:

  writeln(Format('This procedure's name is %s', ['TClass.SomeProc']));
I prefer
  writeln('TClass.SomeProc '|);

The | symbol is where the cursor is positioned after the template was added.

Show quoted text 7 lines
should print This procedure's name is TClass.SomeProc or This procedure's name is SomeProc

Mattias

Wimpie Nortje
to Mattias Gaertner

Thanks, I will look at the suggestions

Mattias Gaertner wrote 45 lines
On Wed, 03 Mar 2010 21:33:45 +0200 Wimpie Nortje wrote: > Hello everybody, > > Is there a macro or function that gives the current procedure's name? > > E.g. > > procedure TClass.SomeProc; > begin > writeln(Format('This procedure's name is %s', [THE_MACRO])); > end; > If you use Lazarus you can create a code template. Then you can type w plus Ctrl+J and you will get: writeln(Format('This procedure's name is %s', ['TClass.SomeProc'])); I prefer writeln('TClass.SomeProc '|); The | symbol is where the cursor is positioned after the template was added. > should print > > This procedure's name is TClass.SomeProc > > or > > This procedure's name is SomeProc > Mattias _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal