Page 1 of 1 1
Topic Options
#166014 - 2006-08-16 11:19 PM Error in Expression... need an extra set of eyes...
Georges_K Offline
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
#166015 - 2006-08-16 11:29 PM Re: Error in Expression... need an extra set of eyes...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4642
Loc: The Netherlands
Error on line 111 Your script only has 64 lines so is this the entire script? Guess not or there is some kind of typo.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#166016 - 2006-08-16 11:36 PM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Haa ... you know I didn't think about that, I actually took out a bunch of Commented out DEBUG lines, and I'm also using the ASE editor, so it adds some 32 lines of Scripts settings on top which I ommited as well.. so the line number is correct in my editor... but for the record, line 111 does correspond with the, now, red line in the code. (sorry about the confusion)
Top
#166017 - 2006-08-16 11:59 PM Re: Error in Expression... need an extra set of eyes...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
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
#166018 - 2006-08-17 12:06 AM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Hm.. that's a cool UDF, i didn't know about it... let me look into that...
Thanks Doc,
I'll post again if after fixing those, I still have problems with this array.

Top
#166019 - 2006-08-17 12:07 AM Re: Error in Expression... need an extra set of eyes...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
the issue is, you dim $ouStore as normal variable and then try to access it as if it was a array.
Top
#166020 - 2006-08-17 12:12 AM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Would Dim-ing it as $ouStore[] declare it as an array? that didn't seem to work either, even when I declared it as $ouStore[10] ...
Top
#166021 - 2006-08-17 12:23 AM Re: Error in Expression... need an extra set of eyes...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
well, it does work to some point.
but ofcourse, you can't access out side of it's bounds.
nor use array inside strings. obviously.

Top
#166022 - 2006-08-17 12:30 AM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
so, what would be the correct way to assign an array element to another array ....

I guess I'm just not quite clear about that.
As I mentioned before, I am newbie, so I'm trying to learn the ropes here. I do appreciate your patience!

Top
#166023 - 2006-08-17 12:35 AM Re: Error in Expression... need an extra set of eyes...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
well, to get you started, that 500 element dim sounds fitting.

but...
If $ouStore <> ''

you can't test against the whole array.
the element yes.


btw, doc, just realised that sanity checker is buggy.


Edited by Jooel (2006-08-17 12:36 AM)

Top
#166024 - 2006-08-17 12:44 AM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Thanks.
though I looked more into the "variables in string" that you guys (or rather the sanity script). and it's actually incorrect. the "var in strings" that it's finding are ones that I really did put as "$$variable name" to print out the variable name (as a label) for debugging purposes. Thus the line that looks like this:
? "$$myOU: " + $myOU (Sanity is catching "$$myOU" as a var in string, which is incorrect I think)

I know that I still have some issues with some var declarations. (still have some confusion regarding the scope of variables)

Top
#166025 - 2006-08-17 01:37 AM Re: Error in Expression... need an extra set of eyes...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
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
#166026 - 2006-08-17 01:40 AM Re: Error in Expression... need an extra set of eyes...
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
That's cool, thanks guys. I figured out my problem, and the Sanity checker actually did help with it.

Thanks for your assistance.

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 191 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.051 seconds in which 0.026 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