Dear,Thanks for your feedback.
We saw the problems:
- $prompt="Copying file... $source_file[$i]" will only interpretate
the variable $i. Array can't be evaluated in a string.
We replace it with:
$prompt="Copying file from... "+$source_file[$i]
- second problem was: we hasn't modify your previous name.
it becomes now:
code:
COPY $dest_file[$i] $backupdir /H ; - make a backup from original -
COPY $source_file[$i] $dest_file[$i] /H ; - copy the new file -
btw:
- we have switch $dest_file and $source_file for readability.
- to check your feedback you have create a directory with contents.
New code:
code:
; **************************************************************************
; ** GIS Updates
; **************************************************************************
CLS
BREAK OFF
;IF (Exist("C:\Jdaodbms\Project") = 1)
IF (Exist("C:\zx1") = 1)
GOSUB main_update_files
ENDIF
RETURN ; - exit script -
:main_update_files
DIM $location, $serverpath, $imagefile, $backupdir
; - source location -
;$serverpath=@lserver+"\netlogon\updates\gis"
$serverpath="c:\zx1"
; - destination locations -
$location="C:\Jdaodbms\Project"
$location="c:\zx2"
;$imagefile="C:\Jdaodbms\Images"
$imagefile="c:\zx2"
$backupdir="$location\Backup"
IF (Exist("$backupdir") = 0)
MD "$backupdir"
ENDIF
;
DIM $number_of_files
$number_of_files=14
DIM $errors
$errors=0
; **************************************************************************
; ** Destination locations
; **************************************************************************
DIM $dest_file[$number_of_files+1]
$dest_file[ 1]="$location\buyu0194.frm"
$dest_file[ 2]="$location\finq0008.frm"
$dest_file[ 3]="$location\basu0060.frm"
$dest_file[ 4]="$location\basu0062.frm"
$dest_file[ 5]="$location\basu0201.frm"
$dest_file[ 6]="$location\blk_m0001.frm"
$dest_file[ 7]="$location\blk_q0001.frm"
$dest_file[ 8]="$location\blk_q0002.frm"
$dest_file[ 9]="$location\blk_u0001.frm"
$dest_file[10]="$location\blk_u0002.frm"
$dest_file[11]="$location\blk_u0003.frm"
$dest_file[12]="$location\bass0089.frm"
$dest_file[13]="$location\capq0003.frm"
$dest_file[14]="$imagefile\blokker1.bmp"
; **************************************************************************
; ** Source locations
; **************************************************************************
DIM $source_file[$number_of_files+1]
$source_file[ 1]="$serverpath\buyu0194.frm"
$source_file[ 2]="$serverpath\finq0008.frm"
$source_file[ 3]="$serverpath\basu0060.frm"
$source_file[ 4]="$serverpath\basu0062.frm"
$source_file[ 5]="$serverpath\basu0201.frm"
$source_file[ 6]="$serverpath\blk_m0001.frm"
$source_file[ 7]="$serverpath\blk_q0001.frm"
$source_file[ 8]="$serverpath\blk_q0002.frm"
$source_file[ 9]="$serverpath\blk_u0001.frm"
$source_file[10]="$serverpath\blk_u0002.frm"
$source_file[11]="$serverpath\blk_u0003.frm"
$source_file[12]="$serverpath\bass0089.frm"
$source_file[13]="$serverpath\capq0003.frm"
$source_file[14]="$serverpath\blokker1.bmp"
; **************************************************************************
DIM $i
$i=1
WHILE ($i <= $number_of_files)
GOSUB update_files
$i=$i+1
LOOP
IF ($errors = 0)
$prompt="All your files are up to date...!"
ELSE
$prompt="All your files are up to date! "+$errors+" errors found."
ENDIF
GOSUB center
SLEEP 1
$prompt=" "
GOSUB center
CLS
RETURN
; **************************************************************************
:update_files
IF (Exist($dest_file[$i]) = 0)
$errors=$errors+1
$prompt="File '"+LCASE($dest_file[$i])+"' not present on client."
GOSUB center
ENDIF
IF (Exist($source_file[$i]) = 0)
$errors=$errors+1
$prompt="File '"+LCASE($source_file[$i])+"' not present on server."
GOSUB center
ENDIF
IF (GetFileTime($dest_file[$i]) <> GetFileTime($source_file[$i])) ; $dest_file[$i] not the same as $source_file[$i]?
$prompt="Copying file from... "+$source_file[$i]
GOSUB center
$prompt=" "
GOSUB center
COPY $dest_file[$i] $backupdir /H ; - make a backup from original -
COPY $source_file[$i] $dest_file[$i] /H ; - copy the new file -
ENDIF
RETURN
; **************************************************************************
:center
COLOR n/n
Box (22,1,24,78,double) ; erase the bar
COLOR w/n
At (23,40-(Len($prompt)/2)) $prompt
SLEEP 1
RETURN
; **************************************************************************
Greetings.