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