PDA

View Full Version : Problem that needs solving - please help!!



SteevieNiteHeat
08-01-2009, 12:40 PM
I am making an address book in AMS and I am stuck, have tried the examples Ive found, but not managed to sort it right.

I have a combo box listing various statuses (ie Mr, mrs etc) and then seperate input boxes for the rest of the information, this is then saved to a text file and it appears like this:


Mr Donnald Duck
45 Duckpond Lake
Riverside
Riverborough
AB1 2CD
01234567890
01234567890
email.address.here@here.com

When this is saved, it saves the file with the first & last name ie Donnald Duck.file BUT the problem I am having is then loading this file back and putting the different lines back in the boxes, as I want a view / edit sort of thing so I guess I need to know how to read each seperate line from the file and then intert it in the right boxes?

If I just do a textfille.readtostring, it all displays right in a paragraph, so i know the file is loading right, but how to seperate the lines?

Please help as I am going to share this with the AMS community when its completed to say thankyou for all the help Ive recieved!

Ulrich
08-01-2009, 12:47 PM
Why don't you read the file back using TextFile.ReadToTable()? You could then access easily each line and work with the data you retrieved.

Ulrich

SteevieNiteHeat
08-01-2009, 01:54 PM
Thanks for your fast reply Ulrich, I think I have done that?!?!
Here is what I have so far:
[CODE]blTextFile = TextFile.ReadToTable("AutoPlay\\AdbDta\\"..FileName..".adb");

for n=1, Table.Count(tblTextFile) do
tblLine = DelimitedStringToTable(tblTextFile[n], ",")
if Table.Count(tblLine) == 4 then
ComboBox.SetText("ComboBox1", tblLine[1]);
Input.SetText("Address1", tblLine[2]);[
end
end /CODE]

Im getting myself into a right muddle with the code! :(

JimS
08-01-2009, 02:38 PM
Give this a try :yes

SteevieNiteHeat
08-02-2009, 04:34 AM
Thank you Ulrich & JimS for your help, and here as promised is the app I built, please feel free to change it in anyway you wish, if nothing else, it can be used as a base for others!

One problem I did find however, when I added a new person, it didnt show up in the list, so I wanted to do a trick I did on another project, whereby putting a file.runsameprogram.exe and then application.exit which worked perfectly on my other app, is this a bug in dialog.ex??

Anyway, here it is and I hope you all have fun with it :)