Home page  
Help >
Logical Data Type
Version 7.11
Logical Data Type Logical Data Type

Description:

The Logical Data Type is a special data type for data with only two possible values. These values can be construed as 0/1, true/false, yes/no, etc.

The Logical Data Type requires only one bit of storage. For a single Logical field, the left-most (high-order) bit is used. When Logical fields occur consecutively, they are stored internally 8 per byte, left to right.

For applications with a large number of two-valued fields, this can result in a large reduction of storage requirement [compared to X(1) data type or I data type].

Data Base Definition Syntax

The DBD Data Declaration Syntax for a Logical data item is:
    [<level>] <fieldname> LOGICAL [(<logical-template>)] [KEY [<key-qualifiers>]]

The form and function of the <logical-template> are explained in the following paragraphs.

Application Interface Syntax

The AI Data Declaration Syntax for a Logical data item is:
    [<level>] <fieldname> LOGICAL [(<logical-template>)]

The form and function of the <logical-template> are explained in the following paragraphs.

The <logical-template>

The <logical-template> provides a method for specifying the external manifestations of a LOGICAL value. By default, when a LOGICAL value is displayed or exported, it is manifest as ascii '0' or '1', depending on its value. When a LOGICAL value is imported, the default values are {'0', 'F*', 'N*'} for false; and {'1', 'T*', 'Y*'} for true.

The <logical-template> allows the default assignments to be overridden. The form of a <logical-template> is:
    ("<logical-pair1>, <logical-pair2>, ...")

The form of a <logical-pair> is:
    <true-token>/<false-token>

An example of a valid <logical-template> is:
    ("true/false,yes/no,on/off")

When importing to a LOGICAL field, a match on any token will be accepted. When exporting or displaying a LOGICAL field, the tokens from the first <logical-pair> are used.

Moving Data From a Logical Data Type to Another Data Type:

When a Logical field is moved to an X() field, it is stored as an ascii '0' or '1'.
When a Logical field is moved to an N() field, it is stored as a numeric '0' or '1'.
When a Logical field is moved to an I, ID, ID64, F or FD field, it is stored as a binary integer 0 or 1.

Moving Data From Another Data Type to a Logical Data Type:

When an X() field is moved to a Logical field, the first character of the X() field determines the Logical value. '0', 'n', 'N', 'f' and 'F' result in a Logical 0 value. '1', 'y', 'Y', 't' and 'T' result in a Logical 1 value.
When an N() field is moved to a Logical field, value 0 results in Logical 0 value. Any non-zero value results in Logical 1 value.
When an I, ID, ID64, F or FD field is moved to a Logical field, value 0 results in Logical 0 value. Any non-zero value results in Logical 1 value.

Breakdowns and Aliases

A Logical data item can have only a single Logical data item as a breakdown or alias. For example:


This is legal:
   LDT1     LOGICAL  
 :1 LDT1_1  LOGICAL
  :2 LDT1_2 LOGICAL
   LDT2     LOGICAL

This is not legal:
   LDT1     LOGICAL  
 :1 LDT1_1  LOGICAL
  :2 LDT1_2 LOGICAL
  :2 LDT2   LOGICAL


Grouping Fields

A Logical data item can be included under any kind of grouping field. However, it is recommended that only I, ID and ID64 data types be used as grouping fields for Logical data types.

[The reason for this recommended restriction is that when a new record is created, only the level 0 data items are initialized to their default values. X() data types are set to ascii blanks; N() data types are set to ascii zeroes; the remaining binary data types are set to binary zeroes.]

[If a Logical data item is grouped under an X() or N() data type, it may be in a position that corresponds to a binary 1 in the grouping field. This could lead to confusion if it is assumed that all Logical data items are initially set to 0 (false).]

Copyright © 2019 , WhamTech, Inc.  All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. Names may be trademarks of their respective owners.