Speeding up array initialization
Mark Brownell
gizmotron at earthlink.net
Sat Nov 22 20:48:48 EST 2003
I'm kind of busy trying to integrate macToISO binary data with plain
text for cross platform encryption data for file storage. It was the
national past time on the Director users-list to solve list (array)
issues... no prizes where ever awarded anyway.
So How about this idea?
Store data like this as plain text: in the Var (yourData)
on mouseUp
put "<yourData[1][1]>Things about bob.</yourData[1][1]>" & return
into yourData
put "<yourData[1][1][1]>Bob has a big coat.</yourData[1][1][1]>" &
return after yourData
put "<yourData[1][1][2]>Bob has a big goat.</yourData[1][1][2]>" &
return after yourData
-- example calls:
put empty into bobStuffHere
put getArrayData("yourData[1][1][1]", yourData) into foundThis
put foundThis & return into bobStuffHere
put "Bob has a small cat." into tData
put putArrayData("yourData[1][1][1]", yourData, tData) into yourData
put getArrayData("yourData[1][1][1]", yourData) into foundThis
put foundThis & return after bobStuffHere
put "Bob has a small dog." into tData
put putArrayData("yourData[1][1][3]", yourData, tData) into yourData
answer bobStuffHere
put yourData
end mouseUp
-- put getArrayData("yourData[1][1][1]", yourData) into foundThis
function getArrayData tStTag, stngToSch
put empty into zapped
put "<" & tStTag & ">" into sTag
put "</" & tStTag & ">" into eTag
put the number of chars in sTag into dChars
put offset(sTag,stngToSch) into tNum1
put offset(eTag,stngToSch) into tNum2
if tNum1 < 1 then
return "error"
exit getArrayData
end if
if tNum2 < 1 then
return "error"
exit getArrayData
end if
put char (tNum1 + dChars) to (tNum2 - 1) of stngToSch into zapped
return zapped
end getArrayData
-- put putArrayData("yourData[1][1][1]", yourData, tData) into yourData
function putArrayData tStTag, stngToSch, dataToPut
put empty into zapped
put "<" & tStTag & ">" into sTag
put "</" & tStTag & ">" into eTag
put sTag & dataToPut & eTag into changeZap
put the number of chars in sTag into dChars
put offset(sTag,stngToSch) into tNum1
put offset(eTag,stngToSch) into tNum2
if tNum1 < 1 then
put changeZap after stngToSch
return stngToSch
exit putArrayData
end if
if tNum2 < 1 then
put changeZap after stngToSch
return stngToSch
exit putArrayData
end if
put char tNum1 to (tNum2 + dChars + 1) of stngToSch into zapSpot
replace zapSpot with changeZap in stngToSch
return stngToSch
end putArrayData
More information about the use-livecode
mailing list