incomprehensible bug!? (from an idea of: passing parameters in a send call)

Stephen Barncard stephenREVOLUTION at barncard.com
Tue May 23 12:12:06 EDT 2006


your use of stripping the returns from base64Encode is clever. I 
thought of that but wasn't sure how much one could mess with the 
format once encoded.

However URLEncoding is great for one-line-packing HTML snippets in 
scripts, which otherwise would require extra steps with base64Encode.

In my suggestions of encoding, I'm assuming moderate snippets of text 
rather than volumes are being moved this way, and the extra 
processing needed is minimal and invisible.

It's fast enough that I'm using packing/unpacking techniques like 
this to create a list on-the-fly and set the text of a popup button 
on mousedown, and it shows up in the popup menu.



>  Note that the URLEncoded suggested by Stephen is unnecessary and 
>will be an unnecessary overhead (the cr replaced by empty is faster 
>and takes less memory to convert the base64encoded string to one 
>line).
>
>Regards,
>
>AF
>
>
>
>function test1
>   local a,b
>   repeat with i=1 to the num of lines in fld 1
>     put line i of fld 1 into a[i]
>   end repeat
>   put imedarray_pack(a) into tPacked
>   put imedarray_unpack_1(tPacked) into b -- see the 
>imedarray_unpack_1() and imedarray_unpack_2() for clue
>   return imedarray_equal(a,b)
>end test1
>
>function test2
>   local a,b
>   repeat with i=1 to the num of lines in fld 1
>     put line i of fld 1 into a[i]
>   end repeat
>   put imedarray_pack(a) into tPacked
>   put imedarray_unpack_2(tPacked) into b -- see the 
>imedarray_unpack1() and imedarray_unpack2() for clue
>   return imedarray_equal(a,b)
>end test2
>
>
>function imedArray_pack pArray -- convert an array to a cr-delimited 
>string with <key>tab<base64encoding>
>   local r
>   repeat for each line k in the keys of pArray
>     get base64encode(pArray[k])
>     replace cr with empty in it
>     put k &tab& it &cr after r
>   end repeat
>   return r
>end imedArray_pack
>
>function imedArray_unpack_1 pPackedData -- convert back a packed 
>string to an array, version 1
>   local a
>   set the itemdel to tab
>   repeat with i=1 to the num of lines in pPackedData
>     put line i of pPackedData into tLine
>     put base64Decode(item 2 of tLine) into a[item 1 of tLine]
>   end repeat
>   return a
>end imedArray_unpack_1
>
>function imedArray_unpack_2 pPackedData -- convert back a packed 
>string to an array, version 2 (DONT RETURN CORRECT RESULT: BUG IN 
>THE REV ENGINE?)
>   local a
>   set the itemdel to tab
>   repeat for each line tLine in pPackedData
>     put base64Decode(item 2 of tLine) into a[item 1 of tLine]
>   end repeat
>   return a
>end imedArray_unpack_2
>
>function imedArray_equal a,b,pCaseSensitive -- test if two arrays 
>have the same keys and same content
>   put the keys of a into tkeys
>   if the number of lines in tKeys is not the num of lines in the 
>keys of b then return false
>   set the caseSensitive to pCaseSensitive is true
>   repeat for each line tk in tKeys
>     if a[tk] is not b[tk] then return false
>   end repeat
>   return true
>end imedArray_equal
>
>
>
>>Date: Mon, 22 May 2006 20:50:13 -0700
>>From: Stephen Barncard <stephenREVOLUTION at barncard.com>
>>Subject: Re: passing parameters in a send call.
>>...
>>
>>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"
>>
>>...
>>
>>sqb
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your 
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution


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



More information about the Use-livecode mailing list