Sample code for 30+ languages & platforms
PowerBuilder

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Bz2

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Bz2 = create oleobject
li_rc = loo_Bz2.ConnectToNewObject("Chilkat.Bz2")
if li_rc < 0 then
    destroy loo_Bz2
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
li_Success = loo_Bz2.CompressFile("qa_data/hamlet.xml","qa_output/hamlet.bz2")
if li_Success <> 1 then
    Write-Debug loo_Bz2.LastErrorText
    destroy loo_Bz2
    return
end if

Write-Debug "Success."


destroy loo_Bz2