I have a problem concerning manipulation of ASCII text files.
With the help of an entry form, I collect cities:
collection of cities
After finishing the input, I save the filled in data to a text file.
Now there occur some difficulties, if I want to do it in the other
direction: I read an earlier saved file and try to write the content
to the appropriate lines of the entry form.
The shape of the text file could be like this:
Europe Rome Paris
Europe Bucarest Prague
Europe Lissabon Frankfurt
North america San Franzisko New York
North america Los Angeles
North america Toronto Calgary
South america Caracas Lima La Paz Quito
South america Buenos Aires Rio de Janeiro
South america Sao Paolo
In this case, the task would be rather easy:
The user has filled in every line, so you can work with an index:
TEdit 1-3: Europe;
TEdit 4-6: North America
TEdit 7-9: South America
However, the user has the option to leave one or more lines blank, and this makes
(For several reasons, I dont want empty lines in my text file. so I save only
those Edits which contain relevant data.)
So - after saving the input data - the shape of the text file could
be like this, too:
Europe Rome Paris South america Buenos Aires Rio de Janiero South america Sao Paolo
(Here all datas are written to one single line.)
How can I determine now in this case where each continent starts and ends?
How can I write the data to the correct TEdit? Note: It does not matter much,
if I write an European city to TEdit1 or TEdit2 or TEdit3, although it is
nice and logic to start with filling TEdit1. Note that a maximal lenghth of
100 characters must not be exceeded in a single TEdit.
Of course it is forbidden to split one city into 2 lines in the entry form:
I don't allow: TEdit7: Sao
and I don't allow TEdit7: Sao Pao
Any suggestions for a solution?
With kind regards