Differences between revisions 11 and 63 (spanning 52 versions)
Revision 11 as of 2008-04-25 14:21:03
Size: 5169
Editor: KaiJaeger
Comment:
Revision 63 as of 2016-09-13 15:27:22
Size: 1957
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= WinZip =
`WinZip` is part of the CategoryAplTree project.

<<TableOfContents>>

|| !WinZip was once a part of the CategoryAplTree project before it was suspended in September 2016.||

The reason is that it does not behave when installed under a modern Windows system: it retires some OS-system DLLs, and it does not even bring them back when un-installed. In other words. it compromises a Windows system. See SevenZip as an alternative.

== Warning ==

Note that WinZip issues an error when you pass something like this with the flag to preserve the directory structure:

{{{
C:\My\folder1\file.txt
C:\My\folder2\file.txt
}}}

According to the company behind !WinZip this is nit a bug but by design. Therefore `WinZip` will issue a DOMAIN ERROR if you have to files with the same name in your list of files to be zipped.
Line 3: Line 23:
[[TableOfContents]] The class "WinZip" relies on an installed version of [[http://winzip.com/win/en/index.htm |WinZip]] '''and''' the command line extension. If both are installed on your machine then will will have the two executables `WZZIP.EXE` (for zipping) and `WZUNZIP.EXE` (for unzipping) somewhere, typically in C:\Program Files (x86)\WinZip.
Line 5: Line 25:
INI files are still useful to provide settings to an application. Vista is not going to change this. The class makes it very easy to zip as well as unzip stuff.
Line 7: Line 27:
The Windows API methods provided to read a particular value have an advantage: they follow a clearly defined search path, and following that path they take not only the INI file into account, they also check the Windows registry and the command line parameter. Furthermore, they deliver always up-to-date values. == Examples ==
Line 9: Line 29:
They have disadvantages as well:

 * They are slow
 * They return everything as a string

If you are not interested in the Windows registry and command line parameters, and if nobody else is changing your INI files while your application is running, then the "!IniFile" class introduced in this article might attract your attention.

This class allows you to use a kind of APL-Syntax in your INI files. Values not enclosed in quotes will be converted to numbers, everything else gets a string.

== Details ==

=== Character Values ===

An entry like:

{{{HomeFolder='C:/Windows/Appl/'}}}

results in a string holding the path.

=== Numeric Values ===

An entry like:

{{{FormSize=300 400}}}

results in a two-element-vector "!FormSize" holding two integers.

=== References ===

Furthermore, an entry like:

{{{LogFolder='{"HomeFolder}Logsfiles/'}}}

is treated in a special way: the name between the curlies is taken as the name of an already defined value. It is then replaced by the value of that entry.

== Example ==

=== Creating an Instance ===

After creating an instance from the class:

{{{MyIni←⎕New #.IniClass (,⊂'C:/Appl/Example.ini')}}}

=== Accessing Data with the "Get" method ===

you can get all information you are interested in by calling the method "Get". Note that names are '''not''' case sensitive.

Given this file "Example.ini":
Zip all files in C:\!MyFolder\ recursively into myZipFile.zip:
Line 58: Line 31:
[GENERAL]
MaxNoOfErrors=20
FormSize=800 1200
LogfileFlag=1
LogLevels=1 2 3 ; from 1 to 9

[DIR]
Home='C:/mainfolder/'
AppFolder='{Home}appls/'
DocsFolder='{Home}docs/'
LogFileFolder='{Home}Logs/'
 (rc more)←#.WinZip.Create 'C:\MyFolder\*' 'myZipFile.zip'
Line 71: Line 34:
You can get any level of information you are interested in: Zip two files nto myZipFile.zip:
{{{
(rc more)←#.WinZip.Create ('C:\file1' 'C:\file2') 'C:\MyZipFile'
}}}
Line 73: Line 39:
 * get everything
 * get only a particular section
 * get a particular value in a particular section

==== Examples with "Get" ====
Unpack C:\!MyZip.zip into C:\!MyUnzippedFiles\:
Line 80: Line 42:
      MyIni.Get ⍬ ⍬
 GENERAL
          MAXNOOFERRORS 20
          FORMSIZE 800 1200
          LOGFILEFLAG 1
          LOGLEVELS 1 2 3
 DIR
          HOME C:/mainfolder/
          APPFOLDER C:/mainfolder/appls/
          DOCSFOLDER C:/mainfolder/docs/
          LOGFILEFOLDER C:/mainfolder/Logs/
      MyIni.Get'General' ⍬
MAXNOOFERRORS 20
FORMSIZE 800 1200
LOGFILEFLAG 1
LOGLEVELS 1 2 3
      MyIni.Get'General' 'FormSize'
800 1200
      ¯1 MyIni.Get'General' 'Unknown' ⍝ with default
¯1
      MyIni.Get'General' 'Unknown' ⍝ without default
Value Error: "Unknown"
myDoc.Get'General' 'Unknown'
 (rc more)←#.WinZip.Extract 'C:\MyZip.zip' 'C:\MyUnzippedFiles\'
Line 105: Line 45:
=== Indexing ===
Line 107: Line 46:
Since version 1.1, the class provides a default property. That means you can access values by indexing. == Project Page ==
Line 109: Line 48:
Examples (with the same INI file listed above):

{{{
      MyIni[⊂'GeneRAL:']
20 800 1200 1 1 2 3
            ⊃MyIni[⊂'GeneRAL:FormSize']
800 1200
}}}

=== Assigning ===

            ⊃MyIni[⊂'GeneRAL:FormSize']←12 23

=== The "Put" method ===

            (12 23) MyIni.Put 'GeneRAL:FormSize'

=== The "Save" method ===

You can also change a particular value but the changed value will persist only if you execute the "Save" method at some point:

{{{
      MyIni[⊂'GeneRAL:FormSize']←⊂'¯1 1000
      MyIni.Save
}}}

==== A Warning ====

However, an INI file is by definition not a kind of database and should '''not''' be used to save data by the application itself. The "Save" method '''might''' be useful to initialise an INI file.

=== Check Keys before indexing ===

Note that using indexing, there is no default. That means that specifying an unknown value leads to an error. There are two ways to escape this problem:

{{{
      MyIni.Exist 'General:Unknown'
0
      MyIni.Default← ¯1 ¯1
      MyIni[⊂'General:Unknown']
¯1 ¯1
      MyIni[⊂'General:Unknown']←200
      MyIni[⊂'General:Unknown']
200
}}}

== Creating an INI file ==

To create a new INI file, don't specify a filename:

{{{MyIni←⎕New #.IniClass }}}

=== Adding a Section ===

The only way to add a new section is to use the {{{AddSection}}}-method:

{{{
      MyIni←⎕New #.IniClass
      MyIni.AddSection'NewSection'
}}}

=== Adding Values ===

Adding new values can be done the same way you would cange a value: either use the "Put"-method or sinply assign a value.
For bug reports, future enhancements and a full version history see WinZip/ProjectPage
Line 174: Line 51:
||Original author: ||KaiJaeger ||
||Responsible: ||KaiJaeger ||
||Email: || kai@aplteam.com ||
Line 175: Line 55:
||Original author:||KaiJaeger||
||Responsible:||KaiJaeger||
||Email:||kai@aplteam.com||
||Current state:||1.2||

Goto the IniFileDownloadPage
<<Include(APLTreeDownloads)>>
Line 183: Line 58:
CategoryOpenSourceApl CategoryAplAplDyalog CategoryAplTree

WinZip

WinZip is part of the CategoryAplTree project.

WinZip was once a part of the CategoryAplTree project before it was suspended in September 2016.

The reason is that it does not behave when installed under a modern Windows system: it retires some OS-system DLLs, and it does not even bring them back when un-installed. In other words. it compromises a Windows system. See SevenZip as an alternative.

Warning

Note that WinZip issues an error when you pass something like this with the flag to preserve the directory structure:

C:\My\folder1\file.txt
C:\My\folder2\file.txt

According to the company behind WinZip this is nit a bug but by design. Therefore WinZip will issue a DOMAIN ERROR if you have to files with the same name in your list of files to be zipped.

Overview

The class "WinZip" relies on an installed version of WinZip and the command line extension. If both are installed on your machine then will will have the two executables WZZIP.EXE (for zipping) and WZUNZIP.EXE (for unzipping) somewhere, typically in C:\Program Files (x86)\WinZip.

The class makes it very easy to zip as well as unzip stuff.

Examples

Zip all files in C:\MyFolder\ recursively into myZipFile.zip:

 (rc more)←#.WinZip.Create 'C:\MyFolder\*' 'myZipFile.zip'

Zip two files nto myZipFile.zip:

(rc more)←#.WinZip.Create ('C:\file1' 'C:\file2') 'C:\MyZipFile'

Unpack C:\MyZip.zip into C:\MyUnzippedFiles\:

 (rc more)←#.WinZip.Extract 'C:\MyZip.zip' 'C:\MyUnzippedFiles\'

Project Page

For bug reports, future enhancements and a full version history see WinZip/ProjectPage

Version Information

Original author:

KaiJaeger

Responsible:

KaiJaeger

Email:

kai@aplteam.com


CategoryAplTree

WinZip (last edited 2016-09-13 15:27:22 by KaiJaeger)