Compress
PowerScript function
Description
Compresses the folder or one or more files, or the byte data
stream.
Applies to
CompressorObject objects
Syntax
|
1 |
objectname.Compress ( string source, string dest {, ArchiveFormat format }) |
|
1 |
objectname.Compress ( string source[], string dest {, ArchiveFormat format }) |
|
1 |
objectname.Compress ( blob source, ref blob dest {, ArchiveFormat format }) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the CompressorObject |
|
source |
A string whose value is the full directory of the Or a blob whose value is the byte data |
|
dest |
A string whose value is the target directory where Or a |
|
format (optional) |
A value of the enumerated datatype ArchiveFormat
If the extension in “dest” is inconsistent |
Return value
Integer.
Returns the following value. If any argument’s value is null, the
method returns null.
1 — Success
-1 — A general error occurred. If the CompressorObject object is
used in asynchronous mode, this function will return the general
error.
-2 — The password entered is illegal.
-3 — The operation is not supported for the source file
format.
-4 — The task thread is aborted.
-5 — A task thread is currently running.
-6 — The folder to be compressed does not exist.
-7 — The folder to be compressed is empty.
-8 — The compression format does not support multi-file
compression.
-9 — Failed to read file from the folder for compression.
-10 — The target path does not exist.
-11 — The compressed file cannot be saved to the directory where a
file of the same name already exists.
-12 — Failed to compress.
Example 1
This example demonstrates how to compress a folder.
|
1 2 3 4 5 6 7 |
CompressorObject lnv_compress Integer li_return string ls_source, ls_target ls_source = "C:Program Files (x86)AppeonSharedPowerBuilder heme180" ls_target = "D: estcom" lnv_compress = create CompressorObject li_return = lnv_compress.Compress(ls_source,ls_target, ArchiveFormat7Zip!) |
Example 2
This example demonstrates how to compress a single file.
|
1 2 3 4 5 6 7 |
CompressorObject lnv_compress Integer li_return string ls_source, ls_target ls_source = "C:Program Files (x86)AppeonSharedPowerBuilderegreg.txt" ls_target = "D: estcom" lnv_compress = create CompressorObject li_return = lnv_compress.Compress(ls_source,ls_target, ArchiveFormat7Zip!) |
Example 3
This example demonstrates how to compress multiple files.
|
1 2 3 4 5 6 7 8 |
CompressorObject lnv_compress Integer li_return string ls_source[], ls_target ls_source[1] = "C:Program Files (x86)AppeonSharedPowerBuilderegreg.txt" ls_source[2] = "C:Program Files (x86)AppeonSharedPowerBuilderzlib.dll" ls_target = "D: estcom" lnv_compress = create CompressorObject li_return = lnv_compress.Compress(ls_source,ls_target, ArchiveFormat7Zip!) |
Example 4
This example demonstrates how to compress the data stream.
|
1 2 3 4 5 6 7 |
CompressorObject lnv_compress Integer li_return blob lb_source,lb_target lb_source = blob("A123456") lnv_compress = create CompressorObject li_return = lnv_compress.Compress(lb_source,lb_target, ArchiveFormat7Zip!) |
See also