View Full Version : Help please w/ this table thing
Bruce
12-26-2003, 11:35 PM
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);
Corey
12-27-2003, 12:07 AM
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 (http://www.indigorose.com)
TJ_Tigger
12-27-2003, 08:44 AM
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
Bruce
12-27-2003, 01:02 PM
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. :rolleyes:
Thx Corey, I'll wait for the CD.
TJ_Tigger
12-27-2003, 01:13 PM
A basic table with have an index number associated with a value or data. Like this
index
TJ_Tigger
12-27-2003, 01:16 PM
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.
Bruce
12-30-2003, 09:01 PM
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????
Bruce
12-31-2003, 06:46 PM
Looks like Tiggs away for a bit... Anyone else?
Thx
Bruce
12-31-2003, 07:09 PM
Oops here's the project, very simple but it's bouncing off my head.
Corey
12-31-2003, 07:41 PM
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 (http://www.indigorose.com)
Bruce
01-01-2004, 03:36 AM
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.???
Corey
01-01-2004, 03:57 AM
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 (http://www.indigorose.com)
Bruce
01-01-2004, 02:43 PM
WHAAAAA! I've been pounding my head for days over a *.*! Ahhhh the dispair! What a noob!
Thx Corey!
Corey
01-01-2004, 04:59 PM
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 (http://www.indigorose.com)
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.