Efficient code for accessing the items (or lines) in a variable.
dick.kriesel at mail.com
Sun Feb 20 04:07:28 EST 2011
On 2/19/11 4:44 PM, "Alex Tweedly" <alex at tweedly.net> wrote:
>> put 1 into tCurrentItemCharOffset
>> repeat with i = 1 to the number of items in tData
>> ... item 1 of (char tCurrentItemCharOffset to -1 of tData) ...
>> add the number of chars in item 1 of (char tCurrentItemCharOffset
>> to -1 of tData) + 1 to tCurrentItemCharOffset
>> end repeat
Hi, Alex. Since technique 3 involves counting the items and then for each
item twice extracting a substring, perhaps a technique 4 is worth comparing:
put 1 into tOffset
repeat forever -- no counting the items
put item 1 of (char tOffset to -1 of tData) into tItem -- single
extraction per item
if tItem is empty then
add (the number of chars in tItem) + 1 to tOffset
-- do something useful with tItem
Is it any faster on your data?
More information about the Use-livecode