unit DLists;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    ListBox1: TListBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
        InFile : TextFile;
        fname, InString : string;
begin
        fname := 'smaloc.txt';
        AssignFile(Infile,fname);
        Reset(Infile);
        While not Eof(Infile) do
        Begin
        Readln(Infile,InString);
        ListBox1.Items.Add(InString);
        end;
        CloseFile(Infile);
        end;


procedure TForm1.ListBox1Click(Sender: TObject);
 var
fileData : string;
latData : string;
lonData : string;
prefixData : string;
begin
//gets the highlighted line
fileData := ListBox1.Items.Strings[ListBox1.ItemIndex];
latData := copy(fileData,30,7);   //get degrees north/south latitude
lonData := copy(fileData, 38,8);  //get degrees west longitude
prefixData:= copy(fileData,1,29);  //get the prefix and area

 Edit1.text := latData;    //put the info into the screen
 Edit2.text := lonData;    //put the info into the screen
 Label2.caption := prefixData;   //put the info into the screen

end;

end.
