Some Things I have tried.
Remember Your: Test/demo ExtractWord
ref: DataProblems Maybe
https://forum.lazarus.freepascal.org/index.php/topic,45150.0.html I Started it and pointed it a the MstRegions file.
On the first record it Decomposed 11 fields. (That''''s really a nice little utility program).
But all the rest of the records were good.
Just a thought: You also wrote a procedure to get rid of the UTF8 BOM file and save it to a ASCII file.
So I'm thinking about taking the ExtractWord Demo and add the procedure to it.
That way I could bring up a file, see if it is extracting ok, if not then save it as an ASCII.
All of this data comes from one source = Apt.Dat, 7.0 Million lines.
A program reads that and produces the ByAirports.txt.
Apt.dat 7.9 Million
ByAirports.txt 36,000 +- Extrated from Apt.dat file
MstRegions.txt Just an extract of ByAirports.txt records without and 'Nil'
CountryRegions.txt Extracted from ByAirports.txt
In the program MstRegions I load in the left hand listbox a list of all the airport ICAO's (KPHX, KLAS ect.) extracted from MstRegions.txt when I load MstRegions.txt.
In the middle of the screen, Top istbox I load ByAirports.txt 36,000 +- record. And in the lower middle box I load MstRegions.txt 9,600+-.
In the far right Lstbox I load CountryRegions.txt which was extracted from MstRegions. this was done in a seperat program.
In order to do what I really want to do I need a clean file with no 'Nil''s in any record and all records accounted for.
So I took the ByAirports.txt file and extracted record with no 'Nil's and made MstRegions.txt.(seperate program).
Now I can determine the Country field of each record that is 'Nil' in two way's.
First Way:
Region field isn't Nil but has a valid code determined from the right listbox then I can plug in the country. This doesn't always work because some countries (i.e US, China, Russia all have multi Regional ). But countries have 1 region.
Second Method:
Use the Haverstine formula. Take the record with the Nil country Listbox2 Click on it and it becomes the target record (Displayed in the TEdit contro at the top of the screen).
Click on a MstRegions record (Lower Middle Listbox). It's record will be displayed a TEdit located in the middle of the screen.
Now click on the Calc Dist button.
It will give you the distance between the two airports. (Worked properly I think).
I checked against Online site.
Record: [00E][6781690][Nil][Nil][Nil][33.49421222][-111.64124806] which
is a few records down in the top listbox is good one to try.
Click on it.
In the bottom Listbox MstRegions try and find the record:
[AZ66][7175661][Mesa][United States][K2][33.340547222][-109.494466667] and click on it.
It's going to tell you that you are 124 mi from Mesa Arizona.
The web says: 4227 North 88th Street, Mesa, Arizona 85207, United States.
So I may have a bug in my haverstine routing.
Under the middle listboxs there is a TEdit labeled Country with a small button next to it. Press the small button and it changes the target record Country to United States.
With the listboxes and data I can write code to fill in a lot of the 'Nil'.
After running the program I can save a new MstRegions file.
It has a few bugs I need to fix and resolve the data issue.
NOTE:----------------------------------------------------
So after writing this up I got to thinking.
All data comes from Apt.Dat. I generate a 36,000 ByAirports.txt file in a seperate program.
I change the MstRegions program to load the ByAirports.txt and then populate the Listbox1, Listbox3, and Listbox5 from Listbox2.
So far I no longer get the error on the first record in listbox2.