So I created these two arrays Approved shares and current shares.
\'Reads Approvedshare txt and makes the txt file into an array
public objFSO
set objFSO = Cre
So your problem is to get the relative complement of the set 'approved' in the set 'current': the set of those elements that are in 'current', but not in 'approved'.
The script:
Option Explicit
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
ExecuteGlobal goFS.OpenTextFile( ".\SetLib.vbs" ).ReadAll
Function Fi2Ar(sFSpec)
Dim aTmp : aTmp = Split(goFS.OpenTextFile(sFSpec).ReadAll(), vbCrLf)
Dim nLst : nLst = -1
Dim i
For i = 0 To UBound(aTmp)
If Trim(aTmp(i)) <> "" Then
nLst = i
aTmp(i) = Trim(aTmp(i))
aTmp(i) = "'" & aTmp(i) & "'" ' just for display
End If
Next
ReDim Preserve aTmp(nLst)
Fi2Ar = aTmp
End Function
Dim aA : aA = Fi2Ar("..\data\s1.txt")
Dim aB : aB = Fi2Ar("..\data\s2.txt")
Dim aRes : aRes = diffArray( aA, aB )
WScript.Echo "A : [", Join( aA ), "]"
WScript.Echo "B : [", Join( aB ), "]"
WScript.Echo "UNI: [", Join( aRes( 0 ) ), "]", "in A or B"
WScript.Echo "INT: [", Join( aRes( 1 ) ), "]", "in A and B"
WScript.Echo "A\B: [", Join( aRes( 2 ) ), "]", "in A but not in B"
WScript.Echo "B\A: [", Join( aRes( 3 ) ), "]", "in B but not in A"
goFS.CreateTextFile("..\data\s3.txt").WriteLine Join(aRes(3), vbCrLf)
WScript.Echo "Bad Shares File:"
WScript.Echo goFS.OpenTextFile("..\data\s3.txt").ReadAll()
output:
A : [ 'Test' 'test123' 'test1234' 'flexare' 'this' 'is' 'a' 'example' ]
B : [ 'Test' 'test123' 'added 1' 'added2' 'test1234' 'flexare' 'added 3' 'this' 'is' 'a' 'example' 'added4' ]
UNI: [ 'Test' 'test123' 'test1234' 'flexare' 'this' 'is' 'a' 'example' 'added 1' 'added2' 'added 3' 'added4' ]
in A or B
INT: [ 'Test' 'test123' 'test1234' 'flexare' 'this' 'is' 'a' 'example' ] in A and B
A\B: [ ] in A but not in B
B\A: [ 'added 1' 'added2' 'added 3' 'added4' ] in B but not in A
Bad Shares File:
'added 1'
'added2'
'added 3'
'added4'
reads your sample files, computes the relative complement B\A, and writes it to a files.
It uses the diffArray() function from here; this function should go in the file SetLib.vbs in the same folder (the ExecuteGlobal-line 'imports' the function).
The Fi2Ar() function reads the .txt files; I quoted the elements to improve the display, you should remove the statement after testing.