[ANN] Democratic Revolution

Mark Brownell gizmotron at earthlink.net
Fri Aug 29 10:39:01 EDT 2003


On Friday, August 29, 2003, at 07:34  AM, Mark Brownell wrote:

> I might be able to speed the transcript parallel numerical array 
> builder by converting it to a single loop process.

Yep. As a single looping function it builds an array of elements-found 
about 33% faster.

> If I were to get what I'm really looking for it would be:
>
> getPNLPelements(startTag, endTag, stringToSearch) used like this to 
> get an array of elements from a structured document like XML:
>
> put "<record" into tStartT
> put "</record>" into tEndT
> put getPNLPelements(tStartT, tEndT, stringToSearch) into myArray
>
> used like this:
> put myArray[1]
> -- transactionNumber="1234567" firstname="Bob" lastname="Smith">item# 
> abc123
>
> where:
> <record transactionNumber="1234567" firstname="Bob" 
> lastname="Smith">item# abc123</record>
> were used as the first instance.

I ran this in the frogBreath.rev tester and got 6 to 7 milliseconds 
while getting 11 to 12   milliseconds using the three loop PNLP method.

put getPNLPelements("<record>", "</record>", tZap) into theArray

function getPNLPelements tStartTag, tEndTag, StringToSearch
   put empty into tArray
   put 0 into tStart1
   put 0 into tStart2
   put 1 into tElementNum
   put the number of chars in tStartTag into dChars
   repeat
     put offset(tStartTag,StringToSearch,tStart1) into tNum1
     put (tNum1 + tStart1) into tStart1
     if tNum1 < 1 then exit repeat
     put offset(tEndTag,StringToSearch,tStart2) into tNum2
     put (tNum2 + tStart2) into tStart2
     if tNum2 < 1 then exit repeat
     --if tNum2 < tNum1 then exit repeat
     put char (tStart1 + dChars) to (tStart2 - 1) of StringToSearch into 
zapped
     put zapped into tArray[tElementNum]
     add 1 to tElementNum
   end repeat
   return tArray
end getPNLPelements




More information about the use-livecode mailing list