I can't say definitively, but I think the problem may be a minimum length issue. In testing your code using ASCII strings comprised of random lower case [a...z] characters, the minimum length was 128 before it would work. Even so, it failed approximately three out of four times, and when it did succeed, the resulting packed length was ~130 bytes.
There is also an error in your code. The source parameter for UnpackMemory() is the packed memory. Change this:
Code: Select all
If (res)
res = UnpackMemory(*srcMem, *destMem)
PrintN("UnPack Result = " + Str(res))
EndIf
to this:
Code: Select all
If (res)
res = UnpackMemory(*destMem, *srcMem)
PrintN("UnPack Result = " + Str(res))
EndIf
This is what I used to test:
Code: Select all
OpenConsole()
PrintN("")
For i = 1 To 128
src.s + Mid("abcdefghijklmnopqrstuvwxyz", Random(25) + 1, 1) ;"This is a testing line string."
Next i
srcLen = Len(src)
*srcMem = AllocateMemory(srcLen + 1)
*destMem= AllocateMemory(srcLen+100)
PokeS(*srcMem, src)
res = PackMemory(*srcMem, *destMem, srcLen)
PrintN(src)
PrintN("Pack Result = " + Str(res))
If (res)
res = UnpackMemory(*destMem, *srcMem)
PrintN("UnPack Result = " + Str(res))
EndIf
PrintN(PeekS(*srcMem, srcLen))
FreeMemory(*srcMem)
FreeMemory(*destMem)
Input()
CloseConsole()
HTH,
Clutch
EDIT: Nevermind.. I just tried this with a single-character-length string and it worked. The resulting memory was 14 bytes in length, but it did work.
"Ahead one third... ahead two thirds... Full ahead flank
And out from the belly of the whale came a prophet, Amen"