Page 1 of 1

is not in list

Posted: Mon Apr 13, 2015 7:54 pm
by DavJans
I have been using this to compare two lists of numbers

Code: Select all

if item 1 of tLine is not in tContents then
          put item 1 of tLine into delPcmk
later in the code it removes it from a database but thats not important for my question.

The problem is that if for example tLine is 1005 and in tContents there is a 131005 then it wont get removed. I was thinking I can maybe compare both lists to each other from both directions, but wanted to see here first if there was a solution already known before I make up my own bloated solution.

Re: is not in list

Posted: Mon Apr 13, 2015 8:12 pm
by dunbarx
Hi.

The way you have it written, using "is not in", will have that problem, since you (essentially) are asking if "1005" is in "131005", which it is.

A lot depends on how your tLine and your tContents are set up. Are they all lines? All items within lines? Whatever?

If you do not want to loop through the data, comparing tLine with each chunk of tContents, then the regex gadget "matchtext" is what is really needed here. Have you ever used that? It is very fast and powerful. Check the entry in the dictionary, and write back if you get stuck. Or just call Thierry.

Craig Newman

Re: is not in list

Posted: Mon Apr 13, 2015 8:42 pm
by FourthWorld
The "among" operator checks the complete chunk type, e.g.:

Code: Select all

if item 1 of tLine is not among the lines of tContents then