among not working the way it should with numbers

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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

among not working the way it should with numbers

Post by Da_Elf » Tue Jul 07, 2015 1:00 am

trying this where tileTypeNumber is 2

Code: Select all

if tileTypeNumber is among the words of "1 2 3 4 5 6" then
   put "VideoAloneTemplate" into templateMaster
end if
but it refuses to find 2 in that list. the numbers are separated by spaces so they should be recognised as words shouldn't they?
i tried setting itemDelimiter to comma then setting the list to "1,2,3,4,5,6" and used "among the items of" but it still didnt work

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

Re: among not working the way it should with numbers

Post by dunbarx » Tue Jul 07, 2015 2:28 am

Hi.

Something hidden is fouling up the works? Because that code surely works if the "2" is surrounded by spaces:

Code: Select all

on mouseUp
   put 2 into tileTypeNumber
   if tileTypeNumber is among the words of "1 2 3 4 5 6" then answer "Yep!"
end mouseUp
The code fragment ..." if tileTypeNumber is among the words of "1 2 3 4 5 6" then..." is direct from your post.

Craig Newman

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: among not working the way it should with numbers

Post by Da_Elf » Tue Jul 07, 2015 3:19 am

you were right. there was something messing it up. thats. it gave me the right idea to look at the creation of the 2 rather than looking at the use of "among"

Post Reply