IF and... multiple OR | (=*.*=) A newbie nightmare

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
Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

IF and... multiple OR | (=*.*=) A newbie nightmare

Post by Mariasole » Wed May 29, 2013 11:47 am

Hello to all!
I am continuing to study LiveCode... it's fantastic!!!!!
But now I'm stopped on this IF statement... (=*.*=)


Here's the problem in "PigCode" (I'm a guru of PigCode!!!! :) )

I have a list of words into field fList:

cat,
cat
,cat
!cat
cat!
cat$
cat%

If any of these words contain at the end "," or "!" or "$" doSomething

I've tried so:

Code: Select all


repeat for each word tWord in field "fList"

      IF (",") or ("!") is the last char of tWord THEN answer last char of tWord

end repeat

This in fact works! :) BUT.... :(

Code: Select all


repeat for each word tWord in field "fList"

      IF (",") or ("!") or ("$")  is the last char of tWord THEN answer last char of tWord

end repeat

This does not work! :(

So I thought this ;)

Code: Select all

repeat for each word tWord in field "fList"
IF "(?:[,!$])"  is the last char of tWord THEN answer  last char of tWord
end repeat
But it does not work ...

Help me to solve this newbie nightmare for a newbie ! :)
Thanks!!!

Baci!!!!!

Mariasole
(=°.°=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: IF and... multiple OR | (=*.*=) A newbie nightmare

Post by SparkOut » Wed May 29, 2013 11:53 am

This should do the trick, if you don't want anything more sophisticated

Code: Select all

put "(?:[,!$])" into tMatches
repeat for each word tWord in field "fList"
  if the last char of tWord is among the chars of tMatches then
     answer last char of tWord
  end if
end repeat

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: IF and... multiple OR | (=*.*=) A newbie nightmare

Post by Dixie » Wed May 29, 2013 12:34 pm

on mouseUp
put ("!" & "$" & "%" & ",") into theChars

repeat with count = 1 to the number of lines of fld 1
repeat with count2 = 1 to the number of chars of line count of fld 1
if itemOffset( char count2 of theChars,line count of fld 1) <> 0 then
put count & cr after theLines
end if
end repeat
end repeat

put theLines
end mouseUp

Dixie...

Mmmm... can't get 'code' button to work..:-(

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: IF and... multiple OR | (=*.*=) A newbie nightmare

Post by Klaus » Wed May 29, 2013 12:40 pm

Dixie wrote:Mmmm... can't get 'code' button to work..:-(
Yep, it is still broken, I already mailed to support.
Maybe you should also write a littel mail?
Would not hurt ;-)

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: IF and... multiple OR | (=*.*=) A newbie nightmare

Post by SparkOut » Wed May 29, 2013 1:08 pm

but you can just type "

Code: Select all

" and "
" in the edit window

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: IF and... multiple OR | (=*.*=) A newbie nightmare

Post by Mariasole » Wed May 29, 2013 8:52 pm

Thanks SparkOut! Tanks Dixie!!
I am using all the two solutions! :)

Thank you again!

Baci!!!!

Mariasole
(=°.°=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Post Reply