Slow loading Option Menus

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
Greg O.
Posts: 21
Joined: Wed Jun 18, 2014 4:02 am

Slow loading Option Menus

Post by Greg O. » Wed Jun 18, 2014 4:32 am

<ridiculously complex lead in>
I have a card with up to 48 groups of controls. In each group of controls is an option menu. Each of the 48 option menus has the same choices available. The available options are set up when a different option menu has a menu item selected.
</ridiculously complex lead in>

This sets up the menu choices and puts them into a variable nGrps:
This is from the first option menu selected. qQuery is a function that returns revDataFromQuery

Code: Select all

  --determine the number of groups
   put ("SELECT name FROM sqlite_master WHERE type ='table' AND name LIKE 'grp" & pItemName & "%'") into tFind
   put qQuery(tFind) into tFound
   put the number of lines of tFound into nCount2
   
   
     repeat with y = 1 to nCount2
      put  y & cr after nGrps
   end repeat
Once I have this text put into the variable I then need to set the text of the other (up to) 48 option menus:
The name of the option menus follow the pattern "gNum#" 1 through 48
tCInfo is the result of a database query where each line is a group of information used to set the corresponding group of controls

Code: Select all

Repeat with x = 1 to nCount1
   Put item 2 of line x of tCInfo into fld ("cNum" & x)
   
   If (item 3 of line x of tCInfo) is 1 then
      Set the highlited of btn ("alph" & x) to true
   Else
      Set the highlited of btn ("alph" & x) to false
   End if
   
   Put item 4 of line x of tCInfo into fld ("visNum" & x)
  
   
   set the text of btn ("gNum" & x) to nGrps
   set  the text of btn ("gNum" & x) to item 6 line x of tCInfo
end Repeat
If I comment out the last two lines of the repeat, the whole operation takes just long enough to see it happening, but with the last two lines in it takes close to 5 seconds to complete. Is there a faster way to load the option menus?


thank you,

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

Re: Slow loading Option Menus

Post by Klaus » Wed Jun 18, 2014 11:53 am

Hi Greg,

1. welcome to the forum! :D

2. Add a un-/lock screen and see if this helps:
...
lock screen
repeat with ...
##...
end repeat
unlock screen
...

Best

Klaus

Greg O.
Posts: 21
Joined: Wed Jun 18, 2014 4:02 am

Re: Slow loading Option Menus

Post by Greg O. » Wed Jun 18, 2014 2:33 pm

I assume this takes the burden off of the system of actually drawing everything in real time. I will give it a try.

Thank you

Greg O.
Posts: 21
Joined: Wed Jun 18, 2014 4:02 am

Re: Slow loading Option Menus

Post by Greg O. » Wed Jun 18, 2014 2:40 pm

That worked wonders! thank you. I will go through and fix many other places that were slowing down for very similar reasons.

Post Reply