I write to a textFile.. i now i want read the names in the txt, and put inside the one ComboBox... e assumes the names...
on Show
Code:result = TextFile.ReadToString("E:\\teste.txt"); result1 = ComboBox.AddItem("ComboBox3", result, "")
Professional Software Development Tools
I write to a textFile.. i now i want read the names in the txt, and put inside the one ComboBox... e assumes the names...
on Show
Code:result = TextFile.ReadToString("E:\\teste.txt"); result1 = ComboBox.AddItem("ComboBox3", result, "")
in your text file, make each item you want in your combobox / listbox as a new line.
item1
item2
item3
etc...
then when you import the text file to a table.
if you get a listing of numbers in the combobox, then change the j to an i on the lineCode:tResult = TextFile.ReadToTable("E:\\teste.txt"); for i, j in tResult do ComboBox.AddItem("ComboBox3", j,"" ) end
hope that helpsCode:ComboBox.AddItem("ComboBox3", i, "")
chris
Here is an example of populating (filling up) a ComboBox with the contents from a text (.txt) file.
Note: That the contents is saved as a table (for each line of text in the file it gets an index ("i" in my example below), e.g. 1, 2, 3 and the line of text is stored in the value ("v" in my example below), e.g. "Hey all".
This code was put in the On Show event area for my example:
Code:tblTextFile = TextFile.ReadToTable("C:\\Documents and Settings\\bubba\\Desktop\\test.txt") for i,v in tblTextFile do ComboBox.AddItem("ComboBox1", v) end
Intrigued
It's interesting too... to look back in time when I was looking for answers like those myself in 2003, early 2004. Though I tried to ask as little as possible and learn on my own, when folks like Worm and the I.R. dev/support team did help me with something, boy what a relief and I still appreciate those times of help.
I feel, "the person that thinks he/she knows it all, still has twice as far to go as the one that knows they do not know it all." (random blurb ;-))
Intrigued
stickck and Intrigued, thanks for your help... really works...
yes.. is the other way to same result.. thanks..![]()
Last edited by sermak; 03-15-2008 at 09:34 AM.
i change my comment, because i see with more attention and your code is not complicated... we complicated everything when the things is so easy... lol![]()
Intrigued hey can you explain a little how it works
if each line is a index but where dose it get the list show to the user
i feel like a twit now as some other things way hire then this i can do bit
a lot of think just go out of my head can you do me a simple example when
you get some free time please.
thanks.![]()
Np.... I'm still learning myself.
Lets say you have three lines in a plain old text (.txt) file:
Hey all
How is the weather your way?
Lets go and do some ATVing!
Now, lets take a look at that code I posted earlier today:
I hope that helps and was what you were after.Code:-- This line takes each line in the text file and puts it into an AMS (LUA) table. And each line of text has a index number (1 for the first line, 2 for the second line, and 3 for the third line). tblTextFile = TextFile.ReadToTable("C:\\Documents and Settings\\bubba\\Desktop\\test.txt") -- In the 'for..do' portion of the loop, we are going to do something for each -- line of text. 1= index number and Hey all=value (i,v in my loop) -- 1 Hey all -- 2 How is the weather your way? -- 3 Lets go and do some ATVing! for i,v in tblTextFile do -- Now, we add the value (v=Hey all, etc.) to the combobox object -- for each pass through the loop. -- The loop goes three times because there is only three lines of text ComboBox.AddItem("ComboBox1", v) end
Intrigued
I learned from the best.... You guys here on the forum! My first question ever on the forum was extremely stupid now looking back. Corey helped me out back then. Thanks for the kudos Intrigued
One of the best things about AMS is that your can get the same results with several different scripts.
Here's another way to fill your combobox...
Code:results = TextFile.ReadToTable(_SourceFolder.."\\AutoPlay\\Docs\\Stuff.txt") min = 1 max = Table.Count(results) for count = min, max do ComboBox.AddItem("ComboBox1", results[count], "") end
or even just keep the table in LUA format in your txt file and use the LoadScript like this...
your text file will have this in it....
Code:tList = {} tList[1] = "First Item" tList[1] = "Middle Item" tList[1] = "Last Item"
Or this...
Then use this to run the lua script into your app....Code:tList = {"First Item", "Middle Item", "Last Item"}
A LUA file is just a TXT file with LUA Scripts in it. You can open them with Wordpad / Notepad.Code:Application.LoadScript(_SourceFolder.."\\AutoPlay\\Docs\\Your_LUA_Script_File.LUA")
The cool thing about this last option (Application.LoadScript()) is that you can add other script to the file later on without having to change your app.
I guarantee that there are other ways yet to do this.
Later
Chris