Blackstar Posted December 31, 2006 Posted December 31, 2006 (edited) I'm fairly new to this multi-dim arrays part and I realized the potentials of storing more data for 2nd dimensional array and is suited for my task. What I am trying to do is creating unlimited amount of dimensions for names & subject whitelist filters from a text file for emails (3 elements as in 2nd dimensional such as: [0] = Names or "@subject", [1] = Subject's filter name, [2] = Target folder names) like this and use " -> " to sort emails to target folders:From a text file:@subject New Message: @subject [group] -> Group Emails John Doe myemail@anywhere.com Tom Warren -> Friends Jessica White Mike Shaw -> Business Jon & Jane WilliamsTo:;@subject New Message: $FilteredWhitelist[0][0];@subject $FilteredWhitelist[0][1];New Message: $FilteredWhitelist[0][2];"" (blank) ;@subject [group] -> Group Emails $FilteredWhitelist[1][0];@subject $FilteredWhitelist[1][1];[group] $FilteredWhitelist[1][2];Group Emails ;John Doe $FilteredWhitelist[2][0];John Doe $FilteredWhitelist[2][1];"" (blank) $FilteredWhitelist[2][2];"" (blank) ;myemail@anywhere.com $FilteredWhitelist[3][0];myemail@anywhere.com $FilteredWhitelist[3][1];"" (blank) $FilteredWhitelist[3][2];"" (blank) ;Tom Warren -> Friends $FilteredWhitelist[4][0];Tom Warren $FilteredWhitelist[4][1];"" (blank) $FilteredWhitelist[4][2];Friends ~so onHowever, I could not get this to work:expandcollapse popupDim $whitelist[1], $FilteredWhitelist[1], $tempsearch[1] _GetWhitelist() ReDim $FilteredWhitelist[UBound($FilteredWhitelist) + 1][3];Adjust the compare array size to accomodate new values For $j = 1 To $whitelist[0] $search = $whitelist[$j] Select Case StringInStr($search, "@subject ");Searching for "@subject " $FilteredWhitelist[UBound($FilteredWhitelist) - 1][0] = "@subject" $search = StringReplace($search, "@subject ", "") ;Remove "@subject " If StringInStr($search, " -> ") Then ;Searching for " -> " $tempsearch = StringRegExp($search, "((?: -> )([:alnum:].*))", 1);Extract anything after " -> " If Not $tempsearch = "" Then $search = $tempsearch[0] $FilteredWhitelist[UBound($FilteredWhitelist) - 1][2] = $search EndIf Else;No "@subject " or " -> " existed $FilteredWhitelist[UBound($FilteredWhitelist) - 1][1] = $search EndIf Case StringInStr($search, " -> ");Searching for " -> " $tempsearch = StringRegExp($search, "(&@[:alnum:].*)(?: -> )", 1);Extract anything before " -> " If Not $tempsearch = "" Then $search = $tempsearch[0] $FilteredWhitelist[UBound($FilteredWhitelist) - 1][0] = $search EndIf $tempsearch = StringRegExp($search, "((?: -> )([:alnum:].*))", 1) If Not $tempsearch = "" Then $search = $tempsearch[0] $FilteredWhitelist[UBound($FilteredWhitelist) - 1][2] = $search EndIf Case Else $FilteredWhitelist[UBound($FilteredWhitelist) - 1][0] = $search EndSelect ReDim $FilteredWhitelist[UBound($FilteredWhitelist) + 1][3];Adjust the compare array size to accomodate new values Next For $element = 1 to $whitelist[0] MsgBox(0, "", $FilteredWhitelist[$element - 1][0] & "," & $FilteredWhitelist[$element - 1][1] & "," & $FilteredWhitelist[$element - 1][2]) Next Func _GetWhitelist() ;Get whitelist $s_Path = @ScriptDir & "\whitelist.txt" If Not FileExists($s_Path) Then MsgBox(4096, "Error!", "whitelist.txt does not exist. Please create one with at least one filter in it.") Exit EndIf _FileReadToArray($s_Path, $whitelist) EndFunc Func _FileReadToArray($sFilePath, ByRef $aArray) Local $hFile $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $aArray = StringSplit(StringStripCR(FileRead($hFile, FileGetSize($sFilePath))), @LF) FileClose($hFile) Return 1 EndFuncAlso, what is the proper way to do For Next on $FilteredWhitelist multi-dimensional arrays when dealing with unknown element numbers in 1st dimensional array and then checks those 3 elements in 2nd dimensional array each time?EDIT:Changed to [ autoit ] code box Edited January 1, 2007 by Blackstar
Uten Posted January 1, 2007 Posted January 1, 2007 (edited) I have not read your code as the "unlimited" word made me loose interest.But you could read the wiki tutorial about arraysAlso remember that UBound($arr, $dimention) will help you out..EDIT:PS: Happy new year.. Edited January 1, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
jlorenz1 Posted January 1, 2007 Posted January 1, 2007 I have downloaded your files and I have tried them. The messagebox shows only some of the persons. It is difficult to follow your code. Try to solve your problems in more little steps and evaluare them. I don't know the function StringRegExp and don't find them in my help file. Sorry, that I can't give you another answer Johannes Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]
Uten Posted January 1, 2007 Posted January 1, 2007 I have downloaded your files and I have tried them. The messagebox shows only some of the persons. It is difficult to follow your code. Try to solve your problems in more little steps and evaluare them. I don't know the function StringRegExp and don't find them in my help file. Sorry, that I can't give you another answer Johannes You should update to the latest release. StringRegExp was away in some of the betas due to bugs. But a new version (beta) has been around fore months now. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
Blackstar Posted January 1, 2007 Author Posted January 1, 2007 (edited) I have downloaded your files and I have tried them. The messagebox shows only some of the persons. It is difficult to follow your code. Try to solve your problems in more little steps and evaluare them. I don't know the function StringRegExp and don't find them in my help file. Sorry, that I can't give you another answer Johannes jlorenz1, I commented what does that StringRegExp do in the code, didnt you see it?Uten, "unlimited" - true...I guess thats the wrong word for it....just say at least up to hundred elements then . It just depends on how many names added to the text file...it could start out at 5 names to at least 100 names. Are you able to see what went wrong with the code?EDIT:PS, Happy New Year you too! Edited January 1, 2007 by Blackstar
Uten Posted January 1, 2007 Posted January 1, 2007 Try to explain what goes wrong. You give no indication on what goes wrong, only what you want. And I'm not in beta testing mode today, sorry.. hmm, this does not look good to my eyes UBound($FilteredWhitelist) - 1 although you have a redim in the last part of the code so it might work, but it is definitely not fast.. Another tip. Use the [ autoit ] ; code [ /autoit ] tags (remove the spaces). It will make it a lot easier to read your code. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
Blackstar Posted January 1, 2007 Author Posted January 1, 2007 (edited) Ok, changed to [ autoit ]...indeed it does look better - good idea, thanks. What does not work that I unable to figure out when msgbox says: ,, or @subject,, when it should say: @subject, New Message, or @subject, [group], Group Emails from $whitelist array: @subject New Message: @subject [group] -> Group Emails I have redim in the last part of my code...speed not really the issue for me...I just wanted to work properly. Make sense? Edited January 1, 2007 by Blackstar
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