Midrange News for the IBM i Community

App Defaults Overview Published by: Bob Cozzi on 16 Jul 2012 view comments

Application Defaults System

The application defaults system in COZTOOLS allows developers to save and retrieve small pieces of information (up to 64 characters in length). The intended purpose of this is to allow applications programs to save the current or default settings for end-users. Then when the user returns to the app at a later date, their prior settings are retrieved for them.

The application defaults system consists of 3 components:

  1. Application Defaults file. Based on the COZAPPDFT file shipped with the COZTOOLS package.
  2. A set of CL commands to save and retrieve default values within the app defaults file.
  3. A set of subprocedures to streamline integration with high-level languages such as RPG IV and C.

The set of CL commands includes:

CRTDFTFILE - Create applications defaults file. Use this command to create your own app defaults file in any library, under any name. Then specify the file name on the RTVAPPDFT and CHGAPPDFT commands. Note the special file name of *USRDFT may be used to create a file named COZAPPDFT in a user-specified library.

CHGAPPDFT - Create or change any application default value using this command. Specify the default name and value to be assigned to that default name. By default, the command searches the library list for an application defaults file named COZAPPDFT (i.e., *USRDFT) or for your user-specified file. It changes the existing default value or if it does not exist, creates a new one in the file with the specified value.

RTVAPPDFT - Returns the current default value for the default named on the command. This commands allows either character and numeric CL variables to be specified for the returned default value. In addition, a "return this value if none exists" parameter allows the programmer to specify a default value to be returned if there is in fact, no existing default value in the file for the one named on the command. Sort of a "default for the default".

The set of subprocedures available in the provided COZAPPDFT *SRVPGM object includes, but is not limited to:

  • getAppDefaultAsLogical
  • getAppDefaultAsDate
  • getAppDefaultAsInt
  • getAppDefaultAsUINT
  • getAppDefaultAsDec
  • getAppDefault
  • setAppDefault
  • setAppDefaultsFile

There are basically two primary interfaces, getAppDefault() and setAppDefault(). But accept character values of up to 32 characters for the name of the default value, and up to 64 characters for the value itself. 

The other subprocedures wrap getAppDefault, providing a simple method for returning the default value in an alternate format. 

 All App Default Values are stored as character/text strings, however the CL command RTVAPPDFT and CHGAPPDFT allow the value to be specified in any available format--the data is converted internally to a character string. For example if a packed decimal value of X'0001000F' is specified in a Decimal CL variable with a length of 7 and decimal positions of 2, this value is converted to 10.00 by the app defaults system and stored as the text string '10.00' in the file.

When it is retrieved using getAppDefaultAsDec, it is returned as a packed decimal value, similarly when the RTVAPPDFT command includes a packed decimal CL variable on the RTVVAR parameter, the value is also returned as packed decimal.

NOTE: The subprocedure names are the internal/exported names. the actual Prototypes a programmer would use shorten the word "default" to "dft", for example, to call the getAppDefaultAsDec() subprocedure, the programmer would write something like the following:

 crdLimit = getAppDftDec('CREDIT_LIMIT');


The App Defaults subsystem is part of the COZTOOLS software package, available from Cozzi Productions, Inc.

Visit www.cozTools.com for more information.

Return to midrangenews.com home page.
Sort Ascend | Descend