INFORMIX-4GL Concepts and Use, Version 7 INFORMIX-4GL Concepts and Use Version 7.3 July 1999 Part No

  • View
    2

  • Download
    0

Embed Size (px)

Text of INFORMIX-4GL Concepts and Use, Version 7 INFORMIX-4GL Concepts and Use Version 7.3 July 1999 Part No

  • INFORMIX-4GL

    Concepts and Use

    Version 7.3 July 1999 Part No. 000-5298

  • ii INFORMIX-4GL Conc

    Published by INFORMIX Press Informix Corporation 4100 Bohannon Drive Menlo Park, CA 94025-1032

     1999 Informix Corporation. All rights reserved. The following are trademarks of Informix Corporation or its affiliates:

    Answers OnLineTM; CBT StoreTM; C-ISAM; Client SDKTM; ContentBaseTM; Cyber PlanetTM; DataBlade; Data DirectorTM; Decision FrontierTM; Dynamic Scalable ArchitectureTM; Dynamic ServerTM; Dynamic ServerTM, Developer EditionTM; Dynamic ServerTM with Advanced Decision Support OptionTM; Dynamic ServerTM with Extended Parallel OptionTM; Dynamic ServerTM with MetaCube ROLAP Option; Dynamic ServerTM with Universal Data OptionTM; Dynamic ServerTM with Web Integration OptionTM; Dynamic ServerTM, Workgroup EditionTM; FastStartTM; 4GL for ToolBusTM; If you can imagine it, you can manage itSM; Illustra; INFORMIX; Informix Data Warehouse Solutions... Turning Data Into Business AdvantageTM; INFORMIX-Enterprise Gateway with DRDA; Informix Enterprise MerchantTM; INFORMIX-4GL; Informix-JWorksTM; InformixLink; Informix Session ProxyTM; InfoShelfTM; InterforumTM; I-SPYTM; MediazationTM; MetaCube; NewEraTM; ON-BarTM; OnLine Dynamic ServerTM; OnLine for NetWare; OnLine/Secure Dynamic ServerTM; OpenCase; ORCATM; Regency Support; Solution Design LabsSM; Solution Design ProgramSM; SuperView; Universal Database ComponentsTM; Universal Web ConnectTM; ViewPoint; VisionaryTM; Web Integration SuiteTM. The Informix logo is registered with the United States Patent and Trademark Office. The DataBlade logo is registered with the United States Patent and Trademark Office.

    Documentation Team: Elaina Von Haas, Tom Houston, Mary Leigh Burke, Jennifer Leland, Mary Kraemer

    Contributors: Jonathan Leffler

    GOVERNMENT LICENSE RIGHTS

    Software and documentation acquired by or for the US Government are provided with rights as follows: (1) if for civilian agency use, with rights as restricted by vendor’s standard license, as prescribed in FAR 12.212; (2) if for Dept. of Defense use, with rights as restricted by vendor’s standard license, unless superseded by a negotiated vendor license, as prescribed in DFARS 227.7202. Any whole or partial reproduction of software or documentation marked with this legend must reproduce this legend.

    epts and Use

  • Table of Contents

    Table of Contents

    Introduction In This Introduction . . . . . . . . . . . . . . . . . 3 About This Manual . . . . . . . . . . . . . . . . . . 3

    Organization of This Manual . . . . . . . . . . . . . 3 Types of Users . . . . . . . . . . . . . . . . . . 5 Software Dependencies . . . . . . . . . . . . . . . 5 Assumptions About Your Locale. . . . . . . . . . . . 6 Demonstration Database and Examples . . . . . . . . . 6 Accessing Databases from Within 4GL. . . . . . . . . . 7

    Documentation Conventions . . . . . . . . . . . . . . 8 Typographical Conventions . . . . . . . . . . . . . 8 Icon Conventions . . . . . . . . . . . . . . . . . 9

    Additional Documentation . . . . . . . . . . . . . . . 9 Documentation Included with 4GL . . . . . . . . . . . 10 On-Line Manuals . . . . . . . . . . . . . . . . . 10 On-Line Help . . . . . . . . . . . . . . . . . . 11 On-Line Error Messages. . . . . . . . . . . . . . . 11 Related Reading . . . . . . . . . . . . . . . . . 12

    Informix Welcomes Your Comments . . . . . . . . . . . . 12

    Chapter 1 Introducing INFORMIX-4GL In This Chapter . . . . . . . . . . . . . . . . . . . 1-3 What Is 4GL? . . . . . . . . . . . . . . . . . . . . 1-3 4GL Provides a Programmer’s Environment . . . . . . . . . 1-3 4GL Works with Databases . . . . . . . . . . . . . . . 1-4 4GL Runs in Different Environments . . . . . . . . . . . . 1-5 Informix Dynamic 4GL . . . . . . . . . . . . . . . . 1-5 Two Implementations of 4GL . . . . . . . . . . . . . . 1-5

  • iv INFOR

    Chapter 2 Interfaces of INFORMIX-4GL In This Chapter . . . . . . . . . . . . . . . . . . . 2-3 Database Access . . . . . . . . . . . . . . . . . . 2-4 Access to Sequential Files . . . . . . . . . . . . . . . 2-5 Report Output . . . . . . . . . . . . . . . . . . . 2-5 User Access . . . . . . . . . . . . . . . . . . . . 2-6 Using Forms and Menus . . . . . . . . . . . . . . . 2-7 Summary . . . . . . . . . . . . . . . . . . . . . 2-8

    Chapter 3 The INFORMIX-4GL Language In This Chapter . . . . . . . . . . . . . . . . . . . 3-3 A Structured, Procedural Language . . . . . . . . . . . . 3-3 A Nonprocedural, Fourth-Generation Language . . . . . . . 3-6

    Database Access . . . . . . . . . . . . . . . . . 3-6 Report Generation . . . . . . . . . . . . . . . . 3-7 User Interaction . . . . . . . . . . . . . . . . . 3-8

    Summary . . . . . . . . . . . . . . . . . . . . . 3-9

    Chapter 4 Parts of an Application In This Chapter . . . . . . . . . . . . . . . . . . . 4-3 The Database Schema . . . . . . . . . . . . . . . . 4-5 Form Specifications and Form Files . . . . . . . . . . . . 4-6

    Form Design . . . . . . . . . . . . . . . . . . 4-8 Field Entry Order . . . . . . . . . . . . . . . . 4-8

    Program Source Files . . . . . . . . . . . . . . . . . 4-9 Organization of a Program . . . . . . . . . . . . . 4-9 The Globals Files . . . . . . . . . . . . . . . . . 4-10

    Program Object Files . . . . . . . . . . . . . . . . . 4-10 P-Code Object Files . . . . . . . . . . . . . . . . 4-11 C-Code Object Files . . . . . . . . . . . . . . . . 4-13

    Example Programs . . . . . . . . . . . . . . . . . 4-14

    MIX-4GL Concepts and Use

  • Chapter 5 The Procedural Language In This Chapter . . . . . . . . . . . . . . . . . . 5-3 Declaration of Variables . . . . . . . . . . . . . . . 5-3

    Data Typing . . . . . . . . . . . . . . . . . . 5-3 Automatic Data Type Conversion . . . . . . . . . . 5-4 Data Structures . . . . . . . . . . . . . . . . . 5-5 Memory Allocation . . . . . . . . . . . . . . . 5-7 Scope of Reference . . . . . . . . . . . . . . . . 5-9

    Decisions and Loops . . . . . . . . . . . . . . . . 5-10 Statement Blocks . . . . . . . . . . . . . . . . 5-11 Comment Symbols . . . . . . . . . . . . . . . 5-12

    Exceptions . . . . . . . . . . . . . . . . . . . . 5-12 Kinds of Exceptions . . . . . . . . . . . . . . . 5-12 Why Exceptions Must Be Handled . . . . . . . . . . 5-13 How Exceptions Are Handled. . . . . . . . . . . . 5-13

    Chapter 6 Database Access and Reports In This Chapter . . . . . . . . . . . . . . . . . . 6-3 Using SQL in a 4GL Program . . . . . . . . . . . . . 6-3 Creating 4GL Reports . . . . . . . . . . . . . . . . 6-5

    The Report Driver . . . . . . . . . . . . . . . . 6-7 The Report Definition. . . . . . . . . . . . . . . 6-8

    Chapter 7 The User Interface In This Chapter . . . . . . . . . . . . . . . . . . 7-3 Line-Mode Interaction . . . . . . . . . . . . . . . . 7-3 Formatted Mode Interaction . . . . . . . . . . . . . . 7-5

    Formatted Mode Display . . . . . . . . . . . . . 7-6 Sample Code for Formatted Mode Display . . . . . . . 7-8

    Screens and Windows . . . . . . . . . . . . . . . . 7-9 The Computer Screen and the 4GL Screen . . . . . . . 7-9 The 4GL Window . . . . . . . . . . . . . . . . 7-9

    How Menus Are Used . . . . . . . . . . . . . . . . 7-10 How Forms Are Used . . . . . . . . . . . . . . . . 7-13

    Defining a Form . . . . . . . . . . . . . . . . 7-14 Displaying a Form . . . . . . . . . . . . . . . . 7-16 Reading User Input from a Form . . . . . . . . . . . 7-17 Screen Records . . . . . . . . . . . . . . . . . 7-18 Screen Arrays . . . . . . . . . . . . . . . . . 7-19

    Table of Contents v

  • vi INFOR

    How the Input Process Is Controlled . . . . . . . . . . . 7-20 How Query by Example Is Done . . . . . . . . . . . . . 7-23 How 4GL Windows Are Used . . . . . . . . . . . . . . 7-25

    Alerts and Modal Dialog Boxes . . . . . . . . . . . . 7-26 Information Displays . . . . . . . . . . . . . . . 7-27

    How the Help System Works . . . . . . . . . . . . . . 7-28

    Chapter 8 Using the Language In This Chapter . . . . . . . . . . . . . . . . . . . 8-3 Data Types of 4GL . . . . . . . . . . . . . . . . . . 8-3 Simple Data Types . . . . . . . . . . . . . . . . . . 8-3

    Number Data Types . . . . . . . . . . . . . . . . 8-4 Time Data Types . . . . . . . . . . . . . . . . 8-6 Character Data Types . . . . . . . . . . . . . . . 8-8 Large Data Types . . . . . . . . . . . . . . . . . 8-9

    Variables and Data Structures . . . . . . . . . . . . . . 8-10 Declaring the Data Type . . . . . . . . . . . . . . 8-11 Creating Structured Data Types . . . . . . . . . . . . 8-12 Declaring the Scope of a Variable . . . . . . . . . . . 8-14 Using Global Variables . . . . . . . . . . . . . . . 8-17 Initializing Variables . . . . . . . . . . . . . . . 8-21

    Expressions and Values . . . . . . . . . . . . . . . . 8-21 Literal Values . . . . . . . . . . . . . . . . . . 8-21 Values from Variables . . . . . . . . . . . . . . . 8-22 Values from Function Calls . . . . . . . . . . . . . 8-22 Numeric Expressions . . . . . . . . . . . . . . . 8-23 Boolean Expressions . . . . . . . . . . . . . . . . . . . . 8-23 Character Expressions . . . . . . . . . . . . . . . 8-25 Null Values . . . . . . . . . . . . . . . . . . . 8-26

    Assignment and Data Conversion . . . . . . . . . . . . 8-27 Data Type Conversion . . . . . . . . . . . . . . . 8-28 Conversion Errors . . . . . . . . . . . . . . . . 8-29

    Decisions and Loops . . . . . . . . . . . . . . . . . 8-29 Decisions Based on NULL . . . . . . . . . . . . . 8-31

    Functions and Calls . . . . . . . . . . . . . . . . . 8-32 Function Definition . . . .