Ok, we have a computer naming convention that our IT guys out in each office are supposed to follow and don't. Well our current leadership wants to crack down on the offenders so I'm writing a script to give us a list of computers in AD that don't match the proposed convention. It started out with my conditionals working great until I tried to strip off the front 5 characters of the computer name and then ASCAN() those front five to see if they're what they're supposed to be but my $var that was supposed to return the substr() results, returned nothing. So I started echoing @ERROR and right after my SubStr() command, @SERROR reports "Next without For!" and @ERROR returns no numeric problem. BUT, if i comment out my SubStr() line, the script runs fine. I looked over my past scripts and I'm pretty sure I'm using SubStr() correctly to get the first five chars. Can anyone see a problem?? Thank you in advance.

Code:
Break On

If Len($day) = 1
$day = '0'+$day
Endif

$day = @MDAYNO
$Computers = GetObject("WinNT://n00b.com")
$Computers.filter = "Computer",""
$OutputFile = 'Bad Computer Names ('+@YEAR+' '+SubStr(@MONTH,1,3)+' '+$day+').csv'
$x = 0

$org = "aew","emdg","eamds","emsg","eces",
"econs","ecs","elrs","esfs","esvs",
"emxg","eamxs","emxs","amog","eog",
"efs","eoss","amu","eas"

If Exist(@ScriptDir + '\' + $OutputFile)
Del @ScriptDir + '\' + $OutputFile
Endif

If Open(1,@ScriptDir +"\"+ $OutputFile,5) = 0
for each $Computer in $Computers
If Instr($Computer.name,'-')
$cArr = Split($computer.name,"-")
If Ubound($cArr) <= 1 AND Ubound($cArr) > 2
$ = WriteLine(1,$Computer.name + @CRLF)
$x = $x + 1
Else
$ = WriteLine(1,$Computer.name + @CRLF)
Endif
$fFive = SubStr($Computer.name,0,4)
If @ERROR <> 0 "Error "+@ERROR+": "+@SERROR
;? $fFive
; If Ascan($org,$five) = -1
Else
$ = WriteLine(1,$Computer.name + @CRLF)
$x = $x + 1
Endif
next
Else
? "Error "+@ERROR+": "+@SERROR
Endif

$ = Close(1)

? 'End: '+$x
get $