4 Replies Latest reply on May 31, 2007 5:40 PM by Lukewig

    Speed issue with text

    Level 7
      Hi All,

      I have a speed issue I could do with some help with...

      I have a simple app that grabs records from a database and puts them in a
      scrollable list (a scrollable field member).

      Just done a few speed tests an various parts of the code (as it seems very
      slow), and found....

      The (access) database had just over 7000 records
      it takes 0.2secs to get this data (using ADOXtra)
      it takes over 4secs to put each line into the field member!!!

      Here's the code.....

      --fullData is a list of the data i need
      --totalRecs is the number of items in fullData
      --member("currentList") is the scrollable field member

      set theList = ""
      repeat with nn = 1 to totalRecs
      set theList = theList & fullData[nn]
      if nn < totalRecs then set theList = theList & return
      end repeat

      put theList into member("currentList")
      member("currentList").scrollTop = 0

      Anyone have any suggestions to make this quicker?



        • 1. Re: Speed issue with text
          Level 7
          I'm not sure how much more efficient it will be, but the code does execute
          7000 unnecessary if-then statements where you check whether or not to append
          RETURN. Try appending RETURN everytime (without the if-then statement) then
          just remove the last (unnecessary) RETURN that will be at the end. Something

          repeat with nn = 1 to totalRecs
          set theList = theList & fullData[nn]& return
          end repeat

          -- add code to remove the last char if it is a RETURN

          • 2. Re: Speed issue with text
            James Newton, ACP Level 3
            Back in the days of DIrector 5, I discovered that it was faster to populate a field member with text if the field member was not on the Stage at the time. I have not tested recently to see if this is still true.
            • 3. Re: Speed issue with text
              You might also try the put... after..syntax which I think may be faster than using '&'

              put fullData[nn] after theList
              put RETURN after theList


              • 4. Re: Speed issue with text

                For fields (box type set to scrolling), the following will speed things up a bit (assuming your field is sprite 1):

                sprite(1).visible = 0
                sprite(1).member.text = newStr
                sprite(1).visible = 1

                Surprisingly (last time I checked), #text member were populated with text way faster than fields - so you might also want to try using a #text member.

                -- Luke