CnPack Forum » CnWizards IDE Wizards » Writing property's


2009-3-30 16:50 Bearimprint
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

[i]Private
  fPropOne: Cardinal;
  fPropTwo: String;[/i]

etc.

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

[i]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;
[/i]




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

2009-3-30 17:16 Passion
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, ;-)

2009-3-30 18:48 Bearimprint
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).

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

2009-3-30 19:47 Bearimprint
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:

[i]property PropOne: Cardinal read fPropOne write SetPropOne;[/i]

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 :D

页: [1]
查看完整版本: Writing property's


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.