PackMemory error

Just starting out? Need help? Post your questions and find answers here.
Jose
User
User
Posts: 34
Joined: Sat Apr 26, 2003 9:20 pm

PackMemory error

Post 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
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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..
Jose
User
User
Posts: 34
Joined: Sat Apr 26, 2003 9:20 pm

Post by Jose »

Thanks Pupil, it works with longer string.
Post Reply