;Set the string for the filename
$UIDINFO = "c:\Codes2b.csv"
;Check it exists
If Exist ($UIDINFO) = 0
MessageBox ("Error1:Consultant ID File Does Not Exist."+ Chr(13)+
"Please contact IT Support on 1234, as you will not be able to log in,"+Chr(13)+
"You will now be logged off this system!.",
"WARNING MESSAGE", 48, 300)
Else
;Check if the file is of a size greater than 0KB
$UIDSIZE = GetFileSize($UIDINFO)
If $UIDSIZE = 0
MessageBox ("Error2:Consultant ID File Is To Small."+ Chr(13)+
"Please contact IT Support on 1234, as you will not be able to log in,"+Chr(13)+
"You will now be logged off this system!.",
"WARNING MESSAGE", 48, 300)
Sleep 10
EndIf
;Open Up The UID File
Dim $objFSO, $objFile, $strLine, $strNewLine
$objFSO = CreateObject("Scripting.FileSystemObject")
$objFile = $objFSO.OpenTextFile($UIDINFO, 1, 1)
While Not $objFile.AtEndOfStream
$strLine = $objFile.ReadLine
$strUser = Split($strLine,",")[0]
If $strUser = @USERID
$uid = $strUser
EndIf
Loop
$objFile.Close
;Count the UID string and ensure its populated
$uid_length = Len($UID)
;If statement that creates a new UID and number
If $uid_length = "0"
$strNewLine = Split($strLine,",")[1]
$strNewLine = CInt($strNewLine)+1
$objFSO = CreateObject("Scripting.FileSystemObject")
$objFile = $objFSO.OpenTextFile($UIDINFO, 8, 1)
$objFile.WriteLine(@USERID+","+CStr($strNewLine))
$objFile.Close
Else
Set "CONS_CODE=$UID"
? "Found name with UID: " + $uid
EndIf
EndIf