is not in list

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

is not in list

Post by DavJans » Mon Apr 13, 2015 7:54 pm

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.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10394
Joined: Wed May 06, 2009 2:28 pm

Re: is not in list

Post by dunbarx » Mon Apr 13, 2015 8:12 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10066
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: is not in list

Post by FourthWorld » Mon Apr 13, 2015 8:42 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply