Hello everyone!

I have been frying my brain with this problem for several days now. Please bear with me while I try and explain what I need to do.

I have a file with a list of ID numbers and email addresses. Here is an example of the file:

1030,fred@hotmail.com
1030,john@hotmail.com
1030,
1041,
1041,
1043,fred@hotmail.com
1043,
1144,
1144,fred@hotmail.com
1150,
1150,
1150,
1150,
1150,

What I need the script to do is tell me which IDs have no associated email address. In this example the answer is 1041 and 1150.

Here's the code so far:

Code:
  

$Directory = "H:\kix\Reports\"
$TempFile = ($Directory + "errors.txt")
Del $TempFile /c
$ID1 = "1"
Open(1,$TempFile)

$ID = ReadLine(1)
If @error = 0
While $ID <> 0 AND @ERROR = 0

? "Line is " $ID


$IDArray = Split($ID,",") ;Extract data from missing.txt
$Count = 0
For Each $Element IN $IDArray
Select
Case $Count = 0
$IDx = $Element ;Set student ID
Case $Count = 1
$email = $Element ;Set email address
Case $Count = 2
? "ERROR in file"
EndSelect
$Count = $Count + 1

Next


? "ID= " $IDx
? "email= " $email



If Len($email) = 0
? "Setting flag"
$Flag = "1"
Else
$Flag = "0"
EndIf

? "Flag = " $Flag


If $ID1 = "1" OR $IDx = $ID1
$ID1 = $IDx
? "ID1= " $ID1
Else
If $Flag = "1"
? $IDx " has No email!"
EndIf

EndIf


? ""



$ID = ReadLine(1)
Loop





Please excuse all the comments - it's a work in progress.

I'm getting my knickers in a twist with this one! Any advice on how to proceed with this will be most appreciated.

Thanks in advance for all your help,

Glenn