gleem Posted June 9, 2006 Posted June 9, 2006 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
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 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 . 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.
gleem Posted June 9, 2006 Author Posted June 9, 2006 (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 .simply create a folder call data that has a text file called White List.txt and Black List.txt, and Final Shutdown List.txtput any names that you want.. for example:White List.txt------------cartrucktrainboatetc...Black List.txt------maryjanetrainjoenow.. 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 thisFinal Shutdown List.txt-----maryjanejoe Edited June 9, 2006 by gleem
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 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? 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.
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 (edited) Hmm, that wasn't very fun expandcollapse popup#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) EndIfGave the exact response you showed at least.Edit:You will need beta to run this. Edited June 9, 2006 by SmOke_N 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.
gleem Posted June 9, 2006 Author Posted June 9, 2006 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 20Local $IsOk = TrueLocal $IsOk = ^ ERRORError: Unknown function namethanks agian
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 (edited) wow.. thank you for your feedback. I installed the beta and tried running the script.I get an error on Line 20Local $IsOk = TrueLocal $IsOk = ^ ERRORError: Unknown function namethanks agianYour not using Alt+F5 then to run the script from SciTe, the Released version runs by default.Edit:Let me re-itterate:Open SciTeOpen ScriptAlt+F5 to Run Beta or SciTe >> Tools >> Run Beta Edited June 9, 2006 by SmOke_N 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.
gleem Posted June 9, 2006 Author Posted June 9, 2006 Your not using Alt+F5 then to run the script from SciTe, the Released version runs by default.Edit:Let me re-itterate:Open SciTeOpen ScriptAlt+F5 to Run Beta or SciTe >> Tools >> Run BetaThat worked.....I must say, your code is very clean. I am still a newbie at programming; however, thank you for your guidance...
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 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. 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.
gleem Posted June 13, 2006 Author Posted June 13, 2006 (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 June 13, 2006 by gleem
Moderators SmOke_N Posted June 13, 2006 Moderators Posted June 13, 2006 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..weridThe 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? 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.
gleem Posted June 13, 2006 Author Posted June 13, 2006 (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 dothe only thing I modified was where the list.txt's where being stored Edited June 13, 2006 by gleem
Moderators SmOke_N Posted June 13, 2006 Moderators Posted June 13, 2006 actually I did... can I pm you my whole code? you will see the big picture of what I am trying to dothe only thing I modified was where the list.txt's where being storedYeah, 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. 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.
gleem Posted June 13, 2006 Author Posted June 13, 2006 (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 June 13, 2006 by gleem
gleem Posted June 13, 2006 Author Posted June 13, 2006 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now