Page 1 of 1

If and repeat problem...methinks

Posted: Thu Jan 11, 2024 2:26 pm
by oldummy
Livecode Community 9.6

I have a test stack that has 5 cards. On each card there are two grouped fields.The backgroundbehavior of this group is set to true.
My intention is to run through the stack and check to see if any of those fields in this stack contain the current year.
I cannot get this script to work in any of four ways I write it.
Of these fields, only one contains 2024.
When I step through the debugger, tcount is always 5 or 0 instead of 1 or 4 depending on which option I choose use.
I'm sure it is something simple. I'm just a lot simpler than that.



Code: Select all

on mouseUp
   put the long date into tmydate
   set the itemdelimiter to ","
   put the last item of tmydate into tzzz-- I break things down into small parts just to watch them
   put "0" into tcount -- this to watch in the debugger.
   repeat with i = 1 to the number of cds of this stack --5 cds with the same grouped flds with background behavior set to true.
      --if tzzz is in fld "plop" of cd i then-- this does not work. if statement is ignored 
      if tzzz is not in fld "plop" of cd i then--this does not work. if statement is ignored
         --if tzzz is not in fld "plop" then --this does not work. if statement is ignored
         add 1 to tcount
      end if
   end repeat
end mouseUp

Re: If and repeat problem...methinks

Posted: Thu Jan 11, 2024 2:38 pm
by Klaus
Hi oldummy,

Code: Select all

...
put the last item of tmydate into tzzz
...
tzzz is now: " 2024" -> with a leading SPACE!
And I presume that SPACE is not in one of your fields, right?
Try this:

Code: Select all

...
put the last item of tmydate into tzzz
replace " " with "" in tzzz
...
Best

Klaus

Re: If and repeat problem...methinks

Posted: Thu Jan 11, 2024 3:15 pm
by oldummy
AHA! I would have gone for years without that crossing my mind.
Thank you yet again.

Re: If and repeat problem...methinks

Posted: Fri Jan 12, 2024 6:54 pm
by jiml
This one liner might work too.

Code: Select all

put the last trueword of tmydate into tzzz