Compress.String (gb.compress)

Function String ( Source As String [ , Level As Integer, AllowGrow As Boolean ] ) As String

This function returns a string compressed using the algorithm defined by the Type property.

  • Source: string to be compressed.

  • Level: compression level, a value from Min value to Max value. If this parameter is missing, the default will be used.

  • AllowGrow: If this parameter is missing, or you pass FALSE as value, this function will return a compressed string only if its length is lesser than the original (uncompressed) string length. If you pass TRUE, it will always return the compressed string. Note that almost all compression algorithms can really compress a string (reduce its length) only if it has clear patterns. Very short strings and random strings can hardly be compressed.

Examples

Dim Cz As New Compress
Dim Buf As String

Cz.Type = "bzlib2"

Buf = Cz.String(SourceString,Cz.Max,FALSE)

IF Len(Buf) < Len(SourceString) THEN
    PRINT "Compression successfully finished"
ELSE
    PRINT "Unable to compress that string"
END IF