Here is a better arranged version of the string based function:


This works with [1][2][3] kinds of data points:

on mouseUp
local yourData
put "<[1][1]>Things about bob.</[1][1]>" & return into yourData
put "<[1][1][1]>Bob has a big coat.</[1][1][1]>" & return after yourData
put "<[1][1][2]>Bob has a big goat.</[1][1][2]>" & return after yourData


  -- example calls:
  put empty into bobStuffHere
  put getArrayData(yourData, "[1][1][1]") into foundThis
  put foundThis & return into bobStuffHere

  put "Bob has a small cat." into tData
  put putArrayData(yourData, "[1][1][1]", tData) into yourData

  put getArrayData(yourData,"[1][1][1]") into foundThis
  put foundThis & return after bobStuffHere

  put "Bob has a small dog." into tData
  put putArrayData(yourData, "[1][1][3]", tData) into yourData

  answer bobStuffHere
  put yourData
end mouseUp

function getArrayData stngToSch, tStTag
  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

function putArrayData stngToSch, tStTag, 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

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to