#44084 - 2003-08-15 01:21 AM
How do I make this script continue.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
Hey all, can someone please tell me why the script will not continue to report '? "Reported finds = " $finds ?' at the end of the script. At the moment the idea is to match directory names, from a text file. Then report them to $finds. Oh, itsdoes find matches as it also reports while running.
Thanks to the ppls examples I've used so far.
Phoe.
code:
cls break on $file = "archlist.txt" $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 ? GOSUB "find_dir"
NEXT
:find_dir if len($clientno) <> 7 Exit else $dirno = $clientno endif
$dirfnd = dir("c:\tmp\kix2001\clients\"+$dirno+"*")
if ($dirfnd <> ".") And ($dirfnd <> "..") And len($dirfnd); > 7 And GetFileAttr($basedir+"\"+$name) & 16)
? "Directory found: $dirfnd" ? $finds = $finds+ ", " + $dirfnd ; GOSUB "zip_dir"
else
? "Directory not found: $dirno" ? ; Exit endif Return
:zip_dir $filename = $dirfnd $basedir="c:\tmp\kix2001\clients"
WHILE ($filename <> "") AND (@error = 0) IF ($filename <> ".") AND ($filename <> "..") GOSUB "create_zip" ENDIF $filename=Dir() LOOP ; Exit
:create_zip $cmd=" wzzip -a -ex -rp " $cmd=$cmd+' "$basedir\'+LTRIM(RTRIM($filename))+'.zip" "$basedir\'+LTRIM(RTRIM($filename))+'" ' ; SHELL '%comspec% /c $cmd ' ; <++++++++ ; Return
? "Reported finds = " $finds ?
|
|
Top
|
|
|
|
#44087 - 2003-08-15 02:08 AM
Re: How do I make this script continue.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
Thanks for the prompt reply Lonkero & LLigetfa,
I've look again and removed the goto's and returns. If I remove the NEXT at the bottom it will report $finds in the loop. If I replace the NEXT it will not move on to '? "Reported finds = " $finds ? '
LLigetfa I thought $finds is global as its declaired like $GlobalVariable = 10 and not DIM $LocalVariable $LocalVariable = 10
Phoe
code:
cls break on $file = "archlist.txt" $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 Exit else $dirno = $clientno endif
$dirfnd = dir("c:\tmp\kix2001\clients\"+$dirno+"*")
if ($dirfnd <> ".") And ($dirfnd <> "..") And len($dirfnd); > 7 And GetFileAttr($basedir+"\"+$name) & 16)
? "Directory found: $dirfnd" ? $finds = $finds+ ", " + $dirfnd
else
? "Directory not found: $dirno" ? ; Exit endif
NEXT
? "Reported finds = " $finds ?
|
|
Top
|
|
|
|
#44090 - 2003-08-15 03:02 AM
Re: How do I make this script continue.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
Lonkero,
that was it!!!! Thankyou both so much for helping. Below is what I have ended up with. My next step is to use $finds and output it to a report at the end. Would I be better to use an array to collect the finds or splitting the $finds string?
Phoe.
code:
cls break on $file = "archlist.txt" $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:\tmp\kix2001\clients\"+$dirno+"*")
if ($dirfnd <> ".") And ($dirfnd <> "..") And len($dirfnd); > 7 And GetFileAttr($basedir+"\"+$name) & 16)
? "Directory found: $dirfnd" ? $finds = $finds+ ", " + $dirfnd
else
? "Directory not found: $dirno" ? ; Exit endif
endif NEXT
? "Reported finds = " $finds ?
|
|
Top
|
|
|
|
#44092 - 2003-08-15 04:32 AM
Re: How do I make this script continue.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
Lonkero,
the string could get very long, but I want to save all the reporting of 'finds' and 'not finds' for the end? What would be the best method?
Phoe.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 820 anonymous users online.
|
|
|