A Small Speed Observation on Custom Properties

Josh Mellicker josh at dvcreators.net
Tue Aug 21 13:58:31 EDT 2007

Another way to find data based on column is to make the first row a  
"header row", containing the names of the columns.

Then, you just write a handler to get the column number regardless of  
whether you've added or rearranged columns:

FUNCTION colNum pColumnHeader
     set the itemdelimiter to tab
     put line 1 of fld "data" into tHeaders
     return itemOffset(pColumnHeader, tHeaders)
END colNum

On Aug 21, 2007, at 9:38 AM, Gregory Lypny wrote:

> Hello Everyone,
> I've only just begun using custom properties, and this may be old  
> news to many of you but just in case I thought I'd pass it along.   
> I created a bunch of custom properties for a field called Data.   
> These properties are integers that identify the column or item  
> location in a line where a particular piece of information is  
> stored; for example, the colStudentName of fld "Data" = 3 tells me  
> that the student's name is always the third item.
> If you have to process many lines in such a field in a repeat loop,  
> it will go much faster if you put the values of the custom  
> properties into variables outside the loop and use the variables in  
> the loop rather than calling the custom properties themselves  
> within the loop.
> The second part of the handler below runs about ten times faster  
> than the first for a field with 100 lines.   And the speed is not  
> affected by the fact that I initialized the variables using "add"  
> instead of "put".
> Regards,
> 	Gregory
> on mouseUp
> -- Retrieve the custom property in each pass of the repeat loop
>   put the long seconds into theStartTime
>   get fld "Data"
>   repeat for each line thisLine in it
>     put item (the colStudentName of fld "Data") of thisLine && \
>     item (the colTime of fld "Data") of thisLine && \
>     item (the colGrade of fld "Data") of thisLine & return after x
>   end repeat
>   put "Time with custom prop:" && the long seconds - theStartTime
>   put empty into x
> -- Compare by saving the custom properties to variables
>    put the long seconds into theStartTime
>   get fld "Data"
>   add the colStudentName of fld "Data" into n
>   add the colTime of fld "Data" into t
>   add the colGrade of fld "Data" into g
>   repeat for each line thisLine in it
>     put item n of thisLine && \
>     item t of thisLine && \
>     item g of thisLine & return after x
>   end repeat
>   put return & "Time with variable:" && the long seconds -  
> theStartTime after msg
> end mouseUp
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the use-livecode mailing list