AddPackMemory()

Syntax

Result = AddPackMemory(MemoryAddress, Length [, CompressionLevel])
Description
Add and compress the specified memory area and add it to the current Pack previously created with CreatePack(). Adding a large memory area can take a long time with maximum compression level, but the unpack speed is very very fast (almost instantanious). 'CompressionLevel' is an optional value which can range from 0 (fastest, least compressed) to 9 (slowest, most compressed).

Example:

  Dim Tableau(10) ; Table of 11 elements
  
  ; Filling the table
  For i=0 To 10
    Tableau(i) = i
  Next
  
  If CreatePack("test.pak")
    ; Add and compresses the data of the table
    AddPackMemory(@Tableau(), SizeOf(Long)*11, 9)
    ClosePack()
  EndIf
  
  ; Setting the table contents to zero
  For i=0 To 10
    Tableau(i) = 0
  Next
  
  ; Open the packed file
  If OpenPack("test.pak")
    *Pointeur=NextPackFile() ; Read and decompresses the memory zone
    Taille=PackFileSize()    ; Get the size of the memory zone
    ; Copy the decompressed memory zone to the table
    CopyMemory(*Pointeur, @Tableau(), Taille)
    ClosePack()
  EndIf
  
  ; Reading the table
  For i=0 To 10
    Debug Tableau(i) 
  Next

Supported OS

All

<- AddPackFile() - Packer Index - ClosePack() ->