Board logo

Subject: Writing property's [Print This Page]

Author: Bearimprint    Time: 2009-3-30 16:50     Subject: Writing property's

Hi all.

First, big thank for this nice package, nice and really useful.

I have a request.
I waste much time writing property of a class.

It's any way to for example:
Write the property's

Private
  fPropOne: Cardinal;
  fPropTwo: String;


etc.

Select the property's and have a script who add, correctly, the property's like this:

TmyClass= Class
Private
  fPropOne: Cardinal;
  fPropTwo: String;
  Procedure SetPropOne(const value: cardinal);
  Function GetPopOne: cardinal;
  Procedure SetPropTwo(Const Value: String);
  Function GetPropTwo: string;
Public
  property PropOne: Cardinal read GetPropOne write SetPropOne;
  property PropTwo: String read getPropTwo write SetPropTwo;
end;

implementation


Procedure TmyClass.SetPropOne(const value: cardinal);
begin
  fPropOne:= value;
end;

Function TmyClass.GetPopOne: cardinal;
begin
  result:= fPropOne;
end;

Procedure TmyClass.SetPropTwo(Const Value: String);
begin
  fPropTwo:= value;
end;

Function TmyClass.GetPropTwo: string;
begin
  result:= fPropTwo;
end;





Well, i hope you find this usefua and, maybe, create a menu, in the BlockSelection for this task.
It would save a lot of writing
Author: Passion    Time: 2009-3-30 17:16

I think only the two lines written in class definition and press Ctrl+Shift+C, Delphi will auto generate F* Definitions and implementations.

  property PropOne: Cardinal read GetPropOne write SetPropOne;
  property PropTwo: String read getPropTwo write SetPropTwo;

This function is powerful, ;-)
Author: Bearimprint    Time: 2009-3-30 18:48

Thank for the reply ^^

But, unfortunately, this shortcut (CTRL+SHIFT+C) have work some time ago but no more since some weeks.
I have take a look if the shortcut was used by another added tools (I use Gexpert an CnPack) but, seemingly, all is ok and i don't have more idea why that don't work more properly.
(I use Delphi 7 pro).
Author: Passion    Time: 2009-3-30 19:22

Oh, weird. Try to check the Key Mapping in Editor Options?
Or uninstall CnPack IDE Wizards and GExperts and try again?
Author: Bearimprint    Time: 2009-3-30 19:47

Shame on me... :p

Well, the CTRL+SHIFT+C Works again.
Thank for the help ^^

But, after a little test, that work "only" if you write the property like:

property PropOne: Cardinal read fPropOne write SetPropOne;

And Delphi write all the rest after a CTRL+SHIFT+C

       
It may be time that i take a look at what can be done with the script, and make my own, to create properties from their statement, like i have write in my first post.

Anyway, thank again, you make my day




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0