Jump to content


Photo

AsFormat


  • Please log in to reply
3 replies to this topic

#1 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 30 August 2007 - 03:59 PM

Hi Boki,

Is it possible to add AsFormat as a procedure at carious places where you can use the AsString property?

It would be extreme handy (and shorter to code) as an alternative to code like:

CODE
xx.AsString:=Format('0x%8.8X',[1234]);


it would then look like

CODE
xx.AsFormat('0x%8.8X',[1234]);


The construction would also be very convenient as an extension for the Add method on the TStringList. So

CODE
sl.Add(Format('0x%8.8X',[1234]));


would become

CODE
sl.Add('0x%8.8X',[1234]);

G.W. van der Vegt

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 30 August 2007 - 06:06 PM

Hello Wim,

It look like good idea. I am not yet sure where I can add it, but first I have in mind that it may fit well for TCell object.

I think that I will add it soon.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 31 August 2007 - 05:26 PM

Hi,

For the TStrings/ TStringList you would have to subclass them so you have your own TNxStrings class and thus can create an extended version of it. Personally i would overload the Add() function.

So have TNxStrings.Lines.Add(txt) and TNxStrings.Lines.Add(fmt, [parms]);

The subclassing is something you'll have to do anyway to support widestrings too.

For the other controls, most editors would benefit from an public AsFormat function to set the Text property.

Btw glad you like the idea.

QUOTE (Boki (Berg) @ Aug 30 2007, 07:06 PM) <{POST_SNAPBACK}>
Hello Wim,

It look like good idea. I am not yet sure where I can add it, but first I have in mind that it may fit well for TCell object.

I think that I will add it soon.

Best regards

G.W. van der Vegt

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 31 August 2007 - 08:53 PM

Hello Wim,

I will need to have deep thinking about AsFormat for TStrings, because at the moment when TNT_UNICODE is on, I am using TTntStrings instead of TStrings.

For TCell and similar classes it will be much easier.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users