Use a Dictionary:
Option Explicit
Dim dicSeen : Set dicSeen = CreateObject("Scripting.Dictionary")
Dim aFakeLog : aFakeLog = Split("f f a b a c d e f a b")
Dim sToken
WScript.Echo Join(aFakeLog)
WScript.Echo "--------------"
For Each sToken In aFakeLog
If Not dicSeen.Exists(sToken) Then
WScript.Echo sToken, "seen for the first time"
End If
dicSeen(sToken) = dicSeen(sToken) + 1
Next
WScript.Echo "--------------"
Dim sType
For Each sType In dicSeen.Keys()
WScript.Echo sType, dicSeen(sType)
Next
output:
cscript 21272514.vbs
f f a b a c d e f a b
--------------
f seen for the first time
a seen for the first time
b seen for the first time
c seen for the first time
d seen for the first time
e seen for the first time
--------------
f 3
a 3
b 2
c 1
d 1
e 1
Update wrt comment:
Using a function:
Option Explicit
Function firstTimeSeen(dicX, sVal)
firstTimeSeen = Not dicX.Exists(sVal)
dicX(sVal) = dicX(sVal) + 1
End Function
Dim dicSeen : Set dicSeen = CreateObject("Scripting.Dictionary")
Dim aFakeLog : aFakeLog = Split("f f a b a c d e f a b")
Dim sToken
WScript.Echo Join(aFakeLog)
WScript.Echo "--------------"
For Each sToken In aFakeLog
If firstTimeSeen(dicSeen, sToken) Then
WScript.Echo sToken, "seen for the first time"
End If
Next
WScript.Echo "--------------"
Dim sType
For Each sType In dicSeen.Keys()
WScript.Echo sType, dicSeen(sType)
Next