TFPExpressionParser ...and jargon about strToFloat etc. lazarus / 31-LCL ---------------------------------------------------------------------- ArtLogi · 2021-01-30 17:45 Hello With expression parser is there a way to extract all non-defined (not number, not in build-in categories, not programmer specified "user defined function") strings from expression to array (..or some other list style data structure). Example if user gives a string to edit1.text as 'sin(x)+cos(y)+z' is there a subprogram (or OOP equivalent) which then returns a list of sometype [x, y, z]. Just figured it might be better to ask, before I do some string function/procedure by myself and later do find out that re-inventing the wheel is not so funny after all. PS. It seems that something has changed as wiki is saying: "Floating point constants in expressions must have a point as decimal separator, not a comma" for my PC+OS (win) the DecimalSeparator (which now seems to be deprecated  ) for me is comma (,) and when StrToFloat(edit1.text) where edit1.text=0.5, the program raises error as "not float" or equivalent. However with 0,5 it does seem to work and FParser.Evaluate.ResFloat return correct answer. Also no errors with FParser.Identifiers.AddFloatVariable('x', 0.5);, but the result is given with comma. ---------------------------------------------------------------------- marcov · 2021-01-30 17:50 Symbolic supports it, see its examples. packages/symbolic/examples/evaltest.pas.  The  SymVars:=Expr.SymbolicValueNames;  line  gets the list with symbols detected in the expression: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {    $ id:                                                     $    Copyright (c) 2000 by Marco van de Voort (marco@freepascal.org)    member of the Free Pascal development team     See the file COPYING.FPC, included in this distribution,    for details about the copyright. (LGPL)     Most basic test for TEvaluator class.     This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  ************************************************* *********************} program EvalTest; {$AppType Console} Uses Classes,Symbolic, SysUtils; VAR Expr    : TExpression;    SymVars : TStringList;    I       : Longint;    VarName : TStringList;    Eval  : TEvaluator;    Vars    : Array[0..1] OF ArbFloat; begin {Lets create in a nice equation. Totally nonsense. Don't try to               make sense of it}  Expr:=TExpression.Create('pi*sin(x-x0)+x^(t- 1)+exp(x*t)+5'); Writeln('Expression after parsing :',Expr.InfixExpr);  {Hmm. But the user could have typed that in. Let's check if he used  symbolic values}  SymVars:=Expr.SymbolicValueNames;   If SymVars.Count>0 Then   For I:=0 TO SymVars.Count-1 DO     Writeln(I:5,' ',Symvars[I]);  {Assume the user selected X and T from above stringlist as our variables}   VarName:=TStringList.Create;  VarName.Add('X');  VarName.Add('T');  {Create the Evaluator Object}  Eval:=TEvaluator.Create(VarName,Expr);  {My HP48g provided this value for PI:}  IF Symvars.IndexOf('PI')<>-1 THEN      {If PI exists, then assume it is the                                         circle radius vs diameter ratio}    Eval.SetConstant('PI',3.14159265359);  IF Symvars.IndexOf('X0')<>-1 THEN      {Set X0 to Douglas' number}    Eval.SetConstant('X0',42);  {All this above looks slow isn't? It probably even is. Unit symbolic has  evaluations as plus, not as target. The evaluation is built for  fast repeated evaluations, not just one.  However the Evaluate method is hopefully reasonably fast.  Under FPC TEvaluator.Evaluate is about 600-700 assembler instructions,  without operation on pointer trees and without recursion.  If your compiler (and hopefully FPC too) can inline the math unit functions,  the speed gain could be dramatic.}  Writeln('Stackdepth needed for evaluation: ',eval.EvalDepth);  FOR I:=1 TO 50 DO  begin   Vars[0]:=1/I *1.1;   Vars[1]:=1/I*2;   Writeln(VarName.Strings[0] + '=' + FloatToStrF(Vars[0], ffFixed, 4, 4) + ' ' +           VarName.Strings[1] + '=' + FloatToStrF(Vars[1], ffFixed, 4, 4) + ' = ' +                                      FloatToStrF(Eval.Evaluate(Vars), ffFixed, 4, 4));  end;  Eval.Free; Expr.Free; SymVars.Free;// VarName.Free;  {Is freed by TEvaluator.Destroy. Should TEvaluator copy it?}   Readln;end.  {  $Log$  Revision 1.1  2002/12/15 21:01:22  marco  Initial revision } ---------------------------------------------------------------------- wp · 2021-01-30 18:38 Each variable must be added to the Identifiers list of the parser. By iterating through the Identifiers you can list all variables. Just try this program: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; uses  fpexprPars; var  parser: TFPExpressionParser;  i: Integer; begin  parser := TFpExpressionparser.Create(nil);  try    parser.Identifiers.AddFloatVariable('x', 0.5);    parser.Identifiers.AddFloatVariable('y', 1.0);    parser.Expression := 'x+y';     for i := 0 to parser.Identifiers.Count-1 do      WriteLn(parser.Identifiers[i].Name, '=', parser.Identifiers[i].AsFloat:0:3);     WriteLn(parser.Expression, '=', parser.AsFloat:0:3);  finally    parser.Free;  end;   ReadLn;end. Some time ago I submitted a patch to allow also decimal commas in the expression, but it was rejected. Therefore, I think that the wiki documentation is still up-to-date. I just tested that the parser absolutely requires a decimal point when a constant is used in an expression (e.g. parser.Expression := '1.0 + 0.5';)  even if the format settings of your system want a comma. Of course this is also true for floating point variables which always have been written with a point in the Pascal language. And of course, when you convert a floating point result to a string or vice versa using StrToFloat() or FloatToStr() the decimal separator of the system's FormatSettings is needed. ---------------------------------------------------------------------- marcov · 2021-01-30 20:09 I updated the post above with the code. ---------------------------------------------------------------------- ArtLogi · 2021-01-31 00:50 Thank you. I will read these tomorrow and return with better reply. But as quick reply marcovs answer is more in line what I'm interested at the moment. I was and and I'm still interested if expression parser could somehow extract all identifiers from free form user (not programmer) customer written expression (think like cropping undeclared litter), before identifiers are declared to expression parser. ...But it might be that the expression parser is not actually doing anything that advanced internally which would give such feature "for free" and therefore I do assume it do not exist, now thinking of it.  Also about the wiki... I think it is my brainfart and poor test program (which I do correct also tomorrow) there is obviously double inversion. And the fact IIRC that S2F and F2S do use internally DecimalSeparator (or equivalent) NOT DecimalSeparator and/or dot.  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  [In: , ]->[S2F: DecimalSeparator => dot]->[exprPars]->[F2S: dot => DecimalSeparator] ->[Out: ,]  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i How I was thinking:         +----------str to float-------------+               [input]--|-+-[ is dot   ]----[conversion]--+ |         | |                             | |         | +-[ is comma ]----[conversion]--+-|--[OUT]         +-----------------------------------+ What it actually does:         +----------str to float-------------+              [input]--|-+-[ is D.S   ]----[conversion]--+ |         | |                             | |         | +-[ is NOT D.S ]--[jmp error]   +-|--[OUT]         +-----------------------------------+  ... But I'm too tired, reading above still doesn't make sense ... tldr. brainfart. ---------------------------------------------------------------------- wp · 2021-01-31 09:29 Quote from: ArtLogi on January 31, 2021, 01:50:51 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i How I was thinking:         +----------str to float-------------+               [input]--|-+-[ is dot   ]----[conversion]--+ |         | |                             | |         | +-[ is comma ]----[conversion]--+-|--[OUT]         +-----------------------------------+ If this were true, how should a string be handled which is allowed to contain both decimal and thousand separator? So, which value could be extracted from the string '1,000' when the decimal separator is not fixed as in your sketch? ---------------------------------------------------------------------- ArtLogi · 2021-01-31 11:03 Quote from: wp on January 31, 2021, 10:29:37 amQuote from: ArtLogi on January 31, 2021, 01:50:51 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i How I was thinking:         +----------str to float-------------+               [input]--|-+-[ is dot   ]----[conversion]--+ |         | |                               | |       | +-[ is comma ]----[conversion]--+-|--[OUT]         +-----------------------------------+ If this were true, how should a string be handled which is allowed to contain both decimal and thousand separator? So, which value could be extracted from the string '1,000' when the decimal separator is not fixed as in your sketch? A valid question, the wrong number most probably.  How it at the moment does handle a number 1,000.00 or 1 000.00 or 1'000 ??? ---------------------------------------------------------------------- winni · 2021-01-31 12:42 Hi! Behave like you do in a foreign country: Speak that language the people understand. 1,000.00 or 1 000.00 or 1'000  are unknown languages to fpc. Winni ---------------------------------------------------------------------- wp · 2021-01-31 12:44 Quote from: ArtLogi on January 31, 2021, 12:03:02 pmHow it at the moment does handle a number 1,000.00 or 1 000.00 or 1'000 ???  AFAIK not at all: StrToFloat assumes that a ThousandSeparator is not present and raises an exception otherwise. Your code must remove the ThousandSepator before passing the string to a string-to-float conversion function. ---------------------------------------------------------------------- ArtLogi · 2021-01-31 12:56 Quote from: winni on January 31, 2021, 01:42:41 pmHi! Behave like you do in a foreign country: Speak that language the people understand. 1,000.00 or 1 000.00 or 1'000  are unknown languages to fpc. Winni Hello yes, that's why the whole OS radix thing is so annoying as everyone knows that computer only consumes floats as type 1.0 or 1.0e+0 not 1,0 (ps. which is not techinally true as ie. ARM IIRC only consumes integers) .. And then it does make things messy if I do want to output the float in other than OS radix since s2f and f2s assumes OS radix. Why just not commands like toOSradix and fromOSradix and the f2s and s2f follow the internal convention of no thousand separation and fixed dot as radix. *Phew*     ...must calm down and start to investigate the expression parser further. ---------------------------------------------------------------------- marcov · 2021-01-31 14:10 Quote from: ArtLogi on January 31, 2021, 01:50:51 amBut as quick reply marcovs answer is more in line what I'm interested at the moment. To accept both comma and dot as separater, it is P\probably a matter of hacking parsexpr.inc:170 to 190 a bit. It would be a nice feature. Here in the NL use both English (dot) and Dutch (comma) notation, and not always matching their locale. In most my applications I accept both. The apps are non financial though, so thousand separator use is rare. ---------------------------------------------------------------------- lucamar · 2021-01-31 17:50 The problem, I think, is that conversion functions of that type are meant basically to parse IO to/from human users, who are notoriously inconsistent in what they want at each specific time. A solution might be to add an "Options" (with adequate defaults) parameter (and/or some overloads) to those kind of functions to deal with (almost) all kinds of input/output: with/without thou. sep., accept any decimal sep., follow strictly local conventions, etc. Wouldn't make life very easy for the implementors, though ---------------------------------------------------------------------- ArtLogi · 2021-01-31 20:13 First of I must say that this topic and depth starts to be way way out of my technical expertise. Quote from: marcov on January 31, 2021, 03:10:46 pmQuote from: ArtLogi on January 31, 2021, 01:50:51 amBut as quick reply marcovs answer is more in line what I'm interested at the moment. To accept both comma and dot as separater, it is P\probably a matter of hacking parsexpr.inc:170 to 190 a bit. It would be a nice feature. Here in the NL use both English (dot) and Dutch (comma) notation, and not always matching their locale. In most my applications I accept both. The apps are non financial though, so thousand separator use is rare. While indeed it would be really nice for string to float type conversion, it would be logical suicide when one would need to convert from float to string. It is logically better (for human that is) to have them both behave the same way. Also it would create even more branching inside the implementation and slow things down. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i           +----------str to float-------------+              [In: ./,]-|-+-[ is dot   ]------------------+ |          | |                             | |          | +-[ is comma ]----[conversion]--+-|--[OUT]          +-----------------------------------+            +----------float to str-------------+              [IN:DOT]--|-+-[    dot   ]--------------------|--[OUT]          | |                               |         Which one of these branches ???           | +-[    comma ]----[conversion]----|--[OUT]          | |                               |          | +-[  Des.Sep.]--+-[dot]-----------|--[OUT]          |                 |                 |          |                 +-[,]-[conv]------|--[OUT]          +-----------------------------------+   Quote from: lucamar on January 31, 2021, 06:50:28 pmThe problem, I think, is that conversion functions of that type are meant basically to parse IO to/from human users, who are notoriously inconsistent in what they want at each specific time. I think the original author of this feature s2f/f2s did think it in the same way (falsely???). I do see it purely a type conversion under the hood. Only when the resulting string is then send or read to somewhere as a data it becomes an HMI input/output. However I do understand the reasoning most of its use is when someone is exchanging some data between visible representation and float variable. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Pure type conversion:[FLOAT AS STRING]-----[Conv.]----[FLOAT AS FLOAT][FLOAT AS FLOAT]-----[Conv.]----[FLOAT AS STRING] What actually now happens:[FLOAT AS STRING]--[Localizer]--[Conv.]--[FLOAT AS FLOAT][FLOAT AS FLOAT]--[Conv.]--[Localizer]--[FLOAT AS STRING]??? Edit. Hmm... https://www.freepascal.org/docs- html/rtl/sysutils/strtofloat.html it have been working correctly in the past, but now fixed to be broken at low level.  Edit2. Which unfortunately makes this statement false: QuoteFloatToStr: Convert a float value to a string using a fixed format https://www.freepascal.org/docs-html/rtl/sysutils/floattostr.htmlSince now the format is dependent of the OS decimal separator.  Edit3. QuoteAnsiSameStr: Checks whether 2 strings are the same (case sensitive) AnsiSameText: Checks whether 2 strings are the same (case insensitive)With same naming convention logic these current strToFloat and FloatToStr functions should have been renamed to be: - TxtToFlt - FltToTxt Simple solutions are beautiful and fits for simple person. .... And my expression parser study have not progressed at all today. ---------------------------------------------------------------------- lucamar · 2021-01-31 23:10 Quote from: ArtLogi on January 31, 2021, 09:13:04 pmEdit2. Which unfortunately makes this statement false: QuoteFloatToStr: Convert a float value to a string using a fixed format https://www.freepascal.org/docs-html/rtl/sysutils/floattostr.htmlSince now the format is dependent of the OS decimal separator.  What "fixed format" means there is that it returns a result in a function-choosen "fixed" notation (or rather, "general" notation) instead of having to specify it in the call. In that sense, FloatToStr() is a "specialization" of FloatToStrF(), so the notation is "fixed" even if it depends on the underlying TFormatSettings (which, BTW, can be changed in some overloaded forms). Note that FloatToStr() overloads also allow you to specify format settings other than the system ones. Of course, all that means little (yet?) with regard to TFPExpressionParser, which is the topic of this thread. ---------------------------------------------------------------------- ArtLogi · 2021-02-01 00:15 Quote from: lucamar on February 01, 2021, 12:10:59 amQuote from: ArtLogi on January 31, 2021, 09:13:04 pmEdit2. Which unfortunately makes this statement false: QuoteFloatToStr: Convert a float value to a string using a fixed format https://www.freepascal.org/docs-html/rtl/sysutils/floattostr.htmlSince now the format is dependent of the OS decimal separator.  What "fixed format" means there is that it returns a result in a function-choosen "fixed" notation (or rather, "general" notation) instead of having to specify it in the call. In that sense, FloatToStr() is a "specialization" of FloatToStrF(), so the notation is "fixed" even if it depends on the underlying TFormatSettings (which, BTW, can be changed in some overloaded forms). Note that FloatToStr() overloads also allow you to specify format settings other than the system ones. Of course, all that means little (yet?) with regard to TFPExpressionParser, which is the topic of this thread. The floaty thing is mostly arguing just for sake of it. When the functionality is known to be dependent of localization one always can write a de-localizer or de-localized conversion function (although I do see it a bit stupid that I must undo something that RTL is doing as library of very basic lego-blocks) and use it, instead of using the basic blocks to construct something more complex if not already included to libraries/books/units however one like to call them. I'm just a bit perplexed why the the two functions are developed as they have been (assuming from the doc) from SISO (skipping the fact it does handle scientific notation in format of ±xE±y) to some form of SIMO + MISO system. Instead of keeping it SISO and introducing localizer function for stringfloats. Obviously the localization is step from 1960 to 2000, but...  QuoteWhat "fixed format" means there is that it returns a result in a function-choosen "fixed" notation (or rather, "general" notation) instead of having to specify it in the call. You are probably right, it depends how one do interpret that fixed format. ---------------------------------------------------------------------- lucamar · 2021-02-01 03:31 Quote from: ArtLogi on February 01, 2021, 01:15:29 amWhen the functionality is known to be dependent of localization one always can write a de-localizer or de-localized conversion function (although I do see it a bit stupid that I must undo something that RTL is doing as library of very basic lego-blocks) and use it, instead of using the basic blocks to construct something more complex if not already included to libraries/books/units however one like to call them. But you have got already the "lego" blocks! And they don't depend on default localization, either, unless you wish it. Only, instead of using the most basic function overloads you've to use more "sophisticated" ones, so instead of  for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum)you'd use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MySettings {a TFormatSettings} := DefaultFormatSettings;MySettings.ThousandSeparator := '!';MySettings.DecimalSeparator := ';';Caption := FloatToStr(ANum, MySettings);which for ANum=1234.56 would display as caption: Code: [Select]1!234;56An if you need even more control, there you've FloatToStrF() to which you can tell everything with the level of detail you want: format, notation, digits before/after the comma, ... And similarly for, say, StrToFloat(). So the blocks are there; one just have to know they are there, which can be done by simply reading the documentation. ETA: Corrected stupid mistake ---------------------------------------------------------------------- ArtLogi · 2021-02-01 07:26 Quote from: lucamar on February 01, 2021, 04:31:09 amQuote from: ArtLogi on February 01, 2021, 01:15:29 amWhen the functionality is known to be dependent of localization one always can write a de- localizer or de-localized conversion function (although I do see it a bit stupid that I must undo something that RTL is doing as library of very basic lego-blocks) and use it, instead of using the basic blocks to construct something more complex if not already included to libraries/books/units however one like to call them. But you have got already the "lego" blocks! And they don't depend on default localization, either, unless you wish it. Only, instead of using the most basic function overloads you've to use more "sophisticated" ones, so instead of  for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum)you'd use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MySettings {a TFormatSettings} := DefaultFormatSettings;MySettings.ThousandSeparator := '!';MySettings.DecimalSeparator := ';';Caption := FloatToStr(ANum);which for ANum=1234.56 would display as caption: Code: [Select]1!234;56An if you need even more control, there you've FloatToStrF() to which you can tell everything with the level of detail you want: format, notation, digits before/after the comma, ... And similarly for, say, StrToFloat(). So the blocks are there; one just have to know they are there, which can be done by simply reading the documentation. You do realise how non-self explanary these T-starting objects as some secondary kind of call parameter (whic eventyally is not even called call parameter, but used as such) are for a person who uses freepascal or anyother general language for like once in a four years to write something like ten thousand lines of code. Indeed I will read the documentation of this FloatToStr, but it is really is more straight forward to use tools (without Txxxxx) found from systutils (because of their atomic nature) and a few other base units and a few IFs and FOR-loops to go pass things, than read these documents (if there is much more than comment from source, like with this RTL document), where you are referring to. You see I'm on document reading phase with TFPExpressionParser (<- notice starts with T), I think I'm on that phase still many days more, but it does that much more than StrToFloat that it hopefully eventually pays back. Of course I'm cratefull for persons who contribute to project like this, but come on. ---------------------------------------------------------------------- marcov · 2021-02-01 09:09 Quote from: lucamar on February 01, 2021, 04:31:09 am Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum)Caption := FloatToStr(ANum);[/code] Personally I would make that Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum,MySettings); ---------------------------------------------------------------------- lucamar · 2021-02-01 11:28 Quote from: marcov on February 01, 2021, 10:09:38 amQuote from: lucamar on February 01, 2021, 04:31:09 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum)Caption := FloatToStr(ANum);[/code] Personally I would make thatCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum,MySettings); Oops! Yeah, that's what I meant; corrected now Quote from: ArtLogi on February 01, 2021, 08:26:45 amYou do realise how non-self explanary these T-starting objects as some secondary kind of call parameter (whic eventyally is not even called call parameter, but used as such) are for a person who uses freepascal or anyother general language for like once in a four years to write something like ten thousand lines of code. Indeed I will read the documentation of this FloatToStr, but it is really is more straight forward to use tools (without Txxxxx) found from systutils (because of their atomic nature) and a few other base units and a few IFs and FOR-loops to go pass things, than read these documents (if there is much more than comment from source, like with this RTL document), where you are referring to. If you're realy writing ten thousand lines of code, you should be familiar with the facilities offered by the language and the compiler libraries. Those T-starting objects you complain about are record (and whatnot) types someone took the time and effort to add and use to easy the use of the RTL/FCL/LCL and be able to add all those overloads with (yes!) parameters that allow you to do almost anything you'd wish without having to reinvent the wheel (i.e a few IFs and FOR-loops). And don't forget that most of those conversion functions (with overloads) are in SysUtils, if not in System, so it's not that much effort to find and use them, much less if you take the trouble of dedicating a day or two to read the RTL/FCL/LCL/LazUtils docs to refresh your knowledege when you (re-)start again after those four years. But, of course, that's just my opinion; you can do whatever you see fit for you and your project(s). I just pointed a way to make something using the facilities already there. ---------------------------------------------------------------------- ArtLogi · 2021-02-01 13:09 Quote from: lucamar on February 01, 2021, 12:28:22 pmQuote from: marcov on February 01, 2021, 10:09:38 amQuote from: lucamar on February 01, 2021, 04:31:09 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum)Caption := FloatToStr(ANum);[/code] Personally I would make thatCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Caption := FloatToStr(ANum,MySettings); Oops! Yeah, that's what I meant; corrected now Quote from: ArtLogi on February 01, 2021, 08:26:45 amYou do realise how non-self explanary these T-starting objects as some secondary kind of call parameter (whic eventyally is not even called call parameter, but used as such) are for a person who uses freepascal or anyother general language for like once in a four years to write something like ten thousand lines of code. Indeed I will read the documentation of this FloatToStr, but it is really is more straight forward to use tools (without Txxxxx) found from systutils (because of their atomic nature) and a few other base units and a few IFs and FOR-loops to go pass things, than read these documents (if there is much more than comment from source, like with this RTL document), where you are referring to. If you're realy writing ten thousand lines of code, you should be familiar with the facilities offered by the language and the compiler libraries. Those T-starting objects you complain about are record (and whatnot) types someone took the time and effort to add and use to easy the use of the RTL/FCL/LCL and be able to add all those overloads with (yes!) parameters that allow you to do almost anything you'd wish without having to reinvent the wheel (i.e a few IFs and FOR-loops). And don't forget that most of those conversion functions (with overloads) are in SysUtils, if not in System, so it's not that much effort to find and use them, much less if you take the trouble of dedicating a day or two to read the RTL/FCL/LCL/LazUtils docs to refresh your knowledege when you (re-)start again after those four years. But, of course, that's just my opinion; you can do whatever you see fit for you and your project(s). I just pointed a way to make something using the facilities already there. I will do. I also must thank you, about the code snippet, after all I most probably end up using it at some point of time. About those T-starting objects Records are still rather straight forward (if the record is not too deep) vs object, but for perspective of someone like me those usually are hard to identify which is which as they are a bit like onions with layers after layers which end up really complex really soon. Not maybe yet in RTL so much, but on FCL and LCL. Another natural feature of them is that they are not necessary the same as similar object in another environment (ie. Edit- field) (at this case a programming language + libraries), compared to . Third natural feature is that they are often not as comprehensively documented (at one place), as more do-one-thing type of functions, due to their complexity and volunteer nature of development. You are correct that someone who is re-learning (or learning and re- learning) should read manual (rtfm). What comes to 10k lines of code as absolut max including whitespace and comment and ide-generated parts etc., I'm pretty sure that someone which is fluent with most of the language and library features, shortcuts and so on could do the same with fraction of code. However if I must chose to do things vs. reading of doing things in these hobby projects, I prefer to do things, even if the code is by all professional standards ugly as hell, consisting all form of copypaste(ism) from past projects and so forth.. ---------------------------------------------------------------------- Bart · 2021-02-01 19:39 Quote from: ArtLogi on February 01, 2021, 02:09:50 pmAbout those T-starting objects You are aware that there is some common naming convention here that the name of (custom) types start with a T (with the exception of basic types like integer, char, string etc.)? Bart ---------------------------------------------------------------------- ArtLogi · 2021-02-01 22:58 Quote from: Bart on February 01, 2021, 08:39:08 pmQuote from: ArtLogi on February 01, 2021, 02:09:50 pmAbout those T-starting objects You are aware that there is some common naming convention here that the name of (custom) types start with a T (with the exception of basic types like integer, char, string etc.)? Bart So then TObject is custom type, while it is the parent of all (correct me if I'm wrong) objects found from FPC implementation of OPascal? So how it can be custom if it as much set on the stone as string (array of chars). PS. I almost forgot that there is one clever exception to this rule. T-comes from Teacher it does have knowledge and methods and if it does have lucky students will heritage those both. Sometimes the students evolve to be so annoying that they return knowledge back to teacher. Seriously T I do assume comes from Type or Turbotype. While Record is a drawer and method is a clerk, when both are combined to same space it forms an concept of great suffering aka office. tldr.. I really do not know where and how the name convention of this prefix uppercase T really comes and how it should work. ---------------------------------------------------------------------- lucamar · 2021-02-02 00:06 Quote from: ArtLogi on February 01, 2021, 11:58:53 pmtldr.. I really do not know where and how the name convention of this prefix uppercase T really comes and how it should work. It's quite easy: the "Txxx" convention to name a type (as well as "Pxxx" to mean a pointer) comes from as far back as Turbo Pascal (it was Borland's convention) and Borland/CodeGear/Embarcadero have kept it alive through the years. In the begining, it came about because objects used to be accessed mainly through pointers, so you'd have an object Something of type TSomething, accessed thorugh a pointer PSomething. So it's an historical artifact become a "convention", just as much as Microsoft's "hungarian notation"--and in fact can be seen as a simplification of that. There's a document at Embarcadero (though I don't have the URI, sorry) explaining this and other conventions in their code which has become through the years the "standard" for almost all Pascal programmers. Note that it's mostly used for non-intrisic, non-simple types (and yes, while it's forced as the "ancestor" of all classes TObject is neither of that and is declared, IIRC, in the unit Classes). Ancient types (integer, char, etc.), of course, are part of the base (mostly Wirth's) language and follow no such convention, hence aliases and related types don't follow it either, much less "C" derived types.