Page 1 of 1

field selection and variable [SOLVED]

Posted: Sat Mar 29, 2014 3:05 am
by keram
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

Re: field selection and variable [SOLVED]

Posted: Tue Apr 01, 2014 4:40 am
by keram
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