FoxPro Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Amazon S3
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

(Visual FoxPro) Streaming Deflate String

Demonstrates streaming string compression using the Deflate algorithm. Data may be compressed in chunks by initially calling one of the BeginCompress* methods, followed by 0 or more calls to a MoreCompress* method, and terminating with a call to an EndCompress* method.

Likewise, data may be decompressed by calling a BeginDecompress* method, followed by 0 or more MoreDecompress* calls, and ending with an EndDecompress* method call.

This example demonstrates string-to-string deflate compression and decompression in chunks.

(The deflate algorithm is most commonly used by the .zip file format.)

Download Chilkat Compression ActiveX

LOCAL loCompress
LOCAL lnSuccess
LOCAL lcStrData
LOCAL i
LOCAL lcStrCompressed
LOCAL lcStrOriginal
LOCAL lcChunk1
LOCAL lcChunk2
LOCAL lcChunk3
LOCAL lcChunk4

loCompress = CreateObject('Chilkat.Compression')

*  Any string argument automatically begins a 30-day trial.

lnSuccess = loCompress.UnlockComponent("30-day trial")
IF (lnSuccess <> 1) THEN
    ? loCompress.LastErrorText
    QUIT
ENDIF

loCompress.Algorithm = "deflate"
loCompress.Charset = "ansi"
loCompress.EncodingMode = "base64"

*  Create a long string to compress.
lcStrData = "abcdefg1122334455667788"
lcStrData = lcStrData + CHR(13)+CHR(10)

*  Note: BeginCompressStringENC may return a zero-length
*  string.  This is normal if the input is buffered and no
*  compressed data is yet available.
*  However, a null reference indicates an error -- which is
*  generally only possible if the component was never unlocked.
lcStrCompressed = loCompress.BeginCompressStringENC(lcStrData)

*  Compress 100 more chunks of data.  Each call to
*  MoreCompressStringENC may or may not produce additional
*  compressed output.
FOR i = 0 TO 99
    lcStrData = "abcdefg1122334455667788"
    lcStrData = lcStrData + CHR(13)+CHR(10)

    lcStrCompressed = lcStrCompressed + loCompress.MoreCompressStringENC(lcStrData)
NEXT

*  Finalize the compression with a single call to EndCompressStringENC:
lcStrCompressed = lcStrCompressed + loCompress.EndCompressStringENC()

*  Display the compressed string.
*  The result will be:
*  S0xKTklNSzc0NDIyNjYxMTU1MzM3t7Dg5UoclRiVGJUYlRiVGJUYlRiVGJUYchIA

? lcStrCompressed

*  Decompress back to the original in a single call.

lcStrOriginal = loCompress.DecompressStringENC(lcStrCompressed)

*  Display the uncompressed original:
? "--- Original ---"
? lcStrOriginal

*  Inflate in multiple calls.  It doesn't matter how the
*  compressed data is split -- it could be fed to the decompressor
*  one char at a time if desired.

lcChunk1 = "S0xKTklNSzc0ND"

lcChunk2 = "Iy"

lcChunk3 = "NjYxMTU1MzM3t7Dg5UoclRiV"

lcChunk4 = "GJUYlRiVGJUYlRiVGJUYchIA"

lcStrOriginal = ""
lcStrOriginal = loCompress.BeginDecompressStringENC(lcChunk1)
lcStrOriginal = lcStrOriginal + loCompress.MoreDecompressStringENC(lcChunk2)
lcStrOriginal = lcStrOriginal + loCompress.MoreDecompressStringENC(lcChunk3)
lcStrOriginal = lcStrOriginal + loCompress.MoreDecompressStringENC(lcChunk4)
lcStrOriginal = lcStrOriginal + loCompress.EndDecompressStringENC()

*  Display the uncompressed original after inflating in chunks:
? "--- Original after Inflating from Chunks ---"
? lcStrOriginal

© 2000-2013 Chilkat Software, Inc. All Rights Reserved.