Answer the question
In order to leave comments, you need to log in
How to parse a text editor in delphi?
There is a textbook, there are book titles, authors, and the number of pages. It is necessary to load the data from the textbook into an array of records. The idea is this, I save the file into a variable with the ShortString type, I run through the text and when there is a space, then there is another record property (For example, the title of the book went after the author) I almost implemented it, but I got stuck at the moment when I would take the string to save the author / book title. Just write like I have A[d].Author:= A[d].Author + output[c] ? It just seems to me that this is somehow all through crutches, maybe I'm doing something wrong?
Record code:
TBook = record
Pages: integer;
Title: ShortString;
Author: ShortString;
end;
Load function code from file to records array
procedure TForm1.LoadBtn1Click(Sender: TObject);
var output: ShortString;
begin
assignfile(LoadF, 'LoadF.txt');
Reset(LoadF);
for d:=0 to Length(A) - 1 do
begin
Read(LoadF, output);
for c:=0 to Length(output) do
begin
if (output[c] = ' ') then count:= count + 1;
if (count = 1) then A[d].Author :=
end;
Read(LoadF, A[d].Author);
end;
closeFile(LoadF);
end;
Answer the question
In order to leave comments, you need to log in
procedure TMainForm.ButtonClick(Sender: TObject);
var
men: TMatchCollectionEnumerator;
begin
men := TRegEx.Matches('one two three', '\w+').GetEnumerator;
while men.MoveNext do
begin
men.Current.Value
end;
men.Free;
end;
how can I add records to an existing array, because I don’t know how many there will beUse a dynamic array (
SetLength
).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question