#166014 - 2006-08-16 11:19 PM
Error in Expression... need an extra set of eyes...
|
Georges_K
Getting the hang of it
Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
|
Hi guys, Sorry if this question sounds pretty simple (which it usually ends up being so). Please keep in mind, that I'm a novice scripter.
I'm having this problem with an array that I'm trying to create, and I am always getting an "Error in Expression" error when I get to that line. I read the book, and looked up scripts, and I can't seem to figure out what I'm doing wrong. I know the exact line in my script where it's failing...
here's the script:
Code:
Break ON $ = SetOption("NoVarsInStrings",On) $ = SetOption("Explicit",On) Call ("C:\Scripts\kix\CVUSD\udf.kix") Global $un,$ou,$handle,$LINE,$LineCount Dim $a, $answer ? "User? " Gets $un
? "OU? " Gets $ou
EnumerateUsers($un,$ou)
Function EnumerateUsers(Optional $un, Optional $ou) Shell '%COMSPEC% /C dsquery user -limit 0 -name *' + $un + '* -o dn > pathCheck_dn.dat'
Dim $user,$users, $slashed, $last, $first, $myOU, $element, $i, $ouStore, $ouCount Dim $handle $handle=FreeFileHandle() $ = Open($handle,"pathCheck_dn.dat",2) $LINE=ReadLine($handle) Do ; Let's create the Array out of the string in the file, comma delimited $users=Split($LINE,",") ; Scanning for the existence of the ou $element=0 $ouCount=0 For $element=0 to UBound($users) $myOU = AScan($users,$ou,$element,,1); ? "$$myOU: " + $myOU ? "$$ou: " + $ou ? "$$element: " + $element ? "$$users[$element]: " +$users[$element] ? If ($myOU = $element) And InStr($users[$element],"OU") And InStr($users[$element],$ou) ? $users[$element] $ouStore[$ouCount] = $users[$element] $ouCount=$ouCount + 1 EndIf Next ; Getting the LAST NAME, removing the description of the field i.e CN= , and the baskslash to escape the comma $slashed = Right($users[0],Len($users[0]) - Len(Left($users[0],4))) $last = Left($slashed,Len($slashed) - Len(Left($slashed,1))) ; This is the First Name $first = $users[1] ; Print it out ;? $LINE ? $first + " " + $last ? ? "$$ouStore Limit:" UBound($ouStore) For $i = 0 to UBound($ouStore) If $ouStore <> '' "OUs Found: " $ouStore[$i] + Chr(9) EndIf Next ; Read the Next Line $LINE=ReadLine($handle) ; Clean Up Until @ERROR = -1 Close($handle) If Exist("@SCRIPTDIR\pathCheck_dn.dat") Del ("@SCRIPTDIR\pathCheck_dn.dat") EndIf EndFunction
The exact error I'm getting is this: ERROR : error in expression! Script: C:\scripts\kix\CVUSD\Utils\Search.kix Line : 111
I have tried defining the size of the array ($ouStore[500]) just for the heck of it, but that didn't work either.
Any ideas?
p.s: I am aware that are some unhandled situation in this script, I am not nearly done with it yet ... I'm just eager to figure out this array issue first.. Thank you in advance.
_________________________
Network Specialist Chino Unified School District
|
Top
|
|
|
|
#166017 - 2006-08-16 11:59 PM
Re: Error in Expression... need an extra set of eyes...
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Well not even really reviewing your code I get this back from SANITY.UDF
Code:
Warning: Global variable declared as Local. Variable Name: $un In function: EnumerateUsers Referenced on line: 15 Global declared on line: 5
Warning: Global variable declared as Local. Variable Name: $ou In function: EnumerateUsers Referenced on line: 15 Global declared on line: 5
Warning: Global variable declared as Local. Variable Name: $handle In function: EnumerateUsers Referenced on line: 19 Global declared on line: 5
Warning: Undeclared variable. Variable Name: $ In function: Main Referenced on line: 2
Warning: Undeclared variable. Variable Name: $ In function: EnumerateUsers Referenced on line: 20
Warning: Undeclared variable. Variable Name: $myOU: In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $myOU: In function: EnumerateUsers Referenced on line: 31
Warning: Undeclared variable. Variable Name: $ou: In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $ou: In function: EnumerateUsers Referenced on line: 31
Warning: Undeclared variable. Variable Name: $element: In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $element: In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $users In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $element In function: EnumerateUsers Referenced on line: 31
Warning: Variable referenced inside string. Variable Name: $ouStore In function: EnumerateUsers Referenced on line: 48
14 warnings encountered in 65 lines.
|
Top
|
|
|
|
#166025 - 2006-08-17 01:37 AM
Re: Error in Expression... need an extra set of eyes...
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Quote:
btw, doc, just realised that sanity checker is buggy
Well it's not my code. It's Glenn's code, but in discussion about it, he did say that it's not perfect. It's designed to assist you in discovering potential issues in your code.
If you know what you've written is correct then just ignore the output. It's a warning, not a directive.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|