Page 1 of 1

PackMemory error

Posted: Fri Jul 25, 2003 1:11 am
by Jose
Hi All,

Ok this one has me scratching my head, and my head is getting very red...

This simple test just saves a string into memory, then tries to pack that memory and unpack it, but fails to unpack.

Can anyone tell me what I am doing wrong here, Please...

Code: Select all

sText.s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
nLen.l = Len(sText)

If nLen And AllocateMemory(0,nLen, 0) And AllocateMemory(1,nLen+8, 0)

  PokeS(UseMemory(0), sText)

; fails on next line
  nPackLen.l = PackMemory(UseMemory(0), UseMemory(1), nLen, 9)
  If nPackLen <> 0 

    AllocateMemory(2,nLen+8, 0)

    nUnPackLen.l = UnpackMemory(UseMemory(1), UseMemory(2))

    sNewText.s = PeekS(UseMemory(2),nUnPackLen)

    Debug "Result:" + sNewText

  Else
    Debug "Pack Mem Failed"
  EndIf
Else
  Debug "No Mem Allocated"
EndIf
Can anyone make this work, many Thanks

Posted: Fri Jul 25, 2003 9:39 am
by Pupil
For me it fails to pack the memory, you should maybe use a longer string or a more repetetive string so you actually gain when trying to pack..

Posted: Fri Jul 25, 2003 5:57 pm
by Jose
Thanks Pupil, it works with longer string.