These are two handlers I use to send data between client and server in an app of mine, but might serve well enough for passing data around in those situations where you can't use arrays without trouble.

function serializeArray pArray
      repeat for each line L in keys(pArray)
            put L & "=" &  urlencode(pArray[L]) & cr after cArray
      end repeat
      delete char -1 of cArray
      return base64encode(compress(cArray))
end serializeArray

function unserializeArray pSerializedArray
      put decompress(base64decode(pSerializedArray)) into tArray
      split tArray by cr and "="
      repeat for each line L in keys(tArray)
            put urlDecode(tArray[L]) into tArray[L]
      end repeat
      return tArray
end unserializeArray

It's not very efficient in terms of data size for small arrays, but it's made things easy for the way I like to package up data (I use arrays a lot) to send to and from the server (running rev cgis).

Best,

Mark




On 26 Jun 2008, at 21:58, Jim Ault wrote:
Of course, for those who know and use customproperties, a custom property
set is the same thing as an array

----------- copy script lines and paste into the stack script ---------
on dotest

  put 42 into tMyArray["Vera"]
  put 67 into tMyArray["Chuck"]
  put "Dave" into tName
  put 123 into tValue

  set the custompropertyset of this stack to "tempStorArr"
  set the customproperties of this stack to tMyArray
  send "TestIt tName, tValue" to this stack
put the customproperties of this stack into tMyArray --update the array

  answer the tName of this stack  --show that it worked
  answer tMyArray[ tName]  --show that it worked

   --optional
set the custompropertyset of this stack to "tempStorArr" --just in case set the customproperties of this stack to empty ---purge the properties
end dotest


On TestIt  pName, pInt
  set the pName of this stack to pInt
  --use the array values for any other purpose
  --and can be used in any other handlers called in the message path

  answer the pName of this stack
  --save this stack -- the array is now saved with the stack file
end TestIt

----------- end copy script lines

Jim Ault
Las Vegas


On 6/26/08 1:21 PM, "Mark Wieder" <[EMAIL PROTECTED]> wrote:

Jim-

Or, more generically,

(button script)
on mouseUp
  local tMyArray
  local tName, tValue

  -- insert sample data
  put 42 into tMyArray["Vera"]
  put 42 into tMyArray["Chuck"]
  put "Dave" into tName
  put 123 into tValue
  combine tMyArray using cr and tab
  send "TestIt tMyArray, tName, tValue" to this stack
  put the result into tMyArray
  split tMyArray using cr and tab
  -- verify the test
  put the keys of tMyArray into field 1
end mouseUp

(stack script)
on TestIt pArray, pName, pInt
  split pArray using cr and tab
  put pInt into pArray[pName]
  combine pArray using cr and tab
  return pArray
end TestIt

...and thanks for the tip. This is way useful.


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to