field selection and variable [SOLVED]

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
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

field selection and variable [SOLVED]

Post by keram » Sat Mar 29, 2014 3:05 am

Hello,

I have a stack on which there are 3 fields that toggle their colors and their corresponding checkboxes. At the same time the toggling should change the variable (gMyCategories) in order to calculate the correct number of lines and type of categories. The Select All button works OK, but the code for selecting and dis-selecting each category (One, Two, Three fields) does not work - I don't get the correct line numbers and categories in "categories" and "Will show" fields.
The code in the group "fldCat" is this:

Code: Select all

global gAllLines,gMyCategories

on mouseUp
   set the itemDel to tab
   put empty into gMyCategories
   
   repeat with j = 1 to the number of fields of grp "fldCat"
      if the backgroundcolor of the target is white then
         set the hilite of btn (the short name of the target) of grp "CheckCat" to "true"
         put the short name of the target & tab after gMyCategories
         set  the backgroundcolor of the target to yellow
      else
         set  the backgroundcolor of the target to white
         set the hilite of btn (the short name of the target) of grp "CheckCat" to "false"
      end if
   end repeat
   
   delete char -1 of gMyCategories  --tab
   put gMyCategories into fld "SelCat"
   
   local LinesInMyCategories
   repeat for each line i in gAllLines
      if item 3 of i is among the items of gMyCategories then put item 1 of i &tab& item 2 of i & tab & item 3 of i &tab& item 4 of i &cr after LinesInMyCategories  --lines in selected categories
   end repeat
   delete char -1 of LinesInMyCategories  --return
   
   put the number of lines in LinesInMyCategories into fld "NrOfLines"
   put the number of items in gMyCategories into fld "NrOfCategories"
end mouseUp

Please let me know how to correct it (see the stack). Thanks.

keram
Attachments
field selection and variable.zip
(56.39 KiB) Downloaded 164 times
Last edited by keram on Tue Apr 01, 2014 4:41 am, edited 1 time in total.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: field selection and variable [SOLVED]

Post by keram » Tue Apr 01, 2014 4:40 am

It's solved, thanks to TerryL.

Code: Select all

--grp "fldCat" script:
global gAllLines,gMyCategories
on mouseUp
   local LinesInMyCategories
   set the itemDel to tab
   put empty into gMyCategories
   if the backgroundcolor of the target = "white" then set the backgroundColor of the target to "yellow"
   else set  the backgroundcolor of the target to "white"  --toggle yellow/white
   repeat with j = 1 to number(flds of me)
      if the backgroundcolor of fld j of me = "yellow" then  --***changed to "fld j of me = "yellow""
         set the hilite of btn (the short name of fld j of me) of grp "CheckCat" to "true"
         put the short name of fld j of me & tab after gMyCategories
      else set the hilite of btn (the short name of fld j of me) of grp "CheckCat" to "false"
   end repeat
   delete char -1 of gMyCategories  --tab
   put gMyCategories into fld "SelCat"
   repeat for each line i in gAllLines
      if item 3 of i is among the items of gMyCategories then put item 1 of i &tab& item 2 of i & tab & item 3 of i &tab& item 4 of i &cr after LinesInMyCategories  --lines in selected categories
   end repeat
   delete char -1 of LinesInMyCategories  --return
   put the number of lines in LinesInMyCategories into fld "NrOfLines"
   put the number of items in gMyCategories into fld "NrOfCategories"
end mouseUp
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply