PDA

View Full Version : Populate listbox from text file


Waldo
08-19-2008, 09:29 AM
I have examined just about every listbox example that I can find and I am still stuck. What I want to do is populate a listbox from a text file. The text file will have two items per line.

The first item in the line is the text that I want to appear in the listbox. The second item is the filename to be opened when the user double clicks the item [they all are either a pdf or doc file]. I can delimit the text file with any symbol and I have using a "|" as this was the easiest symbol to use from the sub-system that is generating the text file.

Text File Example [myFiles.txt]:
John Smith|12345.pdf
Wilbur Wood|45433.doc
Jane Doe|5677.pdf
Martha Brown|56666543.doc


I have figured out how to search for the "|" character using LUA....What I can't figure out is how to script that everything to the left of the "|" is the item to display in the text box and everything to the right of the "|" is the full file name.

I know this is probably a stupid question, but after 5 hours of examining every lisbox that I could get my hands on....well, I still can't get it to work....Maybe I can't proceed using this logic process or I have made it much too complicated. :huh Thanks for your patience...:yes

Ulrich
08-19-2008, 10:40 AM
Hello,

please have a look at the example I made for you.

Ulrich

Waldo
08-19-2008, 03:27 PM
Thank you very, very much....This certainly gets me started. I was using the String mid function, but I wasn't smart enough to add 1 or subtract 1 from the separator...Golly, I have much to learn. Thanks again. :yes :)

Waldo
10-03-2008, 02:59 PM
upeters,
I have a question regarding your example. When I populate the text file, how do I write the path to the file location? My application will end up on either a CD or a flash drive. I have no way of knowing what the assigned drive letter will be. So I need to "discover" how to write a "dynamic" path in the text file so that AutoPlay will find the file regardless of the assigned drive letter to the CD or flash drive in the end user's computer.

I hope my question makes sense...I have been working on trying to make this work for the last six hours....I need to step away as I am missing the obvious...any advice is greatly appreciated. Take care.
Waldo.

Ulrich
10-04-2008, 09:45 AM
Hello Waldo,

when you publish your project, you will have a CD_Root folder with autorun.exe in it, and a folder called AutoPlay. Under this AutoPlay folder you will have subfolders for every type of file used in your project.

Your documents could be placed in the Docs subfolder. In my former project I did not supply you with my original files, because those were my shortcuts for premium access to internet radio, and it was only an example... But in your case, it would make more sense to point to the Docs subfolder, and place there the files you are going to ship with your project.

When building the path to the file, you may supress the drive letter, and the current drive will be assumed where autorun.exe is being executed. All you will have to do is correct the full path to the files. In my example, I will point to the Docs subfolder, like this:
Eurodance|AutoPlay\Docs\eurodance.pls

I have modified my original example: Now it shouldn't matter where (on which drive letter) you run this example, by simply clicking one of the 16 music styles available in the ListBox, you should start hearing internet radio with that specific style (unless your registered media player is unable to handle the streaming format I have chosen).

Ulrich

Waldo
10-04-2008, 08:25 PM
upeters,
Thank you for the example...I will spend my Sunday afternoon working to digest your example...I really do appreciate your efforts and posting this revised example file...thank you!!! Waldo