Page 1 of 1

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

Posted: Wed May 29, 2013 11:47 am
by Mariasole
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
(=°.°=)

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

Posted: Wed May 29, 2013 11:53 am
by SparkOut
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

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

Posted: Wed May 29, 2013 12:34 pm
by Dixie
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..:-(

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

Posted: Wed May 29, 2013 12:40 pm
by Klaus
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 ;-)

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

Posted: Wed May 29, 2013 1:08 pm
by SparkOut
but you can just type "

Code: Select all

" and "
" in the edit window

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

Posted: Wed May 29, 2013 8:52 pm
by Mariasole
Thanks SparkOut! Tanks Dixie!!
I am using all the two solutions! :)

Thank you again!

Baci!!!!

Mariasole
(=°.°=)