Who can understand why the test1() function will return TRUE and test2
() FALSE with the script below?
The only difference is in looping each line of the string pPackedData :
- either with : repeat with i=1 to the num of lines in pPackedData --
in imedArray_unpack_1()
- or with : repeat for each line tLine in pPackedData -- in
imedArray_unpack_2()
To test, create a field (number 1 in the script below) and put into
it a text with many paragraphs, then put the script below in the
card, type test1() or test2() in the message box.
Please confirm that you reproduce the result of TRUE for test1() and
FALSE for test2(). If yes I will fill a bug in Revzilla, if you get
TRUE in both case I will have to first reinstall Revolution on
MacOSX... or do you see a bug of my own?
Of course you can freely use these scripts as yours to pass the
packed data of an array in a send or call command but use the
imedArray_unpack1 which gives the correct result presently. 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 <[EMAIL PROTECTED]>
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:
"cCnB1dCBsaWJTUUJfcmV0dXJuUmVsU3RhY2tBZGRyZXNzZXMoInRydWUiKSBpbnRvIHRT
dGFj%0D%0"
using this code:
put URLEncode(base64Encode(fld "disclosure")) into fld "output2"
...
sqb
_______________________________________________
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