Sign in to follow this  
Followers 0
gleem

Stuck with White List / Black List verifcation

15 posts in this topic

I am writing a script that will verify a bunch of names in white list.txt to a bunch of names in black list.txt. during the verification process, I am trying to get the script so that it subtracts white list member names from the black list member names and save it as a new file called final shutdown list.txt

Sofar, I can get both side to go through the motions of checking white list members to black list members, however I hit a snag. the only time it will not add a users name to the final shutdown list.txt is when the name on the white list is being verified.....

all I want it to do is subtract white list members from black list members to create the final list.

here is my script sofar below.

----------

; Start value for line number count

$blacklinenumber = 0

$whitelinenumber = 0

$endcheck = ("")

; Intial varible assignments.

$whitelistcheck = ("White List Kick Off")

$blacklistcheck = ("Black List Kick Off")

; Loop Until Black List is done comparing with White List

While 1

; end Loop

If $whitelistcheck = $endcheck Then ExitLoop

; If black list name is not on white list, add their name to final reboot list

If $blacklistcheck <> $whitelistcheck Then

fileopen(@ScriptDir & "\Data\Final Shutdown List.txt", 1)

filewriteline (@ScriptDir & "\Data\Final Shutdown List.txt", $blacklistcheck & @CRLF)

fileclose(@ScriptDir & "\Data\Final Shutdown List.txt")

Else

EndIf

; When black list reaches the end, checks the next name on the white list

If $blacklistcheck = $endcheck Then

$whitelinenumber = $whitelinenumber + 1

fileopen(@ScriptDir & "\Data\White List.txt", 0)

$whitelistcheck = filereadline (@ScriptDir & "\Data\White List.txt", $whitelinenumber)

fileclose(@ScriptDir & "\Data\White List.txt")

; reset black list to like 1

$blacklinenumber = 0

EndIf

; Black List Check

$blacklinenumber = $blacklinenumber + 1

fileopen(@ScriptDir & "\Data\Black List.txt", 0)

$blacklistcheck = filereadline (@ScriptDir & "\Data\Black List.txt", $blacklinenumber)

fileclose(@ScriptDir & "\Data\Black List.txt")

; Display

msgbox(0,"SGI VIP Bouncer", "White List: " & $whitelistcheck & "" & @CRLF & " Black List: " & $blacklistcheck & "")

WEnd

Share this post


Link to post
Share on other sites



Are each of the names on a seperate line by themselves, can you provide a white and black list so we can help a tad more :D.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Are each of the names on a seperate line by themselves, can you provide a white and black list so we can help a tad more :D.

simply create a folder call data that has a text file called White List.txt and Black List.txt, and Final Shutdown List.txt

put any names that you want.. for example:

White List.txt

------------

car

truck

train

boat

etc...

Black List.txt

------

mary

jane

train

joe

now.. to see if verifcation works.... put the same name in both files. if it works, then that name should not end up in final txt file.

outcome should look like this

Final Shutdown List.txt

-----

mary

jane

joe

Edited by gleem

Share this post


Link to post
Share on other sites

Ugh... so you want them to be removed off the "Black" list if they are on the White List... and the final output be written in the Final Shutdown List.txt? So, the Black list would = the Final Shutdownlist.txt?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hmm, that wasn't very fun :D

#include <File.au3>
Local $WhiteListLocation = @ScriptDir & '\WhiteList.txt', $BlackListLocation = @ScriptDir & '\BlackList.txt'
Local $ShutDownListLocation = @ScriptDir & '\ShutDownList.txt'
Local $nWhiteArray = '', $nBlackArray = '', $aNamesToNotAddSDL = ''
If Not _FileReadToArray($WhiteListLocation, $nWhiteArray) Then Exit
If Not _FileReadToArray($BlackListLocation, $nBlackArray) Then Exit

For $BlackCount = 1 To UBound($nBlackArray) - 1
    For $WhiteCount = 1 To UBound($nWhiteArray) - 1
        If $nBlackArray[$BlackCount] = $nWhiteArray[$WhiteCount] Then
            $aNamesToNotAddSDL &= $nBlackArray[$BlackCount] & Chr(01)
        EndIf
    Next
Next

If $aNamesToNotAddSDL <> '' Then
    $NameFileOpen = FileOpen($ShutDownListLocation, 2)
    If StringInStr($aNamesToNotAddSDL, Chr(01)) Then
        $aNamesToNotAddSDL = StringSplit(StringTrimRight($aNamesToNotAddSDL, 1), Chr(01))
        Local $IsOk = True
        For $AddCount = 1 To UBound($nBlackArray) - 1
            For $DontAddCount = 1 To UBound($aNamesToNotAddSDL) - 1
                If $nBlackArray[$AddCount] = $aNamesToNotAddSDL[$DontAddCount] Then
                    $IsOk = False
                    ExitLoop
                EndIf
            Next
            If $IsOk Then
                FileWriteLine($ShutDownListLocation, $nBlackArray[$AddCount])
            EndIf
            $IsOk = True
        Next
    EndIf
    FileClose($NameFileOpen)
Else
    $NameFileOpen = FileOpen($ShutDownListLocation, 2)
    For $AddCount = 1 To UBound($nBlackArray) - 1
        FileWriteLine($ShutDownListLocation, $nBlackArray[$AddCount])
    Next
    FileClose($NameFileOpen)
EndIf
Gave the exact response you showed at least.

Edit:

You will need beta to run this.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You will need beta to run this.

wow.. thank you for your feedback. I installed the beta and tried running the script.

I get an error on Line 20

Local $IsOk = True

Local $IsOk = ^ ERROR

Error: Unknown function name

thanks agian

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

wow.. thank you for your feedback. I installed the beta and tried running the script.

I get an error on Line 20

Local $IsOk = True

Local $IsOk = ^ ERROR

Error: Unknown function name

thanks agian

Your not using Alt+F5 then to run the script from SciTe, the Released version runs by default.

Edit:

Let me re-itterate:

Open SciTe

Open Script

Alt+F5 to Run Beta or SciTe >> Tools >> Run Beta

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Your not using Alt+F5 then to run the script from SciTe, the Released version runs by default.

Edit:

Let me re-itterate:

Open SciTe

Open Script

Alt+F5 to Run Beta or SciTe >> Tools >> Run Beta

That worked.....

I must say, your code is very clean. I am still a newbie at programming; however, thank you for your guidance...

Share this post


Link to post
Share on other sites

That worked.....

I must say, your code is very clean. I am still a newbie at programming; however, thank you for your guidance...

I don't know about "clean", and to be honest, I don't know if there was a better way, I wrote that at like 1:00 A.M.... but glad it's working for you all the same.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I don't know about "clean", and to be honest, I don't know if there was a better way, I wrote that at like 1:00 A.M.... but glad it's working for you all the same.

Hey Smoke, I tested your code some more out today. From what I have found, some of the names on the whitelist manage to end up on the blacklist.... though.. other names not..

werid

Edited by gleem

Share this post


Link to post
Share on other sites

Hey Smoke, I tested your code some more out today. From what I have found, some of the names on the whitelist manage to end up on the blacklist.... though.. other names not..

werid

The only file it writes too is the Final list or whatever it was. It doesn't write to either the black or white list it only reads them. Did you try to alter it at all before you "played" with it?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

The only file it writes too is the Final list or whatever it was. It doesn't write to either the black or white list it only reads them. Did you try to alter it at all before you "played" with it?

actually I did... can I pm you my whole code? you will see the big picture of what I am trying to do

the only thing I modified was where the list.txt's where being stored

Edited by gleem

Share this post


Link to post
Share on other sites

actually I did... can I pm you my whole code? you will see the big picture of what I am trying to do

the only thing I modified was where the list.txt's where being stored

Yeah, that would fine, I can have a look... but no promises... I have a project of mine I have to finish by Friday, and my procrastination is getting the better of me.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Yeah, that would fine, I can have a look... but no promises... I have a project of mine I have to finish by Friday, and my procrastination is getting the better of me.

its sent... thank you soo much for your help... I would say that everything is working fine.. except what we discussed.

also in the program.. I use some other code to generate the black list in which I use your re-written code to compare it to my white list.

Edited by gleem

Share this post


Link to post
Share on other sites

I believe I found the error of my ways. I wrote some code that would clear the blacklist and shutdown list so that the program can generate a new list. Appearly, the items where being appended to the old list thus creating duplicates.

thanks again.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0