Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014

    Help please w/ this table thing

    Ok...
    I am trying to gaze into a folder (On the CD) "Plugs" that has many other folder that I'm trying to get the names of. These names will be placed into a ListBox to then be double clicked and used. Below is what I thought the code should look like, where I'm I going wrong?



    --Look in the folder "Plugs" and get all the names of the folders.
    result = Folder.Find("AutoPlay\\Plugs", "*.*", true, nil);
    --Make a empty table called "zip".
    zip = {};
    --inserts the folder names from the variable "result" into the zip table.
    Table.Insert(zip, 1, result);
    --Grabs all the folder names from the table and adds them to a variable called "folders".
    folders = Table.Concat(zip, ";", 1, TABLE_ALL);
    --places the results of "folders" to be viewed in a ListBox called "plugs2".
    result = ListBox.AddItem("plugs2", "", folders);

  2. #2
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi Bruce, I'm sure one of the programmers can explain this more precisely than me but I just thought I'd let you know there's a training CD coming out which focuses almost entirely just on functions and tables and the real world usage thereof. It takes you from zero to 60. The CD starts off as though you've never even heard of tables or functions and by the time it's done you will feel very comfortable with using them, i.e. you will understand what they are, what they can do, and how to make them do those things.

    So anyhow that'll be soon, very soon. Keep posted, but don't try to tag me down on a date. All I can say is soon. That may mean a week, it may mean a month, I can't say for sure, but I know it will be soon. So I hope that'll help. I figure it should at least be a very good reference for people to keep handy, i.e. when you need to remember how to write a function to write dynamic table rows you can just click on that chapter and watch the video and in 5 minutes you'll have it done...

    I'll make sure to provide sample code for all the functions too so that you can just use my scripts rather than write your own if you prefer, i.e. to write dynamic table rows you would simply (Pro Version Only) use the Application.RunScript action and point it at the included script.

    Happy turkey week El Guapo.

    Corey Milner
    Creative Director, Indigo Rose Software

  3. #3
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Bruce,

    You are making things a little too difficult with tables. Tables are very easy to work with and great for storing data. The data you have is already in a table, I don't see the need to put it in another table. Also remember you can use a for loop to enumerate the items in the table and perform some action on them each in turn.

    --Look in the folder "Plugs" and get all the names of the folders.
    zip = Folder.Find("AutoPlay\\Plugs", "*.*", true, nil);
    --Enumerate the items and add them to a listbox.
    for index,folder in zip do
    ListBox.AddItem("plugs2", "", folder);
    end

    I have not tested the code in AMS, just typed it here from what you had. The for loop will go through each index in the table it will add that item to the listbox.

    HTH

  4. #4
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Thanks Tigg,
    It's the "for index,folder in zip do" that I'm having the issue with.
    My problem is I can't visualize it, I'm one of those. :

    Thx Corey, I'll wait for the CD.

  5. #5
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    A basic table with have an index number associated with a value or data. Like this

    index

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    A basic table with have an index number associated with a value or data. Like this


    index value
    1 C:\folder1
    2 C:\folder2
    3 C:\folder3
    4 C:\folder4
    5 C:\folder5
    6 C:\folder6

    When you use the for loop to enumerate the table like this:

    for index,value in zip do
    ListBox.AddItem ("plugs2", "", value);
    end

    You are telling AMS to go through each index in the table take the value and add it to the listbox. The help guide has some great examples for this.

  7. #7
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Tigg, first off thank you very much for your help!

    The line:
    --Enumerate the items and add them to a listbox.
    for index,folder in zip do

    I get an error: On Show, Line 15: Attempt to call a nil value.
    This line: for index,folder in zip do... is on line 15 B.T.W.

    What am I missing????

  8. #8
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Looks like Tiggs away for a bit... Anyone else?

    Thx

  9. #9
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Oops here's the project, very simple but it's bouncing off my head.
    Attached Files

  10. #10
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Bruce, here is a sample project which uses Tigg's code. It prompts you for a folder and then adds all the folders (recursively) in that folder to a listbox. Let me know if you still need help.

    Corey Milner
    Creative Director, Indigo Rose Software
    Attached Files

  11. #11
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    Corey, thank you very much!
    I'm still having the same issue and the same error as above.
    As I mentioned in the beginning of this thread, I'm looking for folders that are in "Plugins" on this CD, not from the end users own choice.
    I added this to your code: result = Folder.Find("AutoPlay\\Plugins", "*.*", true, nil);

    I then get the same error as stated above. What is it that result = Folder.Find("AutoPlay\\Plugins", "*.*", true, nil); causes for index,folder in myFolders do
    to take a dump and get this: On Show, Line what ever: Attempt to call a nil value.???

  12. #12
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    I think you're getting strings and tables mixed up plus you don't use a period when you wild card folders, i.e. use "*" not "*.*" only use "*.*" when you are wildcarding files. Anyhow, here's an attached sample project which lists all the folders in the AutoPlay/Plugins folder. As you can see it's super easy to do once you get the hang of the syntax, hang in there:

    Corey Milner
    Creative Director, Indigo Rose Software
    Attached Files

  13. #13
    Join Date
    Jun 2001
    Location
    California
    Posts
    2,014
    WHAAAAA! I've been pounding my head for days over a *.*! Ahhhh the dispair! What a noob!


    Thx Corey!

  14. #14
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hee. That's one of the things I love about computers. You could have 50 of the worlds top programmers make you a 3 million line code sequence and if one tiny semi colon is out of place the whole dang thing is broken. I love that.

    Corey Milner
    Creative Director, Indigo Rose Software

Posting Permissions

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