Thanks Howard,

that solved it, but the main script with a long string, built of directory names fails when I try to write it to a log.

Error: expression to long
Line: 128

Which is: $string1 = substr("$string",1,$spot-1)

If I have it collect less directories it works.

Complete code.

code:
 

; 15th August 2003
; Client File Archiver
;
;
cls break on

; Adjust ip for your office client directory
; use "X:" "\\10.1.2.20\root\"

$file = "c:\kix\archlist.txt" ; Input file. Relies on input file of archlist.txt with a single 7 digit number per line.
$ziparchdir = "c:\kix\zip" ; Directory to place ziped files
$zipbasedir= "c:kix\clients\" ; Directory where all client directories exist
$archlog = "c:\kix\log.txt" ; Archive stats and log file.
$countf = 0


$ = open(1,$file)
$line = readline(1)

;start with an initial array size of 5
dim $array[5]
$count = 0

while not @error

; let check to make sure you are not over the current array size,
; if we are increase the array size by 10

if $count = ubound($array)
redim preserve $array[ubound($array)+10]
endif

;add a line to the array
$array[$count] = $line

;increase our counter by 1
$count = $count + 1

;get the next line of text
$line = readline(1)

loop

$ = close(1)

;ok, time to trim back to array size to the actual size of the data.
if $count > 0
redim preserve $array[$count - 1]
else
;hmmm looks like no information was loaded... make sure your file
;is avaliable
$array = ""
endif

;just a simple check to show your data in the array...
for each $clientno in $array
; ? $clientno ?

if len($clientno) = 7
$dirno = $clientno

$dirfnd = dir("c:\kix\clients\"+$dirno+"*")

if ($dirfnd <> ".") And ($dirfnd <> "..") And len($dirfnd); > 7 And GetFileAttr($basedir+"\"+$name) & 16)
? "Directory found: $dirfnd" ?
$finds = $finds+ ", " + $dirfnd

;zip_dir
$filename = $dirfnd
; Create Zip
$cmd=" wzzip -a -ex -rp -m "
$cmd=$cmd+' "$zipbasedir\'+LTRIM(RTRIM($filename))+'.zip" "$zipbasedir\'+LTRIM(RTRIM($filename))+'" '
? $cmd
;SHELL '%comspec% /c $cmd '

; Move completed zip file to archive
$cmdmv=' move /y "$zipbasedir\*.zip" "$ziparchdir" '
;SHELL '%comspec% /c $cmdmv '

else
; ? "Directory not found: $dirno" ?
$nofinds = $nofinds+ ", " + $dirno
endif
endif
NEXT

? "Directories found = " $finds ?
? "Directories not found = " $nofinds ?

If Open( 3 , $archlog , 5 ) = 0

if len($finds) > 0
$Report = $finds
?? "Client Files Found: "
$wl = WriteLine( 3 , "Archive Log File Created: " + @TIME + " " + @DATE + @CRLF )
$wl = WriteLine( 3 , "Client Files Found: " + @CRLF )
GOSUB "Report"

if len($nofinds) > 0
$Report = $nofinds
?? "The following client file number did not match: "
$wl = WriteLine( 3 , @CRLF + @CRLF + "The following client file number did not match: " + @CRLF )
GOSUB "Report"
?? "Counted $count client file numbers in archlist.txt "
$wl = WriteLine( 3 , @CRLF + "Counted $count lines in archlist.txt " + @CRLF + @CRLF + @CRLF )
GOSUB "End"
else
GOSUB "End"
endif
else
GOSUB "End"
endif

ELSE
BEEP
? "failed to open file, error code : [" + @ERROR + "]"
ENDIF

:Report
$string = $Report
$delim = ","
$repcount = 0
; ? $string
$spot = instr($string,$delim)
; ? "What does Spot = " $spot ?
if $spot = 1

$string1 = substr("$string",1,$spot-1)
? $string1
$wl = WriteLine( 3 , $string1 + @CRLF )

While $spot <> 0
$repcount = $repcount + 1
$string = substr("$string",$spot+1,len("$string")-$spot)
$spot2 = instr($string,$delim)
$string2 = substr("$string",1,$spot2-1)
;? "Spot = " $spot ?
;? "Spot2 = " $spot2 ?
$spot = instr($string,$delim)
? $string2

If $string2 <> 0
$wl = WriteLine( 3 , $string2 + @CRLF )
endif
Loop
$string ?
$wl = WriteLine( 3 , $string + @CRLF )
$wl = WriteLine( 3 , "File Count: " + $repcount + @CRLF )
; ?$repcount?
else
$string
$wl = WriteLine( 3 , $string + @CRLF )
GOSUB "End"
endif
Return

:End