Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 12 of 12

Thread: Why dont work?

  1. #1
    Join Date
    Feb 2008
    Posts
    146

    Why dont work?

    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, "")

  2. #2
    Join Date
    Feb 2004
    Location
    Cowfields of Germany
    Posts
    617
    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.
    Code:
    tResult = TextFile.ReadToTable("E:\\teste.txt");
    for i, j in tResult do
       ComboBox.AddItem("ComboBox3", j,"" )
    end
    if you get a listing of numbers in the combobox, then change the j to an i on the line
    Code:
    ComboBox.AddItem("ComboBox3", i, "")
    hope that helps

    chris

  3. #3
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    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

  4. #4
    Join Date
    Feb 2004
    Location
    Cowfields of Germany
    Posts
    617
    Quote Originally Posted by Intrigued View Post
    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
    There you go!

    two answers at the same time with the same results

    chris

  5. #5
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    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

  6. #6
    Join Date
    Feb 2008
    Posts
    146
    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.

  7. #7
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Quote Originally Posted by sermak View Post
    stickck and Intrigued, thanks for your help... really works.

    Intrigued, i put in my project the code that stickck show me.. because i dont no why i cant understand very well you code.. sorry, but thanks for you give other solution for my problem
    No problem and I undestand. Which ever you feel comfortable with and ultimately gets the job completed properly.

    *tips hat to stickck* :-)
    Intrigued

  8. #8
    Join Date
    Feb 2008
    Posts
    146
    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

  9. #9
    Join Date
    Jul 2007
    Posts
    1,512
    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.

  10. #10
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    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:

    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
    I hope that helps and was what you were after.
    Intrigued

  11. #11
    Join Date
    Jul 2007
    Posts
    1,512
    Quote Originally Posted by Intrigued View Post
    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:

    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
    I hope that helps and was what you were after.



    Thanks that really dose help might have to play around this at some
    point.



    top dollor

  12. #12
    Join Date
    Feb 2004
    Location
    Cowfields of Germany
    Posts
    617
    Quote Originally Posted by Intrigued View Post
    *tips hat to stickck* :-)
    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...

    Code:
    tList = {"First Item", "Middle Item", "Last Item"}
    Then use this to run the lua script into your app....

    Code:
    Application.LoadScript(_SourceFolder.."\\AutoPlay\\Docs\\Your_LUA_Script_File.LUA")
    A LUA file is just a TXT file with LUA Scripts in it. You can open them with Wordpad / Notepad.

    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

Similar Threads

  1. ANSI To UNICODE Is Finished!
    By coderanger in forum AutoPlay Media Studio 6.0
    Replies: 7
    Last Post: 08-13-2007, 09:27 AM
  2. Does Autorun MAX Work on Macs?
    By Adam in forum Autorun MAX! 2.1 FAQ
    Replies: 0
    Last Post: 08-29-2006, 12:50 PM
  3. Having problems getting installer frontend to work
    By Scott Lawrence in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 07-24-2006, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts