CSalt2
Power Member
- Feb 5, 2009
- 761
- 362
i'm not very familiar with code, i was wondering if someone else could explain these codes to me. I want to know what they're doing.
Also I was wonder in "list1" "list2" "lists3" am I suppose to put the file location of my list? and in ["listSearchTextContains"] what should i put? thanks guys
blacklist code:
2nd code:
Also I was wonder in "list1" "list2" "lists3" am I suppose to put the file location of my list? and in ["listSearchTextContains"] what should i put? thanks guys
blacklist code:
Code:
List<string> blacklist = project.Lists["List1"].ToList();List<string> newdata = System.IO.File.ReadAllLines(project.Variables["List2"].Value).ToList();
var good = project.Lists["List3"];
lock(SyncObjects.ListSyncer)
{
List<string> exclude = new List<string>();
exclude = newdata.Except(blacklist).ToList();
foreach(string data in exclude)
{good.Add(data);}
}
2nd code:
Code:
[LIST]
[*][COLOR=grey][COLOR=#006600][I]// take search text from variable[/I][/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#000066][B]var[/B][/COLOR] textContains [COLOR=#339933]=[/COLOR] project.[COLOR=#660066]Variables[/COLOR][COLOR=#009900][[/COLOR][COLOR=#3366CC]"listSearchTextContains"[/COLOR][COLOR=#009900]][/COLOR].[COLOR=#660066]Value[/COLOR][COLOR=#339933];[/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#006600][I]// get a list or search[/I][/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#000066][B]var[/B][/COLOR] sourceList [COLOR=#339933]=[/COLOR] project.[COLOR=#660066]Lists[/COLOR][COLOR=#009900][[/COLOR][COLOR=#3366CC]"SourceList"[/COLOR][COLOR=#009900]][/COLOR][COLOR=#339933];[/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#006600][I]// search in each line of list[/I][/COLOR][/COLOR]
[*][COLOR=grey]lock[COLOR=#009900]([/COLOR]SyncObjects.[COLOR=#660066]ListSyncer[/COLOR][COLOR=#009900])[/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#009900]{[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#000066][B]for[/B][/COLOR][COLOR=#009900]([/COLOR][COLOR=#FF0000]int[/COLOR] i[COLOR=#339933]=[/COLOR][COLOR=#CC0000]0[/COLOR][COLOR=#339933];[/COLOR] i [COLOR=#339933]<[/COLOR] sourceList.[COLOR=#660066]Count[/COLOR][COLOR=#339933];[/COLOR] i[COLOR=#339933]++[/COLOR][COLOR=#009900])[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#009900]{[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#006600][I]// get line from list[/I][/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#000066][B]var[/B][/COLOR] str [COLOR=#339933]=[/COLOR] sourceList[COLOR=#009900][[/COLOR]i[COLOR=#009900]][/COLOR][COLOR=#339933];[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#006600][I]// check if line contains text, if there are matches return "yes"[/I][/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#000066][B]if[/B][/COLOR] [COLOR=#009900]([/COLOR]str.[COLOR=#660066]Contains[/COLOR][COLOR=#009900]([/COLOR]textContains[COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#000066][B]return[/B][/COLOR] [COLOR=#3366CC]"yes"[/COLOR][COLOR=#339933];[/COLOR][/COLOR]
[*][COLOR=grey] [COLOR=#009900]}[/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#009900]}[/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#006600][I]// ifnothing found return "no"[/I][/COLOR][/COLOR]
[*][COLOR=grey][COLOR=#000066][B]return[/B][/COLOR] [COLOR=#3366CC]"no"[/COLOR][COLOR=#339933];[/COLOR][/COLOR]
[/LIST]