Page 1 of 1 1
Topic Options
#195822 - 2009-09-09 07:14 PM Array/Expression error has me stumped...
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
I get this error using the UDF below, and Tail() & WriteTail() UDFs...Any ideas...???

Error : Error in expression:...this type of array not supported in expressions.!
Script: c:\backup\desktop\testtest.kix
Line : 14
 Code:
;Declarations
	SetTitle ("Logging in to the network...")
	SetConsole ("SHOW")
	SetConsole ("MAXIMIZE")
	Break ON
	Global $LOGFILE
	$LOGFILE="c:\cherron.log"
;************************************************************************
;                                                                       *
; Begin Logon Script                                                    *
;                                                                       *
;************************************************************************
:READFILE
	ReadFile($LOGFILE,,-450)
	:ENDREADFILE
Sleep 5
;************************************************************************
;                                                                       *
; Production KIX UDFs - Do not place any code below this line...!!!     *
;                                                                       *
;************************************************************************
; UDF = ReadFile - Returns the last X lines of a file                   *
;************************************************************************
Function ReadFile($_file,optional $_delim,optional $_amount)
	DIM $
	$=$_file
	$_delim=""+$_delim
	$_amount=0+$_amount
	$_file=FreeFileHandle()
	If 0=$_file Exit 1 EndIf
	If Open($_file,$) Exit 2 EndIf
	$=""	
	Do $=$+ReadLine($_file)+CHR(10) Until @ERROR
	$ReadFile=Split(Left($,Len($)-2),CHR(10))
	$=Close($_file)
	$=""
	If $_amount<0
	 For $_file=$_amount+UBound($ReadFile)+1 To UBound($ReadFile)
	  $=$+$ReadFile[$_file]+CHR(10)
	 Next
	 $ReadFile=Split(Left($,Len($)-1),CHR(10))
	EndIf
	If $_amount>0
	 For $_file=0 To $_amount-1
	  $=$+$ReadFile[$_file]+CHR(10)
	 Next
	 $ReadFile=Split(Left($,Len($)-1),CHR(10))
	EndIf
	If $_delim $ReadFile=Join($ReadFile,$_delim) EndIf
	Exit 0
EndFunction

Top
#195826 - 2009-09-09 07:35 PM Re: Array/Expression error has me stumped... [Re: Fletch9871]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Is it this UDF?
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84660
ReadFile returns an array
 Code:
$Lines = ReadFile($LOGFILE,,-450)
for each $Line in $Lines
	? $Line
Next

Top
#195839 - 2009-09-10 09:02 AM Re: Array/Expression error has me stumped... [Re: Witto]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
In fact the UDF optionally returns either an array or a string.

Try this:
 Code:
ReadFile($LOGFILE,@CRLF,-450)+@CRLF

Top
#195867 - 2009-09-10 10:42 PM Re: Array/Expression error has me stumped... [Re: Richard H.]
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
Thanx Richard...That worked.

Now I just need to write the 450 lines back out to the file.

Top
#195869 - 2009-09-10 11:02 PM Re: Array/Expression error has me stumped... [Re: Fletch9871]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
If you read the file into an array you can write it back line by line by using a For - Each loop and the Writeline function.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#195873 - 2009-09-11 08:46 AM Re: Array/Expression error has me stumped... [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Mart
If you read the file into an array you can write it back line by line by using a For - Each loop and the Writeline function.


And if you read it in a string you don't need the loop, a single WriteLine() will do.

Top
#195874 - 2009-09-11 09:40 AM Re: Array/Expression error has me stumped... [Re: Richard H.]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I looked a bit more at the script, and the ReadFile() UDF had some nasty bugs in it.

I've patched it up and added some code to write the data out. There are two versions below, the first handles the ReadFile() data as an array, the second as a simple string.

Study the two and make sure that you understand how and why they are different.

Follow up with more questions if you need to.

Version 1 - Data from ReadFile() as an array:
 Code:
Break ON
$=SetOption("Explicit","ON")

;Declarations
$=SetTitle ("Logging in to the network...")
$=SetConsole ("SHOW")
$=SetConsole ("MAXIMIZE")

Dim $fh,$sLogFile,$sNewFile
Dim $sData,$sLine

$sLogFile="c:\cherron.log"
$sNewFile="c:\newfile.txt"

;************************************************************************
;                                                                       *
; Begin Logon Script                                                    *
;                                                                       *
;************************************************************************

; Read data from log file as an array.
$sData=ReadFile($sLogFile,,-450)

; Display Data
For Each $sLine in $sData
	$sLine+@CRLF
Next

; Now write the data to a new file.
$fh=FreeFileHandle()
If $fh > 0
	If Open($fh,$sNewFile,1+4)
		"Error opening file '"+$sNewFile+"' for output: ["+@ERROR+"] "+@SERROR+@CRLF
	Else
		For Each $sLine in $sData
			$=WriteLine($fh,$sLine+@CRLF)
		Next
		$=Close($fh)
		$fh=0
	EndIf
EndIf

"Hit a key to continue: " Get $ @CRLF

;************************************************************************
;                                                                       *
; Production KIX UDFs - Do not place any code below this line...!!!     *
;                                                                       *
;************************************************************************
; UDF = ReadFile - Returns the last X lines of a file                   *
;************************************************************************
Function ReadFile($_file,optional $_delim,optional $_amount)
	DIM $,$i,$fh,$sData,$sLine

	$_amount=CInt($_amount)

	$fh=FreeFileHandle()
	If 0=$fh Exit 1 EndIf
	If Open($fh,$_file) Exit @ERROR EndIf
	$sLine=ReadLine($fh)
	While Not @ERROR 
		$sData=$sData+Chr(10)+$sLine
		$sLine=ReadLine($fh)
	Loop
	$sData=Split(Substr($sData,2),CHR(10))
	$=Close($fh)

	Select
	Case $_amount<0
		For $i=Max($_amount+UBound($sData)+1,0) To UBound($sData)
			$ReadFile=$ReadFile+Chr(10)+$sData[$i]
	 	Next
		$ReadFile=Split(Substr($ReadFile,2),CHR(10))
	Case $_amount>0
		For $i=0 To Max($_amount-1,UBound($sData)
			$ReadFile=$ReadFile+Chr(10)+$sData[$i]
		Next
		$ReadFile=Split(Substr($ReadFile,2),CHR(10))
	Case DEFAULT
		$ReadFile=$sData
	EndSelect

	If VarType($_delim) $ReadFile=Join($ReadFile,$_delim) EndIf

	Exit 0
EndFunction

Function Max($a,$b) $Max=IIf($a>$b,$a,$b) Exit 0 EndFunction
Function Min($a,$b) $Max=IIf($a<$b,$a,$b) Exit 0 EndFunction


Version 2 - Data from ReadFile() as a string
 Code:
Break ON
$=SetOption("Explicit","ON")

;Declarations
$=SetTitle ("Logging in to the network...")
$=SetConsole ("SHOW")
$=SetConsole ("MAXIMIZE")

Dim $fh,$sLogFile,$sNewFile
Dim $sData

$sLogFile="c:\cherron.log"
$sNewFile="c:\newfile.txt"

;************************************************************************
;                                                                       *
; Begin Logon Script                                                    *
;                                                                       *
;************************************************************************

; Read data from log file as an array.
$sData=ReadFile($sLogFile,@CRLF,-450)

; Display Data
$sData+@CRLF

; Now write the data to a new file.
$fh=FreeFileHandle()
If $fh > 0
	If Open($fh,$sNewFile,1+4)
		"Error opening file '"+$sNewFile+"' for output: ["+@ERROR+"] "+@SERROR+@CRLF
	Else
		$=WriteLine($fh,$sData+@CRLF)
		$=Close($fh)
		$fh=0
	EndIf
EndIf

"Hit a key to continue: " Get $ @CRLF

;************************************************************************
;                                                                       *
; Production KIX UDFs - Do not place any code below this line...!!!     *
;                                                                       *
;************************************************************************
; UDF = ReadFile - Returns the last X lines of a file                   *
;************************************************************************
Function ReadFile($_file,optional $_delim,optional $_amount)
	DIM $,$i,$fh,$sData,$sLine

	$_amount=CInt($_amount)

	$fh=FreeFileHandle()
	If 0=$fh Exit 1 EndIf
	If Open($fh,$_file) Exit @ERROR EndIf
	$sLine=ReadLine($fh)
	While Not @ERROR 
		$sData=$sData+Chr(10)+$sLine
		$sLine=ReadLine($fh)
	Loop
	$sData=Split(Substr($sData,2),CHR(10))
	$=Close($fh)

	Select
	Case $_amount<0
		For $i=Max($_amount+UBound($sData)+1,0) To UBound($sData)
			$ReadFile=$ReadFile+Chr(10)+$sData[$i]
	 	Next
		$ReadFile=Split(Substr($ReadFile,2),CHR(10))
	Case $_amount>0
		For $i=0 To Max($_amount-1,UBound($sData)
			$ReadFile=$ReadFile+Chr(10)+$sData[$i]
		Next
		$ReadFile=Split(Substr($ReadFile,2),CHR(10))
	Case DEFAULT
		$ReadFile=$sData
	EndSelect

	If VarType($_delim) $ReadFile=Join($ReadFile,$_delim) EndIf

	Exit 0
EndFunction

Function Max($a,$b) $Max=IIf($a>$b,$a,$b) Exit 0 EndFunction
Function Min($a,$b) $Max=IIf($a<$b,$a,$b) Exit 0 EndFunction

Top
#195884 - 2009-09-11 10:23 PM Re: Array/Expression error has me stumped... [Re: Richard H.]
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
Well I thought I had this working until the script encounters a file with less than 450 lines...They I get the Array/Expression error.

If no log file exists it gets created and the script runs fine. The second time the script runs it only has about 18 lines and the Array/Expression error pops up. I get the same Array/Expression error when I try the Tail() UDF under the same circumstances.

My goal is to "prune/tail" my logs so they stay at a manageable size. At this point I'm completely frustrated...LOL.

Any pointers...???

BTW I was testing with Richards code above...Thanx again Richard...!!!

Top
#195885 - 2009-09-11 10:46 PM Re: Array/Expression error has me stumped... [Re: Fletch9871]
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
Here is the original complete script (without Richards code) minus the UDFs. Like Richards examples it works fine unless the file is less than 450 lines. Sorry the code is so wide...I plan to get it condensed once I have it working.

 Code:
;Version 0.37
;Declarations
	SetTitle ("Logging in to the network...")
	SetConsole ("SHOW")
	SetConsole ("MAXIMIZE")
	$=SetOption("Explicit","ON")
	Break ON
	Global $LOGFILE,$sLogFile,$sNewFile,$UPTIME,$ND_R,$GC_R,$HD_R,$WS_R,$CS_R,$RD1_C,$RD2_C,$RD3_C,$IM1_C,$IM2_C,$IM3_C,$WM1_R,$WM1_C,$WM2_R,$WM2_C,$P1,$P2,$ANI_R
	$LOGFILE = "\\xxxxxxxx\LogonLogs$\@WUSERID.log"
	$UPTIME = ((@TICKS/1000)/60)/60
	$ND_R=23		;NETWORKDETECT MESSAGES ROW COORDINATE
	$GC_R=24		;GROUPCHECKANIMATION ROW COORDINATE & MESSAGES
	$HD_R=25		;HOMEDRIVEANIMATION ROW COORDINATE & MESSAGES
	$WS_R=26		;WEBSENSEANIMATION ROW COORDINATE & MESSAGES
	$CS_R=27		;CLOCKSYNCANIMATION ROW COORDINATE & MESSAGES
	$RD1_C=22		;RETURN DATA 1 COLUMN COORDINATE
	$RD2_C=55		;RETURN DATA 2 COLUMN COORDINATE
	$RD3_C=35		;RETURN DATA 3 COLUMN COORDINATE
	$IM1_C=5		;INFORMATION MESSAGES COLUMN 1 COORDINATE
	$IM2_C=40		;INFORMATION MESSAGES COLUMN 2 COORDINATE
	$IM3_C=10		;INFORMATION MESSAGES COLUMN 3 COORDINATE
	$WM1_R=30		;WELCOME MESSAGE 1 ROW COORDINATE
	$WM1_C=5		;WELCOME MESSAGE 1 COLUMN COORDINATE
	$WM2_R=32		;WELCOME MESSAGE 2 ROW COORDINATE
	$WM2_C=5		;WELCOME MESSAGE 2 COLUMN COORDINATE
	$P1=0.5		;PAUSE BETWEEN ANIMATION CHANGES
	$P2=1.0		;PAUSE BETWEEN ANIMATION CHANGES
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv;
; Begin Logon Script code                                                       ;
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv;
:START
:PRUNELOGFILE
	$DATA = ReadFile($LOGFILE,,-450)
	DEL $LOGFILE
	WriteFile($LOGFILE,$DATA)
	LogMsg("**************************************************")
	:ENDPRUNELOGFILE
:LOGONBOX
	Color R+/N Box(0,0,34,75,DOUBLE)
	:ENDLOGONBOX
:TEXT
	Color Y+/N
	AT(2,3) "Attention! - Atención! - Achtung! - Attenzione! - Aandacht! - Atenção!"?
	AT(4,3) "Please do NOT attempt to start any applications until this window has"?
	AT(5,3) "automatically closed. The Clean Access Agent is scanning your computer"?
	AT(6,3) "for McAfee antivirus updates and Microsoft Patches."?
	AT(8,3) "Outlook, Internet Explorer, PeopleSoft, Alchemy, etc will not function"?
	AT(9,3) "properly until this process has completed."?
	AT(11,3) "If this window remains open for more than 5 minutes, please call the"?
	AT(12,3) "Helpdesk at: 555.555.1212"?
	AT(14,$IM1_C) "Date:" AT(15,$IM1_C) "Script launch:"? AT(16,$IM1_C) "System uptime:"? AT(17,$IM1_C) "Current user:"?
	AT(14,$IM2_C) "Workstation:"? AT(15,$IM2_C) "IP address:"? AT(16,$IM2_C) "MAC address:"? AT(17,$IM2_C) "Logon server:"?
	AT(19,$IM1_C) "Windows version:"? AT(21,$IM1_C) "Password expires:"?
	AT($ND_R,$IM3_C) "Detecting network:"?
	AT($GC_R,$IM3_C) "Logon group:"?
	AT($HD_R,$IM3_C) "Mapping home drive:"?
	AT($WS_R,$IM3_C) "Starting WebSense:"?
	AT($CS_R,$IM3_C) "Synchronizing clock:"?
	:ENDTEXT
:LOGONINFO
	Color G+/N
	AT(14,$RD1_C) @DATE											LogMsg("Script Launch Date:	@DATE")
	AT(15,$RD1_C) @TIME											LogMsg("Script Launch Time:	@TIME")
	AT(16,$RD1_C) $UPTIME " Hours"										LogMsg("System uptime:		@TIME - $UPTIME Hours")
	AT(17,$RD1_C) @WUSERID											LogMsg("Current user:		@TIME - @WUSERID")
	AT(14,$RD2_C) @WKSTA											LogMsg("Workstation:		@TIME - @WKSTA")
	AT(15,$RD2_C) @IPADDRESS0										LogMsg("IP address:		@TIME - @IPADDRESS0")
	AT(16,$RD2_C) @ADDRESS											LogMsg("MAC address:		@TIME - @ADDRESS")
	AT(17,$RD2_C) @LSERVER											LogMsg("Logon server:		@TIME - @LSERVER")
	AT(19,25) @PRODUCTTYPE " - " @CSD									LogMsg("Windows version:	@TIME - @PRODUCTTYPE - @CSD")
	Color C+/N AT(21,25) (60 - @PWAGE)" Days...!!!"							LogMsg("Password age:		@TIME - @PWAGE days")AT(21,25) (60 - @PWAGE)" Days...!!!"
	:ENDLOGONINFO
:OSDETECTION
	If @PRODUCTTYPE == "Windows XP Professional"
		GoSub "GROUPCHECK"
	Else GoSub "CLOCKSYNC"
	:ENDOSDETECTION
:GROUPcHECK
	DIM $HOMEDRIVE,$FILESERVER
	$ANI_R = $GC_R
	If InOU ("CarneysPoint") = 1 
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Carneys Point - Chambers"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("CedarBay") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Cedar Bay"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Charlotte") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Charlotte"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("CottageGrove") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Cottage Grove"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Hopewell") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Hopewell - James River"
		GoSub "HOMEDIR"
		EndIf		
	If InOU ("Indiantown") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT ($GC_R,$RD3_C) "Indiantown"
		GoSub "HOMEDIR"
		EndIf	
	If InOU ("Logan") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Logan"
		GoSub "HOMEDIR"
		EndIf		
	If InOU ("Northampton") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Northampton"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Northampton Fuels (Huber)") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Northampton Fuels - Huber"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("PlainsEnd") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Plains End"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Portsmouth") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Portsmouth - Virginia Leasing"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Rathdrum") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Rathdrum"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Richmond (Spruance)") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Richmond - Spruance"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("RockyMount (Edgecombe)") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Rocky Mount - Edgecomb"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Scrubgrass") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Scrubgrass"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("SEGS") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "SunRay - SEGS"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Selkirk") = 1
		$HOMEDRIVE = H:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Selkirk"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("VaRegional") = 1
		$HOMEDRIVVE = ?
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "VA Regional Office"
		$ANI_R = $HD_R
		GoSub "ANIMATION"
		Color R+/N AT($HD_R,$RD3_C) "No Home Drive mapped"
		GoSub "WEBSENSE"
		EndIf
	If InOU ("VaWarehouse") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "VA Regional Warehouse - PartsCo"
		GoSub "HOMEDIR"
		EndIf
	If InOU ("Whitewater") = 1
		$HOMEDRIVE = U:
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		GoSub "ANIMATION"
		AT($GC_R,$RD3_C) "Whitewater"
		GoSub "HOMEDIR"
		EndIf
	:NOOU
		$FILESERVER = xxxxxxxx
		GoSub "NETWORKDETECT"
		Color R+/N AT($GC_R,$RD3_C) "No Logon Group detected"					LogMsg("Logon group:		@TIME - Error: No Logon Group detected - OU not found")
		$ANI_R = $HD_R
		GoSub "ANIMATION"
		Color R+/N AT($HD_R,$RD3_C) "No Home Drive mapped"					LogMsg("Mapping home drive:	@TIME - Error: No Home Drive mapped - OU not found")
		GoSub "WEBSENSE"
		:ENDNOOU
	:ENDGROUPCHECK
:NETWORKDETECT
	DIM $COUNTER1
	For $COUNTER1 = 1 To 25 Step 1
		Color R+/N AT($ND_R,$RD3_C) "Please wait. Connecting to the network." AT ($ND_R,$RD3_C) ""
		If Ping ($FILESERVER,0) = 0
			Color Y+/N AT($ND_R,$RD3_C) "Please wait. Connecting to the network."AT ($ND_R,$RD3_C) ""
			Sleep 2
			Else
				GoTo "CONNECTED"
		EndIf
		Next
		:NOTCONNECTED
			Color R+/N AT($ND_R,$RD3_C) "Network not connected                  "
															LogMsg("Detecting network:	@TIME - Error: Network not connected")
			GoSub "CALLHELPDESK"
			:ENDNOTCONNECTED
		:CONNECTED
			Color G+/N AT($ND_R,$RD3_C) "Network connected                      "
															LogMsg("Detecting network:	@TIME - Network connected")
		Return
			:ENDCONNECTED
	:ENDNETWORKDETECT
:HOMEDIR
	$ANI_R = $HD_R
	Use $HOMEDRIVE /DELETE
		GoSub "ANIMATION"
		Use $HOMEDRIVE "\\$FILESERVER\homedirs$\@USERID"
		If @ERROR <> 0
			Color R+/N AT($HD_R,$RD3_C) "No Home Drive mapped"
															LogMsg("Mapping home drive:	@TIME - Error: No Home Drive mapped")
			GoSub "WEBSENSE"
		Else AT($HD_R,$RD3_C) $HOMEDRIVE" Drive mapped on "$FILESERVER
															LogMsg("Mapping home drive:	@TIME - $HOMEDRIVE Drive mapped on $FILESERVER")
		EndIf
	:ENDHOMEDIR
:WEBSENSE
	$ANI_R = $WS_R
	GoSub "ANIMATION"
	Run "@LSERVER\netlogon\logonapp.exe http://XXX.XXX.XXX.XXX:12345 /Copy /dhcp"
		If @ERROR <> 0
			Color R+/N AT($WS_R,$RD3_C) "WebSense failed"					LogMsg("Starting WebSense:	@TIME - Error: WebSense failed")
			GoSub "CLOCKSYNC"
		Else AT($WS_R,$RD3_C) "WebSense started"							LogMsg("Starting WebSense:	@TIME - WebSense started")
	:ENDWEBSENSE
:CLOCKSYNC
	$ANI_R = $CS_R
	GoSub "ANIMATION"
	SetTime "XXXXXXXX"
		If @ERROR <> 0
			Color R+/N AT($CS_R,$RD3_C) "Clock not synchronized"				LogMsg("Synchronizing clock:	@TIME - Error: Clock not synchronized")
			GoSub "WELCOME"
		Else AT($CS_R,$RD3_C) "Clock synchronized"						LogMsg("Synchronizing clock:	@TIME - Clock Synchronized")
	:ENDCLOCKSYNC
:WELCOME
	Color G+/N
	AT($WM1_R,$WM1_C) "You are now connected to the Cogentrix Network."			LogMsg("Welcome message1:	@TIME - You are now connected to the Cogentrix Network.")
	Color Y+/N
	AT($WM2_R,$WM2_C) "Have a nice day "@FULLNAME"...!!!"						LogMsg("Welcome message2:	@TIME - Have a nice day @FULLNAME...!!!")
	GoSub "TIMER"
	:ENDWELCOME
:CALLHELPDESK
	Color R+/N AT($GC_R,$RD3_C) "No Logon Group detected"						LogMsg("Logon group:		@TIME - Error: Network not connected")
		     AT($HD_R,$RD3_C) "No Home Drive mapped"						LogMsg("Mapping home drive:	@TIME - Error: Network not connected")
		     AT($WS_R,$RD3_C) "WebSense failed"							LogMsg("Starting WebSense:	@TIME - Error: Network not connected")
		     AT($CS_R,$RD3_C) "Clock not synchronized"						LogMsg("Synchronizing clock:	@TIME - Error: Network not connected")
															LogMsg("Helpdesk message1:	@TIME - Unable to connect to the network.")
															LogMsg("Helpdesk message2:	@TIME - Please call the Helpdesk: 704.672.2999")
	For $COUNTER2 = 1 To 60 Step 1
		Color R+/N AT($WM2_R,$WM2_C) "     Unable to connect to the network."
		AT($WM2_R,$WM2_C) "            Please call the Helpdesk: 555.555.1212"
			Sleep $P2
		Color Y+/N AT($WM2_R,$WM2_C) "     Unable to connect to the network."
		AT($WM2_R,$WM2_C) "            Please call the Helpdesk: 555.555.1212"
			Sleep $P2
		Next
		GoSub "START"
	:ENDCALLHELPDESK
:ANIMATION
	Color G+/N AT($ANI_R,$RD3_C) "|" Sleep $P1 AT($ANI_R,$RD3_C) "/" Sleep $P1 AT($ANI_R,$RD3_C) "-" Sleep $P1 AT($ANI_R,$RD3_C) "\" Sleep $P1
	Return
	:ENDANIMATION
	:TIMER
	Sleep 2
	:ENDTIMER
:END
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
; End Logon Script code - Do not place or change any code below this line...!!! ;
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;

Top
#195897 - 2009-09-14 09:38 AM Re: Array/Expression error has me stumped... [Re: Fletch9871]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
As I said in my last post the ReadFile() UDF that you are using has some nasty bugs in it. One of the things it doesn't handle is when you ask for a number of lines and the file is shorter.

You can replace the broken ReadFile() UDF with the one in my example, it works in a compatible manner. You'll need the Max() function as well.

You've got some other problems with the code.

First, get rid of the GoSub's - they're horrible and not needed since UDF's were introduced into KiXtart.

Second, I'm sure that you've got at least one If without EndIf. It actually works as the code is now, but it will bite you later.

Don't GLOBAL variables which have a local scope. Again, it will bite you when you least expect it.

Top
#195949 - 2009-09-18 04:35 PM Re: Array/Expression error has me stumped... [Re: Richard H.]
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
Richard,

Thanx for the help to date. Sorry I've been unable to work on this in the past week or so...other fires to put out.

I did use your ReadFile()UDF. It gave me the same issues as the one in the library. I'm working on getting rid of the GoSub's. This is my first script so I'm learning as I go. It's not always apparent to me how to script around the GoSubs, but I'm doing my best. I fixed the EndIFs, there were indeed a few missing. As far as the Global variables go...I guess I need to do some more reading on them. The Global variables that I have set are used throughout the script. I guess I don't under stand what Global variables should really be used for...Back to the drawing board.

chris

Top
#195954 - 2009-09-18 08:35 PM Re: Array/Expression error has me stumped... [Re: Fletch9871]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Chris,

There's a Sanity UDF that I wrote that finds common problems, like mismatched or missing quotes, parens, and makes sure paired commands like If/EndIf, While/Loop, Function/EndFunction and the like are matched properly. It really helps find common issues. The latest version even creates a paired-function report, showing the line # where each pair starts and ends.

The KixDev package on my web site is a UDF resolver that has the latest Sanity release. Even if you don't use the UDF Library and resolving function, renaming your script to "myscript.TXT" and running "KGEN MYSCRIPT" will generate all the variable use and function pairing reports and create MYSCRIPT.KIX.

GoSubs can be directly replaced with functions in most cases. The big exception is that you should pass the data to the function rather than relying on all variables being global. Functions can return the modified data or a message/result code to the calling routine.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#195974 - 2009-09-21 02:59 PM Re: Array/Expression error has me stumped... [Re: Glenn Barnas]
Fletch9871 Offline
Fresh Scripter

Registered: 2008-12-05
Posts: 6
Loc: USA
Glenn...Thanx for the tips...Hopefully I'll get a chance to work on the script this week. I'll post my progress as I go.

Chris

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
0 registered and 381 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.062 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

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