Re: Witango-Talk: List of files in a folder
I need to list any files in a particular folder and assign the list to an array. Is there a way of doing this in Tango 2000 on a Mac running OS 9? Here's how I did it: First, I set up the webserver to give a directory index, then I use the @URL tag to load the HTTP into a VAR. @ASSIGN NAME=FileListPage Value=@URL Location=http://www.thedomain.com.au/isellit/updatefiles/index.dir; SCOPE=local Then I parsed that VAR to extract all the .TXT files (I know the length so it was easy) in a while loop. Each file name is delimited by [ROW]. While @LOCATE STR=@VAR local$FIleListPage FINDSTR=.TXT !=0 @ASSIGN NAME=CurrPos VALUE=@CALC EXPR='@LOCATE STR=@VAR local$FileListPage FINDSTR=.TXT-11' SCOPE=local @ASSIGN NAME=FileList VALUE='@VAR local$FileList@SUBSTRING STR=@VAR local$FileListPage START=@@local$CurrPos NUMCHARS=15[ROW]' SCOPE=LOCAL @ASSIGN NAME=FileListPage VALUE=@RIGHT STR=@VAR local$FileListPage NUMCHARS=@CALC '@LENGTH STR=@VAR local$FileListPage-@VAR local$CurrPos-15' SCOPE=LOCAL Then I loaded the resulting string as an array into another VAR @ASSIGN NAME=FileListArray VALUE=@ARRAY VALUE=@VAR local$FileList RDELIM='[ROW]' CDELIM='[COL]' SCOPE=LOCAL And removed duplicates using the DISTINCT tag @ASSIGN NAME=DistinctFileListArray VALUE=@DISTINCT ARRAY=local$FileListArray SCOPE=LOCAL The only issue is that the index.dir only returns the first 100 records but that is ok as this task is reiterative until there are no more .txt files. Wayne Irvine Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
Re: Witango-Talk: List of files in a folder
Hey All! The other option is to write a (apple?)script to do a search or directory listing. Then run that as an external action. I believe that @var request$resultset inside the results portion of the external action will contain the console output from the external action, so you could then parse out the the filenames. I'm not sure if there's any easy way to do the parsing. Last time I checked (in about 2000) the @regex tag didn't work well or was buggy or something (I can't remember), so you'll probably have to use a method similar to what Wayne is using to parse out his file. Hope this helps! Cheers, Jonah Simpson - Original Message - From: Wayne Irvine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 19, 2004 12:27 AM Subject: Re: Witango-Talk: List of files in a folder I need to list any files in a particular folder and assign the list to an array. Is there a way of doing this in Tango 2000 on a Mac running OS 9? Here's how I did it: First, I set up the webserver to give a directory index, then I use the @URL tag to load the HTTP into a VAR. @ASSIGN NAME=FileListPage Value=@URL Location=http://www.thedomain.com.au/isellit/updatefiles/index.dir; SCOPE=local Then I parsed that VAR to extract all the .TXT files (I know the length so it was easy) in a while loop. Each file name is delimited by [ROW]. While @LOCATE STR=@VAR local$FIleListPage FINDSTR=.TXT !=0 @ASSIGN NAME=CurrPos VALUE=@CALC EXPR='@LOCATE STR=@VAR local$FileListPage FINDSTR=.TXT-11' SCOPE=local @ASSIGN NAME=FileList VALUE='@VAR local$FileList@SUBSTRING STR=@VAR local$FileListPage START=@@local$CurrPos NUMCHARS=15[ROW]' SCOPE=LOCAL @ASSIGN NAME=FileListPage VALUE=@RIGHT STR=@VAR local$FileListPage NUMCHARS=@CALC '@LENGTH STR=@VAR local$FileListPage-@VAR local$CurrPos-15' SCOPE=LOCAL Then I loaded the resulting string as an array into another VAR @ASSIGN NAME=FileListArray VALUE=@ARRAY VALUE=@VAR local$FileList RDELIM='[ROW]' CDELIM='[COL]' SCOPE=LOCAL And removed duplicates using the DISTINCT tag @ASSIGN NAME=DistinctFileListArray VALUE=@DISTINCT ARRAY=local$FileListArray SCOPE=LOCAL The only issue is that the index.dir only returns the first 100 records but that is ok as this task is reiterative until there are no more .txt files. Wayne Irvine Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
RE: Witango-Talk: List of files in a folder
I've done this several times using Perl, or just a simple shell script Perl runs on EVERY platform, including OS9. Here is an example script - I use this one, and I know it works. I modified it for the .txt search you wanted. Just set the ISTXT environment var in Tango to 1: #!/usr/local/bin/perl # listFiles.pl # Simple program for listing directory contents, usable from within Tango. # In the External Action, you must have the following ENV variables set: # UNIXPATH: The path to the directory you are listing from the root # WEBROOT: Optional root directory substitute from which to begin searching # DIR: 1 if you want to list ONLY directories not files. # ISTAF:1 if you want only to list .TAF files. # ISTXT:1 if you want only to list .TXT files. # The result in Tango will be an array of the resulting filenames or directory names # Written by Jim Kass 2003 if ( $ENV{'DIR'} == 1 ) { $display = qx (/bin/ls -1F $ENV{'WEBROOT'}$ENV{'UNIXPATH'} | grep /); } elsif ( $ENV{'ISTAF'} == 1 { $display = qx (/bin/ls -1 $ENV{'WEBROOT'}$ENV{'UNIXPATH'} | grep .taf); } elsif ( $ENV{'ISTXT'} == 1 { $display = qx (/bin/ls -1 $ENV{'WEBROOT'}$ENV{'UNIXPATH'} | grep .txt); } else { $display = qx (/bin/ls -1 $ENV{'WEBROOT'}$ENV{'UNIXPATH'}); } print $display; -Original Message- From: Jonah Simpson [mailto:[EMAIL PROTECTED] Sent: Sunday, April 18, 2004 11:47 PM To: [EMAIL PROTECTED] Subject: Re: Witango-Talk: List of files in a folder Hey All! The other option is to write a (apple?)script to do a search or directory listing. Then run that as an external action. I believe that @var request$resultset inside the results portion of the external action will contain the console output from the external action, so you could then parse out the the filenames. I'm not sure if there's any easy way to do the parsing. Last time I checked (in about 2000) the @regex tag didn't work well or was buggy or something (I can't remember), so you'll probably have to use a method similar to what Wayne is using to parse out his file. Hope this helps! Cheers, Jonah Simpson - Original Message - From: Wayne Irvine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 19, 2004 12:27 AM Subject: Re: Witango-Talk: List of files in a folder I need to list any files in a particular folder and assign the list to an array. Is there a way of doing this in Tango 2000 on a Mac running OS 9? Here's how I did it: First, I set up the webserver to give a directory index, then I use the @URL tag to load the HTTP into a VAR. @ASSIGN NAME=FileListPage Value=@URL Location=http://www.thedomain.com.au/isellit/updatefiles/index.dir; SCOPE=local Then I parsed that VAR to extract all the .TXT files (I know the length so it was easy) in a while loop. Each file name is delimited by [ROW]. While @LOCATE STR=@VAR local$FIleListPage FINDSTR=.TXT !=0 @ASSIGN NAME=CurrPos VALUE=@CALC EXPR='@LOCATE STR=@VAR local$FileListPage FINDSTR=.TXT-11' SCOPE=local @ASSIGN NAME=FileList VALUE='@VAR local$FileList@SUBSTRING STR=@VAR local$FileListPage START=@@local$CurrPos NUMCHARS=15[ROW]' SCOPE=LOCAL @ASSIGN NAME=FileListPage VALUE=@RIGHT STR=@VAR local$FileListPage NUMCHARS=@CALC '@LENGTH STR=@VAR local$FileListPage-@VAR local$CurrPos-15' SCOPE=LOCAL Then I loaded the resulting string as an array into another VAR @ASSIGN NAME=FileListArray VALUE=@ARRAY VALUE=@VAR local$FileList RDELIM='[ROW]' CDELIM='[COL]' SCOPE=LOCAL And removed duplicates using the DISTINCT tag @ASSIGN NAME=DistinctFileListArray VALUE=@DISTINCT ARRAY=local$FileListArray SCOPE=LOCAL The only issue is that the index.dir only returns the first 100 records but that is ok as this task is reiterative until there are no more .txt files. Wayne Irvine Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf Jim Kass Sr. Web-Applications Developer -- Forestweb: The Source for Industry Intelligence Best Content -- Most Relevant -- Best Delivery http://www.forestweb.com (310) 553 - 0008 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
Re: Witango-Talk: List of files in a folder
There is an example (by Fergal) on the component zone on witango.com on how to do this on Windows and with witango 5...it may point you in the right direction. It works well for me - to get it to work on Mac and T2k I think you'll just need to swap request scope for local, replace the bat files with their mac equivalents and hard code the path to the file list you want (Fergal's file uses @makepath which is a witango 5 feature) Hope this helps --- Wayne Irvine [EMAIL PROTECTED] wrote: Any help on this one? Someone must know how to do it. _ I need to list any files in a particular folder and assign the list to an array. Is there a way of doing this in Tango 2000 on a Mac running OS 9? Wayne Irvine Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf __ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
Re: Witango-Talk: List of files in a folder
There is an example (by Fergal) on the component zone on witango.com Cheers, I'll check it out. I'm currently working on a TAF that loads the index.dir result into a VAR and then parses it. Should be fun. Wayne Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
RE: Witango-Talk: List of files in a folder
I can send you a copy of a T2000 setup for Windows to do this, if that would help. I can't translate to Mac, though. -Original Message- From: Wayne Irvine [mailto:[EMAIL PROTECTED] Sent: Friday, April 16, 2004 1:24 AM To: [EMAIL PROTECTED] Subject: Re: Witango-Talk: List of files in a folder There is an example (by Fergal) on the component zone on witango.com Cheers, I'll check it out. I'm currently working on a TAF that loads the index.dir result into a VAR and then parses it. Should be fun. Wayne Byte Services Pty Ltd http://www.byteserve.com.au/ [EMAIL PROTECTED] Ph 02 9960 6099 Mob 0409 960 609 Fax 02 9960 6088 __ __ TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf