Contents
sfZip
Overview
sfZip is a Dyalog namespace that shows examples on how to use the Syncfusion ZipArchive library. This library can be used to Zip and UnZip text and file(s) on disk.
Installation and deployment
The following assemblies (version 12.2 or newer) are required in the subdirectory /Syncfusion/4.5 of the Dyalog APL version 14 (or newer) directory:
- Syncfusion.Compression.Base.dll
How to Zip and UnZip text
The functions ZipText and UnZipText are able to compress/decompress unicode character variable of the workspace.
MyText ← 'This is a test: ⍺⌈⌊_∇∆∘⎕⍎⋄⊢→←*○⍳↓↑~⍴∊∊⍵?' MyTextZipped←ZipText MyText MyText ≡ UnZipText MyTextZipped 1
How to Zip and UnZip a file on disk
The functions ZipFile and UnZipFile are able to compress/decompress an existing file on disk.
ZipFile 'D:\MyFile.dyalog' ⍝ The file D:\MyFile.zip has been created successfully 1 r ← UnZipFile 'D:\MyFile.zip' ⍝ The unzip content of D:\MyFile.zip is in the variable 'r'
How to Zip and UnZip a Namespace of Characters
Sometimes you want to be able to store a multitude of character vector representing scripted namespaces, xaml vectors, config files, ini files, serialized apldata to XML/JSON, etc. The function AplToZipFile is able to save/retrieve a Dyalog namespace containing only characters to a zip file. It is also able to retrieve only a part of the namespace without UnZipping the whole file. For examples you could store the configuration and ini files of your application in a namespace that is written to disk with an extension other than zip (ex. cfg). That way at runtime you can change the extension to zip, inspect/change the configuration file and change back the extension to cfg. That way the end user does not have access to the config/ini files and at the same time you can change them easily.
Config←⎕NS '' Config.text1←'this is text one' Config.text2←'this is text two' Config.text3←'this is text three' Config AplToZipFile 'D:\MyConfig.cfg' 1 'text2' AplToZipFile 'D:\MyConfig.cfg' 1 this is text two r ← 2⊃AplToZipFile 'D:\MyConfig.cfg' r.text1 this is text one r.text2 this is text two r.text3 this is text three
How to install sfZip in your workspace
Download sfZip.v1.1.txt
- Do a Select all (Ctrl+A) and a copy (Ctrl+C).
In your workspace execute )ed ⍟ sfZip
- Paste (Ctrl+V) the text into the Dyalog editor
- Press Escape and ')save' your workspace
Optionally to de-script the namespace you can do:
#.sfZip←{('n' ⎕NS ⍵)⊢n←⎕NS ''}#.sfZip
Version Information
Version 1.0 December 2014 Version 1.1 September 2015 UnZipFile updated to open multiple items with decoding
Version Information
Original author: |
Pierre Gilbert |
Responsible: |
|
Email: |
<apgil AT SPAMFREE videotron DOT ca> |
CategoryDyalog - CategoryDyalogDotNet - CategorySyncfusionWpfExamples - CategoryDotNet