Page 1 of 1 1
Topic Options
#125380 - 2004-08-19 05:59 PM Array Refrence Problem
Trox Offline
Fresh Scripter

Registered: 2002-09-17
Posts: 34
Loc: St. Petersburg, FL
I am running the following script fine, but when it reaches the end of the UID.TXT file, I get an ARRAY REFRENCE ERROR. The script doesn't seem to understand that there is no more lines to process in the txt file.

Code:
If NOT Open(1,"\\spghmbrsrv02\soft$\UID.txt")
If NOT Open(2,"\\spghmbrsrv02\soft$\UIDFail.txt",5) ;1 for Create file and 4 for open in write mode = 5
$UID=Split(ReadLine(1),"~")
$USERNAME=$UID[0] ;6-1-1 UID
$USRNAME=$UID[1] ;3-4 UID
While $UID[0]
Color w+/n
?" Moving files from "Color y+/n"$USERNAME "Color w+/n"to "Color y+/n"$USRNAME"
?" "
;Move "\\spghmbrsrv01\private$\$USERNAME" "\\spghmbrsrv01\private$\$USRNAME" /h/s
If @ERROR > 0
Color r+/n
?"Failed!"
WriteLine (2,$UID+Chr(13)+Chr(10)) ;writes the failed pc to the pcfaillist.txt
Else
Color g+/n
?"Done!"
EndIf
$UID=Split(ReadLine(1),"~")
$USERNAME=$UID[0] ;6-1-1 UID
$USRNAME=$UID[1] ;3-4 UID
Loop
$=Close(1)
$=Close(2)
EndIf



Thanks in advance for any help you can give ~ Trox
_________________________
Thanks ~ Trox John Wayne's not dead - he's frozen. And as soon as we find the cure for cancer we're gonna thaw out the duke and he's gonna be pretty pissed off! ~Dennis Leary~

Top
#125381 - 2004-08-19 06:13 PM Re: Array Refrence Problem
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Just a hint before we give the real answer.

This line is always true so there is no reason for the script to end.

While $UID[0]

Answer typically has to do with errorlevel checking.

Top
#125382 - 2004-08-19 06:21 PM Re: Array Refrence Problem
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
You're trying to access the array before you check to see if you are at the end of the file. Try this (not tested)

Code:

If NOT Open(1,"\\spghmbrsrv02\soft$\UID.txt")
If NOT Open(2,"\\spghmbrsrv02\soft$\UIDFail.txt",5) ;1 for Create file and 4 for open in write mode = 5
$UID=Split(ReadLine(1),"~")
While @error = 0
$USERNAME=$UID[0] ;6-1-1 UID
$USRNAME=$UID[1] ;3-4 UID
Color w+/n
?" Moving files from "Color y+/n"$USERNAME "Color w+/n"to "Color y+/n"$USRNAME"
?" "
;Move "\\spghmbrsrv01\private$\$USERNAME" "\\spghmbrsrv01\private$\$USRNAME" /h/s
If @ERROR > 0
Color r+/n
?"Failed!"
WriteLine (2,$UID+Chr(13)+Chr(10)) ;writes the failed pc to the pcfaillist.txt
Else
Color g+/n
?"Done!"
EndIf
$UID=Split(ReadLine(1),"~")
Loop
$=Close(1)
$=Close(2)
EndIf
Endif




Also, have you come across any that have failed yet, because this line doesn't look like it will work since you're trying to write an array instead of a string.

Code:

WriteLine (2,$UID+Chr(13)+Chr(10)) ;writes the failed pc to the pcfaillist.txt


_________________________
Eric

Top
#125383 - 2004-08-19 06:28 PM Re: Array Refrence Problem
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Dang Maciep.... you only let him wait it out for 8 minutes with the hint.
Top
#125384 - 2004-08-19 06:33 PM Re: Array Refrence Problem
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Would that always be true? what if UID[0] = ""

Code:

$array = split("")
while $array[0]
? $array[0]
loop



And sorry about the 8 minutes, i'm feeling helpful today.
_________________________
Eric

Top
#125385 - 2004-08-19 07:54 PM Re: Array Refrence Problem
Trox Offline
Fresh Scripter

Registered: 2002-09-17
Posts: 34
Loc: St. Petersburg, FL
Thanks for the help and no, I haven't gotten an error yet but thanks for pointing the problem out.

_________________________
Thanks ~ Trox John Wayne's not dead - he's frozen. And as soon as we find the cure for cancer we're gonna thaw out the duke and he's gonna be pretty pissed off! ~Dennis Leary~

Top
#125386 - 2004-08-20 09:40 AM Re: Array Refrence Problem
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wonder what error you are waiting for...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.068 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org