On Mon, Feb 20, 2012 at 2:53 AM, Glen Bojsza <gboj...@gmail.com> wrote:

>
> Is the use of arrays to solve this appropriate? Efficient? Fast?
>
> From another recent thread, using arrays is slower than repeat for each
line, and if the values you give are realistic (not lines with 10000 chars)
then even if you have a million lines, repeat for each will be fast and
efficient.

My script below I creat a list of:

10  6
80  7
130  23
140  2
150  22

and the script produces:

10    6
20    0
70    0
80    7
90    0
120    0
130    23
140    2
150    0
160    22

Throw this into a button and see if it works for you:

on mouseUp
  --create a list to start with
   put 10 & tab & 6 & cr & \
         80 & tab & 7 & cr & \
         130 & tab & 23  & cr & \
         140 & tab & 2 & cr & \
         160 & tab & 22 into tStore

  --actual work done here
   set the itemDelimiter to tab
   put "first" into tLastItem
   repeat for each line tLine in tStore
      put item 1 of tLine into tCheck
      switch
         case (tLastItem = "first")
            --don't do anything
            break
         case (tCheck - tLastItem > 20)
            put tLastItem + 10 & tab & 0 & cr after tStore2
            put tCheck - 10 & tab & 0 & cr after tStore2
            break
         case (tCheck - tLastItem > 10)
            put tCheck - 10 & tab & 0 & cr after tStore2
            break
      end switch
      put tLine & cr after tStore2
      put tCheck into tLastItem
   end repeat
   put tStore2 into msg
end mouseUp

HTH
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to