![]() |
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
(Visual FoxPro) 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.
LOCAL lnSuccess LOCAL loBdCompressed LOCAL loCompress LOCAL loSbUncompressedChunk LOCAL i LOCAL loBdDecompressed LOCAL lcOriginalText lnSuccess = 0 * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loBdCompressed = CreateObject('Chilkat.BinData') loCompress = CreateObject('Chilkat.Compression') loCompress.Algorithm = "deflate" loCompress.Charset = "utf-8" loSbUncompressedChunk = CreateObject('Chilkat.StringBuilder') loCompress.FirstChunk = 1 loCompress.LastChunk = 0 FOR i = 0 TO 24 IF (i = 24) THEN loCompress.LastChunk = 1 ENDIF loSbUncompressedChunk.Clear() loSbUncompressedChunk.AppendInt(i) loSbUncompressedChunk.Append(": This is a line of data to be compressed..." + CHR(13) + CHR(10)) loCompress.CompressSb(loSbUncompressedChunk,loBdCompressed) loCompress.FirstChunk = 0 NEXT * Show the compressed data in hex format: ? "The hex encoded compressed text:" ? loBdCompressed.GetEncoded("hex") * Now decompress in one call. It is important to set both FirstChunk and LastChunk = 1 loBdDecompressed = CreateObject('Chilkat.BinData') loCompress.FirstChunk = 1 loCompress.LastChunk = 1 lnSuccess = loCompress.DecompressBd2(loBdCompressed,loBdDecompressed) IF (lnSuccess = 0) THEN ? loCompress.LastErrorText RELEASE loBdCompressed RELEASE loCompress RELEASE loSbUncompressedChunk RELEASE loBdDecompressed CANCEL ENDIF lcOriginalText = loBdDecompressed.GetString("utf-8") ? lcOriginalText RELEASE loBdCompressed RELEASE loCompress RELEASE loSbUncompressedChunk RELEASE loBdDecompressed |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.