PDA

View Full Version : Add to listbox from search string


nirus
02-14-2005, 08:58 PM
I am trying to search a folder for all files then list them in a list box when the page is shown.

findsource = File.Find("AutoPlay\\Koader Bin\\source", "*.", false, false, nil);
ListBox.AddItem("sourcebox", findsource, "");


It builds but I get the error:
On Show, Line 12: Argument 2 must be of type string

Not sure why findsource is not a string

I had it done in Autoplay 4.0 and it looked like this:

File.Search ( %Files%, ;;, *, 0, 0, 0, 0, 1, %SrcDir%\AutoPlay\Koader Bin\source, 0, Searching for Files, Loading List of available programs, 0 )
ListBoxObject.AddFiles ( Installers, 0, , %Files%, ;;, 2, 1 )
File.Search ( %zipfiles%, ;;, *, 0, 0, 0, 0, 1, %SrcDir%\AutoPlay\Koader Bin\zip\, 0, Searching for Files, Loading List of available programs, 0 )
ListBoxObject.AddFiles ( zip, 0, , %zipfiles%, ;;, 2, 1 )


- Any help .. point me in the right direction or something?
Thank you
Nirus

nirus
02-14-2005, 09:06 PM
when I try:


findsource = File.Find("AutoPlay\\Koader Bin\\source", "*.", false, false, nil);
ListBox.AddItem("sourcebox", "\findsource", "");


The list box has 1 value that says:
indsource

but there is a box or an unknown character or whatever you want to call in it infront of indsource

-Brent

nirus
02-14-2005, 09:11 PM
When I try recurseing I get the same thing... indsource.

Not sure If I need to be recursing or not. I am not searching subfolders

-Brent

Intrigued
02-14-2005, 09:13 PM
Brent, in AMS 5 the variable you have assigned to the Find.Files action returns a table. For example, to get at the first row of data (index and data) you can use this synatx:

findsource[1]

... the [n] represents a row in the table that is index starting at the number 1, and then increments by one by default from there.

To get all the files you need to setup a loop to work with the table that is findsource

The help section (F1) in AMS 5 can give you some examples, you can find some on this forum via way of the Search link (see it up and to the right on this page), and you can check over at amsuser.com, which is a site I created that stores in an easy to access (and free, like here) list of projects mostly culled from this site and those gracious enough to share freely their small projects. Where at least one has an example I am sure will help.

Sincerely,

Worm
02-14-2005, 09:23 PM
Brett from IR posted an example that may be very useful for you to look at.

http://www.indigorose.com/forums/showthread.php?t=7545&highlight=explorer

nirus
02-15-2005, 01:26 AM
ahhh... So it returns it in an array. This will explain a lot :)

Now all I need to do is find some type of for each. Maybe I can do sometype of get_file.findmaxnum to find the total number of items and then loop through them stepping I by 1. Thanks for the help. Ill check out that example.

Much appriciated
Brent

Intrigued
02-15-2005, 09:43 AM
nirus, take a look at this I.R. member's example. It shows you how to do this very thing.

http://www.indigorose.com/forums/showthread.php?t=3432&highlight=add+files+listbox

:yes

Roboblue
02-15-2005, 09:54 AM
Here is a quick one to populate list box from a folder, if that is all you want to do.