$GZip: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$GZip}} | {{DISPLAYTITLE:$GZip}} | ||
<span class="pageSubtitle"><section begin="desc" />Compress a longstring with | <span class="pageSubtitle"><section begin="desc" />Compress a longstring with GZip<section end="desc" /></span> | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the [[GZip (String function)]].</p> | |||
This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. The GZIP format is described in RFC 1952. It is very effective with HTML and XML data. | This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. The GZIP format is described in RFC 1952. It is very effective with HTML and XML data. | ||
Line 16: | Line 14: | ||
<p class="caption">%lstrc is the returned longstring.</p> | <p class="caption">%lstrc is the returned longstring.</p> | ||
The first argument is the longstring to be compressed, and it is required. | |||
The | The second argument is a string or integer value that describes the type of compression to perform on the longstring. This argument is optional; if it is not specified, DYNAMIC (type 2) compression is used. | ||
==Compressions Options== | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>FIXED</th> | <tr><th>FIXED</th> | ||
Line 27: | Line 27: | ||
<tr><th>0-6</th> | <tr><th>0-6</th> | ||
<td>Indicates the type of compression used. Specifying <tt>0</tt> indicates the default should be used, which is the same as specifying <tt>DYNAMIC</tt>. Values 1 through 6 specify a tradeoff in speed and compression factor: The value <tt>1</tt> uses the least CPU and compresses the string quickly; the value <tt>6</tt> uses the most CPU but gets the best compression. Higher numbers may increase the CPU considerably without significantly improving the compression. | <td>Indicates the type of compression used. Specifying <tt>0</tt> indicates the default should be used, which is the same as specifying <tt>DYNAMIC</tt>. Values 1 through 6 specify a tradeoff in speed and compression factor: The value <tt>1</tt> uses the least CPU and compresses the string quickly; the value <tt>6</tt> uses the most CPU but gets the best compression. Higher numbers may increase the CPU considerably without significantly improving the compression. | ||
</td></tr></table> | </td></tr> | ||
</table> | |||
The third argument, an optional string, contains the internal name of the compressed string. Decompression programs will use this name for the output file when the string is un-zipped. The maximum length of the filename is 32 bytes. | The third argument, an optional string, contains the internal name of the compressed string. Decompression programs will use this name for the output file when the string is un-zipped. The maximum length of the filename is 32 bytes. | ||
Line 35: | Line 35: | ||
<li>.YY-MM-DD HH:MI:SS:elit.. If a two-digit year is supplied, the CENTSPAN (:hdref reftxt=CENTSPAN refid=cspan.) value used is 75. | <li>.YY-MM-DD HH:MI:SS:elit.. If a two-digit year is supplied, the CENTSPAN (:hdref reftxt=CENTSPAN refid=cspan.) value used is 75. | ||
Usage notes | ==Usage notes== | ||
<ul> | <ul> | ||
<li> If an invalid option is passed, or if compression is not enabled for the current run, the request is cancelled. | <li> If an invalid option is passed, or if compression is not enabled for the current run, the request is cancelled. | ||
<li> The NCMPBUF parameter must be set by User 0 before the $GZip function can be used. If $GZip is called with NCMPBUF = 0, the request is cancelled. | <li> The NCMPBUF parameter must be set by User 0 before the $GZip function can be used. If $GZip is called with NCMPBUF = 0, the request is cancelled. | ||
Line 44: | Line 44: | ||
<li> Multiple files are not currently supported. | <li> Multiple files are not currently supported. | ||
==Examples== | |||
In the following example, | In the following example, | ||
Line 67: | Line 68: | ||
<p class="caption">Products authorizing $GZip | <p class="caption">Products authorizing $GZip | ||
</p> | </p> | ||
[[Category:$Functions|$GZip]] | [[Category:$Functions|$GZip]] |
Revision as of 17:30, 1 February 2011
<section begin="desc" />Compress a longstring with GZip<section end="desc" />
Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $GZip function is the GZip (String function).
This function compresses a longstring using the "deflate" algorithm. The deflate algorithm is described completely in RFC 1951. The GZIP format is described in RFC 1952. It is very effective with HTML and XML data.
The $GZip function accepts four arguments and returns a longstring result.
Syntax
<section begin="syntax" /> %lstrc = $GZip(%lstr, level, filename, datetime) <section end="syntax" />
The first argument is the longstring to be compressed, and it is required.
The second argument is a string or integer value that describes the type of compression to perform on the longstring. This argument is optional; if it is not specified, DYNAMIC (type 2) compression is used.
Compressions Options
FIXED | Indicates that compression is done with fixed codes. The fixed code tables used for compression (defined as part of RFC 1951) are somewhat optimized for ASCII character data, but slightly decrease the amount of CPU required to perform compression. Also, since the codes are already defined as part of the specification, they are not included in the compressed data. |
---|---|
DYNAMIC | Indicates that the compression code tables are generated based on the input data. Dynamic tables typically provide somewhat better compression on most types of data. There is a very slight CPU overhead in computing the frequencies of byte values in the input data. Also, since the code tables are dynamic, they are included as part of the compressed data. This will increase the size of the compressed longstring, but these tables are small, since they are also stored in a compressed form. |
0-6 | Indicates the type of compression used. Specifying 0 indicates the default should be used, which is the same as specifying DYNAMIC. Values 1 through 6 specify a tradeoff in speed and compression factor: The value 1 uses the least CPU and compresses the string quickly; the value 6 uses the most CPU but gets the best compression. Higher numbers may increase the CPU considerably without significantly improving the compression. |
The third argument, an optional string, contains the internal name of the compressed string. Decompression programs will use this name for the output file when the string is un-zipped. The maximum length of the filename is 32 bytes.
The fourth argument, an optional string, contains the file modification date and time. This must be a string in the format YYYY-MM-DD HH:MI:SS:elit. or
Usage notes
- If an invalid option is passed, or if compression is not enabled for the current run, the request is cancelled.
- The NCMPBUF parameter must be set by User 0 before the $GZip function can be used. If $GZip is called with NCMPBUF = 0, the request is cancelled.
- As with any compression scheme, it is possible that a particular string will become longer after compression. This would happen, for example, if a deflated string were passed to $GZip.
- Short strings (less than 128 bytes) will typically compress better with the FIXED option.
- Multiple files are not currently supported.
Examples
In the following example,
- .%lsgz is set to the compressed version of the given string:
%ls = 'Ive got sunshine on a cloudy day' %dt = $date and $time %lsgz = $GZip(%ls, 6, 'mygirl.txt', %dt)
No other string or longstring functions (except copy) can be usefully performed on the compressed string until it is decompressed with $GunZip (:hdref reftxt=$GUNZIP refid=$gunzip.). :enote