Compress.String
(gb.compress)
Syntax
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, 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 original (uncompressed) string length. If you pass TRUE, it always will 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 hardly can be compressed.
Example
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