![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Compress Text Feed to BinaryThis example receives incoming text data in chunks, compresses as a stream, and accumulates the compressed binary data. Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc integer li_Success oleobject loo_BdCompressed oleobject loo_Compress oleobject loo_SbUncompressedChunk integer i oleobject loo_BdDecompressed string ls_OriginalText li_Success = 0 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_BdCompressed = create oleobject li_rc = loo_BdCompressed.ConnectToNewObject("Chilkat.BinData") if li_rc < 0 then destroy loo_BdCompressed MessageBox("Error","Connecting to COM object failed") return end if loo_Compress = create oleobject li_rc = loo_Compress.ConnectToNewObject("Chilkat.Compression") loo_Compress.Algorithm = "deflate" loo_Compress.Charset = "utf-8" loo_SbUncompressedChunk = create oleobject li_rc = loo_SbUncompressedChunk.ConnectToNewObject("Chilkat.StringBuilder") loo_Compress.FirstChunk = 1 loo_Compress.LastChunk = 0 for i = 0 to 24 if i = 24 then loo_Compress.LastChunk = 1 end if loo_SbUncompressedChunk.Clear() loo_SbUncompressedChunk.AppendInt(i) loo_SbUncompressedChunk.Append(": This is a line of data to be compressed...~r~n") loo_Compress.CompressSb(loo_SbUncompressedChunk,loo_BdCompressed) loo_Compress.FirstChunk = 0 next // Show the compressed data in hex format: Write-Debug "The hex encoded compressed text:" Write-Debug loo_BdCompressed.GetEncoded("hex") // Now decompress in one call. It is important to set both FirstChunk and LastChunk = 1 loo_BdDecompressed = create oleobject li_rc = loo_BdDecompressed.ConnectToNewObject("Chilkat.BinData") loo_Compress.FirstChunk = 1 loo_Compress.LastChunk = 1 li_Success = loo_Compress.DecompressBd2(loo_BdCompressed,loo_BdDecompressed) if li_Success = 0 then Write-Debug loo_Compress.LastErrorText destroy loo_BdCompressed destroy loo_Compress destroy loo_SbUncompressedChunk destroy loo_BdDecompressed return end if ls_OriginalText = loo_BdDecompressed.GetString("utf-8") Write-Debug ls_OriginalText destroy loo_BdCompressed destroy loo_Compress destroy loo_SbUncompressedChunk destroy loo_BdDecompressed |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.