Forum > General
first generic attempt
Paolo:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TFirstGeneric <T1>=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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- (S is a string)..A:=S.ToInteger;A:=S.ToDouble;..
How can do that ?
alternatives ?
avk:
Maybe
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...uses ... SysUtils, ...... A := T1.Parse(S);...
Paolo:
thanks. What PARSE do ? nothing found in SysUtils.
TRon:
--- Quote from: Paolo on May 27, 2023, 10:40:13 am ---thanks. What PARSE do ? nothing found in SysUtils.
--- End quote ---
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:
Thank you !
Navigation
[0] Message Index
[#] Next page