Using "is not", is this correct?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Using "is not", is this correct?

Post by gyroscope » Wed May 13, 2009 10:01 pm

Hi, I might be missing something obvious here: part of my app registration code is:

Code: Select all

 if tB312 is not "41" or tB312 is not "58" or tB312 is not "94" or tB312 is not " 34" or tB312 is not "44" or tB312 is not "18"\
         or tB312 is not "26" or tB312 is not "17" or tB312 is not "32" or tB312 is not "75" or tB312 is not "82" or tB312 is not "88" then
        beep
     answer "Sorry, this is not a valid code for ISAGO"
     exit mouseUp
  end if
But if part of the registration code contains any of those numbers it still answers that it's not valid. Have I misunderstood "is not" , perhaps, could anyone tell me please, or is there some other reason this bit of code isn't working :?:

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 13, 2009 10:33 pm

Hi Gyroscope,

Replace or with and.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed May 13, 2009 10:37 pm

Ah, I knew it'd be something obvious, thank you Mark!

:)

whelkybaby
Posts: 47
Joined: Sat Nov 17, 2007 6:04 pm

Post by whelkybaby » Wed May 13, 2009 11:03 pm

I'm intrigued by the really long "if" statement. You could consider simplifying this code a little by using "if ... is [not] in".

For example:

Code: Select all

if tB312 is not in "41,58,94,34,44,18,26,17,32,75,82,88" then
    beep
    answer "Sorry, this is not a value code to ISAGO"
    exit mouseUp
end if
Regards,


Steve

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed May 13, 2009 11:12 pm

Much better than my version Steve, thank you. Clearer to read too.

:)

whelkybaby
Posts: 47
Joined: Sat Nov 17, 2007 6:04 pm

Post by whelkybaby » Wed May 13, 2009 11:18 pm

No problem!

After reading a post the other day about us lurkers never posting to the board, I thought I'd try to make more of an effort!

Cheers,


Steve

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed May 13, 2009 11:25 pm

Hi Steve and gyroscope,

Code: Select all

if tB312 is not in "41,58,94,34,44,18,26,17,32,75,82,88" then 
will return return false whenever tB312 equals any character that is in "41,58,94,34,44,18,26,17,32,75,82,88", including 1, 2, 3, 4, 5, 6, 7, 8, 9 and comma. To avoid this, you can use the following:

Code: Select all

set the itemDel to comma // if necessary
if tB312 is not among the items of "41,58,94,34,44,18,26,17,32,75,82,88" then 
Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Thu May 14, 2009 4:44 pm

That's neat Mark, thanks again.

:)

Post Reply