prpldodge Posted March 22, 2004 Share Posted March 22, 2004 I have a script that gets this error: Line0: $bkdate= $nt[1] & "/" & $nt[2] & "/" & $nt[0] &"at " &$nt[3] &":"& $nt[4] &":"& $nt[5] $bkdate= $nt^ERROR Error: Subscript used with non-Array Variable. It used to work but I do not know what changed. Originaly I did not declare the variables, I added the DIM statments but it had no effect. Alan here is the script ; This program backups the speed shift data from the Win server to the city hall server dim $nt[5][5] dim $ot[5][5] dim $file dim $bkdate dim $ndate dim $odate $nt = FileGetTime("d:\Speed shift data\schedule1.wcs", 0) $ot = FileGetTime("\\city_hall\data\users\plceschd\isispeed\schedule1.wcs", 0) $bkdate= $nt[1] & "/" & $nt[2] & "/" & $nt[0] &"at " &$nt[3] &":"& $nt[4] &":"& $nt[5] If Not @error Then $ndate = $nt[1] & $nt[2] & $nt[0] & $nt[3] & $nt[4] & $nt[5] ; MsgBox(0, "Creation Time of schedule1.wcs", $ndate ) EndIf If Not @error Then $odate = $ot[1] & $ot[2] & $ot[0] & $ot[3] & $ot[4] & $ot[5] EndIf If $ndate > $odate then FileCopy("d:\Speed shift data\schedule1.wcs", "\\city_hall\data\users\plceschd\isispeed\schedule1.wcs",1) EndIf $results = $ndate - $odate $file = FileOpen("d:\Speed shift data\backup log.txt", 1) FileWriteLine($file, $bkdate & @LF) ;MsgBox(0, "Creation Time of schedule1.wcs", $Results ) $results = $ndate - $odate ;MsgBox(0, "Creation Time of schedule1.wcs", $Results ) Link to comment Share on other sites More sharing options...
Valik Posted March 22, 2004 Share Posted March 22, 2004 You appear to be creating a multi-dimensional array, then trying to access it as if it were a single dimension array. Try: Dim $nt[5] Dim $ot[5] Also, arrays start at 0, not 1. The last element is size-1, not size. So in an array with 5 elements, the elements are 0 - 4, not 1 -5. That will need changed, also. Link to comment Share on other sites More sharing options...
Valik Posted March 22, 2004 Share Posted March 22, 2004 Ooops, I see that you are using FileGetTime, which creates its own array. You need to check to make sure FileGetTime returned correctly before you try to access the elements of the array. Also, its not necessary to Dim the array first since FileGetTime will create on for you. Link to comment Share on other sites More sharing options...
prpldodge Posted March 24, 2004 Author Share Posted March 24, 2004 Corrected array statement but it did not change anything. If i change the paths of the file to work on my local computer it works fine. it seems to be a problem with the file (schedule1.wcs). This file may be open when the script runs. What kind of problem does this create? Is there a better command to use when a file maybe in use at the time the script is run? Alan Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now