passing parameters in a send call.

Stephen Barncard stephenREVOLUTION at barncard.com
Mon May 22 23:50:13 EDT 2006


Andre - the way I 'fake' an array when I have to pass it through, 
say, dialogData, is this way.


I turn the array into a list with lines like this. The secret is to 
encode the data to fit on one line per record, using tab as a delim.

keyName  <tab> <data>

URLEncoded data looks like this on a line:
"--put+the+scriptsOfFocus+of+this+stack+into+tStackList%"

This line was base64Encoded, then URLEncoded on to one line:
"cCnB1dCBsaWJTUUJfcmV0dXJuUmVsU3RhY2tBZGRyZXNzZXMoInRydWUiKSBpbnRvIHRTdGFj%0D%0"

using this code:
put URLEncode(base64Encode(fld "disclosure")) into fld "output2"

As long as the data block for each record is on one line, this array 
will go anywhere.


The data could be converted to URLEncoded for text or Base64Encoded 
(followed by URLEncode) for binary. The idea is to convert the data 
record to something that rests on one line. Each line is an element 
of the array.

I've been using this method a lot for getting data into and out of 
complex dialogs, as well as super-efficient and bulletproof custom 
property storage.  The use of 'repeat for each' loops will speed this 
all up.

I also use URLEncode with HTML text to put a constant for the dialog 
in one line, and unpack on opening the dialog.

this should work as long as the data is not wider than 64k characters.

sqb


>My problem with all those approaches is that I need to pass an 
>array. I can't "combine" the array because the array holds all kinds 
>of HTTP header data and MIME data from the body. Since the body of 
>an HTTP request might hold binary data, I can't afford to combine 
>the data because the splitters I use might be present in some array 
>element thus rendering the "split" command useless.
>
>I could use a global, but, we can't nest arrays in Rev and I am 
>working with multiple HTTP connections. So what I am doing now is 
>holding everything in a global array. Each key has the format of a 
>uniqueID & keyName, this way I can fetch the key elements for a 
>given HTTP connection by filtering the keys with the uniqueID. This 
>is far from optimum approach and I welcome any advise on the topic.
>
>I used send before to pass strings to handlers outside the "usual" 
>message path. I thought that I could use the same technique with 
>arrays, guess I can't till we have a different array implementation 
>in Rev. I could use a box-like approach as used by Dar Scott to 
>generate strings that could hold multiple values. but this would add 
>new API to my supposed-to-be easy module. So I used the described 
>technique of a global array and a function that you pass a unique id 
>and it returns an array with the values that belong to that id. The 
>unique id is passed as a string in the send call. This is known to 
>work.
>
>its a hack, but it is working.
>
>Thanks everyone for the input.
>
>andre

-- 
stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -


More information about the use-livecode mailing list