StrToFloatDEf-why Delphi does not have this ? lazarus / 21-General ---------------------------------------------------------------------- jamie · 2021-03-26 21:46 Kudos To who ever thought of this function... While smashing the keyboard during code production via Delphi I needed a StrToFloat function that wouldn't just give up the ghost to puke all over the user screen with nonsense messages, that only shows weakness of the Tools!   So I made one. But while editing some of my pet moon lighting projects with Laz I find it has "StrToFloatDEF" !...  I guess someone was thinking one day! Just thought I would throw that out there! ---------------------------------------------------------------------- sstvmaster · 2021-03-26 22:28 StrToFloatDef does exists in Delphi? -> http://docwiki.embarcadero.com /Libraries/Sydney/en/System.SysUtils.StrToFloatDef And XE2 also. ---------------------------------------------------------------------- jamie · 2021-03-26 23:15 really, I couldn't find it..  Well so much for that I guess.. the PC with recent Delphi has been getting a good keyboard workout lately... IDE is kind of hard to get use and the help files aren't what they used to be. Btw.  I did just tried to find a StrToStrDef and that does not exist.. I guess. at least I can't find it.. The idea behind that is if the string is empty you can force a value to it... Much like working with INI files etc.. Unless I've missed the boat again! I know this does not save much on code space it none at all but it makes the source code a little less to scroll around without having to deal with IF THIS ELSE Etc  A good inline function would work for this. ---------------------------------------------------------------------- lucamar · 2021-03-27 03:24 Quote from: jamie on March 27, 2021, 12:15:20 am I did just tried to find a StrToStrDef and that does not exist.. I guess. at least I can't find it.. Maybe because it is StrToFloatDef()? IIRC the function has been there (in SysUtils) at least since D5 since it's a very common operation: try StrToFloat and, on except, return a default value. The ideal "utility" routine for Borland to add and look like they had added something wothwhile for the new release ---------------------------------------------------------------------- jamie · 2021-03-27 15:30 Quote from: lucamar on March 27, 2021, 04:24:34 amQuote from: jamie on March 27, 2021, 12:15:20 am I did just tried to find a StrToStrDef and that does not exist.. I guess. at least I can't find it.. Maybe because it is StrToFloatDef()? IIRC the function has been there (in SysUtils) at least since D5 since it's a very common operation: try StrToFloat and, on except, return a default value. The ideal "utility" routine for Borland to add and look like they had added something wothwhile for the new release Hmm, I thought that is what I said? well maybe this old fart is losing it.