first generic attempt lazarus / 21-General ---------------------------------------------------------------------- Paolo · 2023-05-27 08:08 Maybe it is not possible. Starting palying with generics I have an object that is something like (code reduced to the essential parts) 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 TFirstGeneric =classPrivate..   A:T1;..End;  My need is to play with T1 both integer and double type. Everything is going well up to the point I need to do a conversion from an input string, and I have to properly select one of the two alternatives 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  (S is a string)..A:=S.ToInteger;A:=S.ToDouble;..  How can do that ? alternatives ? ---------------------------------------------------------------------- avk · 2023-05-27 08:25 Maybe 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 ...uses  ... SysUtils, ......  A := T1.Parse(S);... ---------------------------------------------------------------------- Paolo · 2023-05-27 08:40 thanks. What PARSE do ? nothing found in SysUtils. ---------------------------------------------------------------------- TRon · 2023-05-27 08:42 Quote from: Paolo on May 27, 2023, 10:40:13 amthanks. What PARSE do ? nothing found in SysUtils. Helpers: https://www.freepascal.org/docs- html/rtl/sysutils/typehelpers.html in particular: https://www.freepascal.org/docs- html/rtl/sysutils/tstringhelper.parse.html ---------------------------------------------------------------------- Paolo · 2023-05-27 08:46 Thank you ! ---------------------------------------------------------------------- avk · 2023-05-27 08:53 More precisely LongInt.Parse()/Integer.Parse() and Double.Parse(). ---------------------------------------------------------------------- TRon · 2023-05-27 08:57 Yeah, sorry avk and Paolo as I interpreted the question the other way around (convert to string). links: https://www.freepascal.org/docs- html/rtl/sysutils/tdoublehelper.parse.html https://www.freepascal.org/docs- html/rtl/sysutils/tintegerhelper.parse.html ---------------------------------------------------------------------- Martin_fr · 2023-05-27 09:47 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 generic TFirstGeneric =class  function ParseString(s:string): T1; virtual; abstract;end; TFoo = class(specialize TFirstGeneric)  function ParseString(s:string): single; override;end;  If you must do it in the base, maybe this will help (not the nicest code in my opinion....) 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   if TypeInfo(T1) = TypeInfo(Single) then writeln('s');  if TypeInfo(T1) = TypeInfo(Double) then writeln('d'); ---------------------------------------------------------------------- Paolo · 2023-05-28 14:59 Thaks to all for the suggestions. I think I'll rearrange the code logic (same problem to distinguish between 'div' and '/' ---------------------------------------------------------------------- Paolo · 2023-06-02 08:31 still unable to find PARSE, even if the code compiles (but not yet tested) ---------------------------------------------------------------------- TRon · 2023-06-02 08:52 Quote from: Paolo on June 02, 2023, 10:31:23 amstill unable to find PARSE, even if the code compiles (but not yet tested) Honest question: what did you not understood from typehelpers located at sysutils ? It is fundamental to know about typehelpers in order to understand how it works. ---------------------------------------------------------------------- Paolo · 2023-06-02 09:11 Forget it, now I see where they are, thank you