With a series of Helper, Delphi can also use chain code.
For example, to extract 3.1415926 of 141 as an integer:var
Num:integer;
begin
Num: = pi.tostring (). Split (['. ']) [1]. Substring (0,3). Tointeger (); Input. , remember to use the Ctrl+space prompt code
showmessage (Num. ToString ()); Theend of the end;
I started using it when I wrote a program similar to the following:
{The program requests to extract A:B from the following text: ... The following text to the specified variable: a:qwertyuiopb:wertyuiopac:ertyuiopasqwertyuiopasdd:rtyuiopasd ...}usesSystem.character; <--IsinarrayConstFtext = ' A:qwertyuiop ' #13 #10 + ' B:wertyuiopa ' #13 #10 + ' C:ertyuiopas ' #13 #10 + ' Qwertyuiopa SD ' #13 #10 + ' d:rtyuiopasd ' #13 #10;procedureTform1.button1click (Sender:tobject);varList:tstringlist; A, B, C, D:string; Str:string;beginList: = tstringlist.create; List.text: = Ftext; forStr inListTodo
beginif(str. Length > 2) andSTR [2]. Isinarray ([': '])thenbegin CaseSTR[1] of' A ': a: = str. Substring (2). Trim; This uses the chain code ' B ': b: = str. Substring (2). Trim; ' C ': c: = str. Substring (2). Trim; ' d ': D: = str. Substring (2). Trim; End; End; End;
List.free; Showmessagefmt ('%s;%s;%s;%s ', [A, B, C, D]); End;