Sign in Join

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

Mailing lists / fpc-pascal / 2012-02

(no subject)

9 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

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

Everton Vieira

Is there any plans to implement public procedures/function of a class that can be used without been necessary to create the class?

Everton Vieira.

Reply by email

Sven Barth
to Everton Vieira
Everton Vieira wrote
Is there any plans to implement public procedures/function of a class that can be used without been necessary to create the class?

Do you know class procedures/functions?

=== example begin ===

type
   TTestClass = class
     class procedure Foo;
     class function Bar: LongInt;
   end;
class procedure TTestClass.Foo;
begin
end;
class function TTestClass.Bar: LongInt;
begin
end;
var
   x: LongInt;
begin
   TTestClass.Foo;
   x := TTestClass.Bar;
end.

=== example end ===

Regards,
Sven

Reply by email

Howard Page-Clark
to Everton Vieira: Is there any plans to implement public procedures/function of a class that can be used…
Everton Vieira wrote
Is there any plans to implement public procedures/function of a class that can be used without been necessary to create the class?

I presume you know about class methods such as TObject's

class function ClassName : shortstring;

that you can use like this

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShowMessageFmt('Class name of TEdit is %s', [TEdit.ClassName]);
end;

without needing to instantiate a TEdit instance?

Reply by email

Everton Vieira
to Michael Van Canneyt

Exactly that i was meant, thank you people.

2012/2/23 Michael Van Canneyt

Show quoted text 30 lines
On Thu, 23 Feb 2012, Everton Vieira wrote: Is there any plans to implement public procedures/function of a class > that can be used without been necessary to create the class? > This exists: class functions. Given the declaration TMYClass = Class Class function doGLobal (Arg : ArgType) : Resulttype; end; Then TMyClass.doGlobal(a) Is Valid. Michael. ______________________________**_________________ fpc-pascal maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
Everton Vieira.

Reply by email