Previous Topic Next topic Print topic


DEFAULT

Purpose

Specifies data attribute defaults in cases where attribute sets are incomplete.

Syntax

DEFAULT simple-spec|factored-spec[,simple-spec|factored-spec]…;

where simple-spec is:

RANGE(letters[,letters]…)attribute-spec;

or

RANGE(*)[attribute-spec];

where letters is:

letter [letters]…

where factored-spec is:

(simple-spec|factored-spec[,simple-spec|factored-spec]…)[attribute-spec]

where attribute-spec is:

[attribute-list][VALUE(value-spec[,value-spec]…)

where attribute-list is a list of attributes separated by at least one space.

attribute[ attribute]…

where attribute is:

ALIGNED | AREA | AUTOMATIC | BASED | BIGENDIAN | BINARY | BIT | CHARACTER | CONTROLLED
			 | DECIMAL | DEFINED | DIMENSION | ENTRY | EXTERNAL | FILE | FIXED | FLOAT | GRAPHIC | INITIAL | INTERNAL | LABEL
			 | NATIVE | NONNATIVE | OFFSET | PARAMETER | PICTURE | POINTER | STATIC | VARYING | UNALIGNED | VARIABLE | WIDECHAR

where value-spec is:

CHARACTER(length)|BIT(length)|AREA(size)|numeric-spec

where numeric-spec is:

FIXED|FLOAT|BINARY|DECIMAL[(precision[,scale])]

Abbreviation(s):

  • AUTO for AUTOMATIC
  • BIN for BINARY
  • CHAR for CHARACTER
  • CTL for CONTROLLED
  • DEC for DECIMAL
  • DFT for DEFAULT
  • EXT for EXTERNAL
  • G for GRAPHIC
  • INIT for INITIAL
  • INT for INTERNAL
  • PIC for PICTURE
  • PTR for POINTER
  • VAR for VARYING
  • WCHAR for WIDECHAR

Parameters

RANGE (letter:letter)    
Specifies that the defaults apply to names with initial letters that either correspond to the two letters specified or to any letters between the two in alphabetic sequence. The letters given in the specification must be in increasing alphabetic order.
RANGE (letter)
Specifies that the defaults apply to names beginning with the letter specified.
RANGE (letters)
Specifies that the defaults apply to names that start with the matching sequence of letters.
RANGE (*)
Specifies that the defaults apply to all names.
VALUE
Establishes default rules for a string length and numeric precision. The only attributes that the VALUE option can influence are length and precision. Other attributes in the option, such as FIXED or DECIMAL, merely indicate which attributes the value is associated with.
Note:

A length or precision specification can be made only in the VALUE clause. They may not be specified with the attributes in attribute-list.

Description

Specifies data attribute defaults in cases where declared attribute sets are incomplete. Any attributes not suppled by the DEFAULT statement for any incomplete explicit, contextual, or implicit declarations are supplied by the Open PL/I default rules. (See the section Compiler-supplied Defaults in the chapter Declarations and Attributes.)

Structure elements are given default attributes according to the name of the element, not the qualified structure element name. The DEFAULT statement cannot be used to declare a structure.

You can use more than one DEFAULT statement within a block. The scope of a DEFAULT statement includes the block in which it occurs and all nested blocks, except those which include another DEFAULT statement with the same range or which are contained in a block having a DEFAULT statement with the same range.

Note the following special case of a DEFAULT statement that is used to restore language-specified defaults in the containing block:

MAIN: PROCEDURE;
DEFAULT RANGE (a:d) FIXED DECIMAL
   VALUE (FIXED DECIMAL(10,2));
DCL CL_INDEX;
   BEGIN;
   DEFAULT RANGE (*);
   DCL C_INTERNAL FIXED DECIMAL;
   END;
END MAIN:

in the previous example, the CL_INDEX in the MAIN routine has precision and scale of (10,2) in accordance with the DEFAULT statement specification, while the C_INTERNAL variable has a language default precision (5,0).

Examples

This statement specifies that all character variables whose name begins with the letter t have the length of 10 characters. Here, tony will have length 6, while tiger will have its explicitly specified length of 20.

DEFAULT RANGE (l:m) FLOAT; 
DECLARE (low, medium) BINARY;

/*In this case both variables, low and medium, will be declared as FLOAT BINARY(23).*/

DFT RANGE (*) STATIC;
DECLARE (x,y) FIXED BINARY(15) INITIAL (0); 
DECLARE t FLOAT DECIMAL AUTOMATIC;

/* In this example both x and y will have STATIC storage class, while t will have AUTOMATIC storage class due to its explicit storage class declaration. */

DEFAULT RANGE (t) VALUE (CHARACTER(6)); 
DCL tony CHAR;
DCL tiger CHAR(20);

This example uses RANGE (letters) to set a matching sequence that is matched by the second of two declarations, whose storage class is STATIC.

DEFAULT RANGE(SCH) STATIC; 
 
DCL SBCHX CHAR ;  /* not a match     */ 
DCL SCHBX CHAR ;  /* storage class will be STATIC */

Restrictions

The DEFAULT statement with an attribute expression is not supported. However, the Open PL/I compiler accepts the following construct:

DEFAULT (RANGE(simple-spec) & ^PARAMETER) [attribute-list];
Previous Topic Next topic Print topic