User Tools

Site Tools


Sidebar

Welcome to DIDO WIKI

dido:public:s_cli:05_contents:01_prt:06_dddl:type

5.2 Types

Purpose

Syntax

Return to Top

    DEFINE TYPE <TypeName> AS
       <PrimitiveType>
       [ ALLOWING NULL | NONULL ]
       | WITH CONSTRAINTS
           <NumericConstraints>
          | <TextConstraints>
          | <EnumerationSet>
          | <DateConstraints>
          | <ElapsedTimeConstraints>
          | <GeoPositionConstraints
          | <HashValueConstraints>

Where

TypeName

Return to Syntax

::=  textual name associated with the TYPE

PrimitiveType

Return to Syntax

A PrimitiveType is a data type built into the DIDO-CLI. It is characterized as a basic structure for building more sophisticated structures. These PrimitiveTypes are familiar to software engineers and programmers. Note: The PrimitiveTypes have no indication of how the data is stored within the DIDO (ie., Int16, Int32, Float, Double, Char255, etc. It is assumed that the “best” underlying type is used for the particular hardware. The Struct primitive type allows for a collection of other Primitive Types to references as a single entity. For example, a NameStruct might have two Text types for FirstName and LastName included in it.

PrimitiveType ::=
             [ Integer 
               | Fixed 
               | Floating 
               | Text 
               | Enum
               | Date 
               | Time 
               | Geo 
               | Hash
               | Object
             ] 

NumericConstraints

Return to Syntax

NumericConstraints ::= 
             ( [ MIN = <BaseTypeNumber>,
                 MAX = <BaseTypeNumber>,
                 DEFAULT = <BaseTypeNumber>.
                 UNITS = <UnitsText>
                 [ PRECISION = <SignificateDigits> [, <DecimalPlaces>]
                 VALUE = <BaseTypeNumber> := DEFAULT
               ]
             )
Example
| Examples of Defining Numeric Types in DidoLL
    DEFINE TYPE PercentType 
      ( VALUE     : FIXED,
        MIN       : FIXED :=   0.0,
        MAX       : FIXED := 100.00,
        DEFAULT   : FIXED :=  50.00,
        units     : TEXT  := "percent",
        PRECISION : TEXT  := "5,2"
      ) AS
      FIXED
      ALLOWING NONULL
      WITH CONSTRAINTS
        ( VALUE     = DEFAULT,
          MIN       = MIN,
          MAX       = MAX,
          DEFAULT   = DEFAULT,
          UNITS     = units,
          PRECISION = PRECISION,
        );
 
     CREATE interestRate PercentType = NEW PercentType ( 2.1 );

TextConstraints

Return to Syntax

  <code>TextConstraints ::=
            ( DEFAULT     = <TextString>
              COMPRESSION = <CompressionOptons> ::= [ None | One | OneUnderscore ]
              CASE        = CaseOptions         ::= [ Upper | Lower | Mixed | Camel | Title ]
              MAXLENGTH   = <PositiveNumber>    ::= [1..n]
              LENGTH      = <PositiveNumber> < MAX_LENGTH;
              VALUE       = <TextString>
            )</code>
Example
| Examples of Defining Text Types in DidoLL.
   DEFINE TYPE VariableNameType
     ( DEFAULT      Text,
       compression  Text,
       CASE         Text,
       maxLength    I
     ) AS
     Text
     WITH CONSTRAINTS
       ( DEFAULT    = DEFAULT,
         COMPRESION = ONEUNDERSCORE,
         CASE       = TITLE,
         MAX_LENGTH = 30,
       );
 
   CREATE variableName VariableNameType = "My Variable Name";

EnumerationSet

Return to Syntax

EnumerationSet ::=
              ( {( <NumericValue> , <TextValue> ) [, <DescriptiveText> ] }, [ DEFAULT = <NumericValue> [, VALUE = <NumericValue>]])
Example

See https://www.computernetworkingnotes.com/networking-tutorials/types-of-network-protocols-explained-with-functions.html

| Examples of Defining Enumeration Types in DidoLL.
   DEFINE TYPE NetworkProtocolType AS 
     ENUM
     WITH CONSTRAINTS
       { { 20 , FTP, "File Transfer Protocol"},
         { 22 , SSH, "Secure Shell"} DEFAULT,
         { 23 , Telnet, "Telnet"},
         { 25 , SMTP, "Simple Mail Transfer Protocol"},
         { 53 , DNS, "Domain Name Service"},
         { 69 , TFTP, "Trivial File Transfer Protocol" },
         { 80 , HTTP, "Hypertext Transfer Protocol" },
         { 110 , POP3, "Post Office Protocol version 3" },
         { 119 , NNTP, "Network News Transport Protocol" },
         { 123 , NTP, "Network Time Protocol" },
         { 143 , IMAP4, "Internet Message Access Protocol version 4" },
         { 443 , HTTPS, "Hypertext Transfer Protocol Secure" }
       )
    VALUE = DEFAULT;
 
   CREATE networkProtocol_1.TextValue NetworkProtocolType = FTP;
   CREATE networkProtocol_2.NumericValue NetworkProtocolType = 20;
   CREATE description Text = networkProtocol_1.DescriptiveText;

DateConstraints

Return to Syntax

DateConstraints ::= 
              ( DEFAULT = [ <DateTimeValue> | CURRENT_DATE | UNKNOWN ],
                START   = [ <DateTimeValue> | CURRENT_DATE | UNKNOWN ],
                END     = [ <DateTimeValue> | + <DateIncementer | UNKNOWN ],
                VALUE   = <DateTimeValue> := DEFAULT
              )
Example
| Examples of Defining Date Types in DidoLL.
   DEFINE TYPE ErrorTimeType AS
     DATE
     WITH CONSTRAINTS
       ( DEFAULT = CURRENT_DATE,
         START   = CURRENT_DATE,
         END     = UNKNOWN,
         VALUE   = <DateTimeValue> := DEFAULT
       );
   DECLARE
      errorTime ErrorTimeType = CURRENT_DATE;
      dateIncementer DateIncementer = (3,"day");
   BEGIN
     errorTime(END) =+ dateIncementer;
   END;

ElapsedTimeConstraints

Return to Syntax

ElapsedTimeConstraints ::=
              ( DEFAULT = [ <TimeValue> | CURRENT_TIME | UNKNOWN ],
                START   = [ <TimeValue> | CURRENT_TIME | UNKNOWN ],
                END     = [ <TimeValue> | + <TimeIncementer | UNKNOWN ],
                VALUE   = <TimeValue> := DEFAULT
              )
Example
| Examples of Defining Time Types in DidoLL.
   DEFINE TYPE TestTimeType AS
     DATE
     WITH CONSTRAINTS
       ( DEFAULT = CURRENT_DATE,
         START   = CURRENT_DATE,
         END     = UNKNOWN
       );
   DECLARE
     testTime TestTimeType;
   BEGIN
   END;

GeoPositionConstraints

Return to Syntax

GeoPositionConstraints::=
             ( DEFAULT = ( [ <LatitudeValue>, <LongitudeValue>, [, <ElevationValue>] | [ CURRENT_POSITION] ]),
               VALIDATION = ( [GEOGRAPHIC_FUNCTION [ ( {Parm} ] ]),
               VALUE      = ( <LatitudeValue>, <LongitudeValue>, [, <ElevationValue>] ) := DEFAULT
             )
Example
| Examples of Defining Time Types in DidoLL.
   DEFINE TYPE GeoPositionType AS
     HASH
     WITH CONSTRAINTS
       ( DEFAULT      = CURRENT_POSITION,
         VALID        = LIB.ValidateLatLong ( LatitudeValue, LongitudeValue, ElevationValue )
         VALUE        = ( 51.476852, -0.000500, 6 ) -- Greenwich, UK
       );
   DECLARE
      geoPosition GeoPositionType := (33.11129821001457, -117.1563430866643, 4,421); -- Mount Whitney  
   BEGIN
   END;

HashValueConstraints

Return to Syntax

HashValueConstraints ::=
             ( ALGORITHM = [ <HashFunctionName> | DEFAULT_ALGORITHM ],
               MESSAGE  = <MessageText>,
               OPTIONS  = [ "Hex" | "binary" |  "base64" ],
               VALUE    = <HexText>
             )
Example
| Examples of Defining Hash Types in DidoLL.
  DEFINE TYPE CryptoKeyType AS
    HASH
    WITH CONSTRAINTS
      ( DEFAULT = "SHA-256",\
        MESSAGE = "This is the text used to generate my key",
        OPTIONS = "hex"
      );
 
  DECLARE
     cryptoKey CryptoKeyType ( MESSAGE = "Use this text to generate my key");
  BEGIN
  END;
 

StructConstraints

Return to Syntax

StructConstraints ::=
             ( {PrimitiveType} )

ArrayConstraints

Return to Syntax

::=
             ( { <IndexType> [.. <IndexType>][,]} )
dido/public/s_cli/05_contents/01_prt/06_dddl/type.txt · Last modified: 2021/06/15 13:59 by nick
Translations of this page: