informix-4gl reference manual, version 7genci/vyucba/dbs/5299.pdf · informix logo is registered...

1312
INFORMIX-4GL Reference Manual Version 7.3 July 1999 Part No. 000-5299

Upload: phungdiep

Post on 28-Sep-2018

269 views

Category:

Documents


1 download

TRANSCRIPT

  • INFORMIX-4GL

    Reference Manual

    Version 7.3July 1999Part No. 000-5299

  • ii INFORMIX-4GL Refer

    Published by INFORMIX Press Informix Corporation4100 Bohannon DriveMenlo Park, CA 94025-1032

    1999 Informix Corporation. All rights reserved. The following are trademarks of Informix Corporation or itsaffiliates:

    Answers OnLineTM; CBT StoreTM; C-ISAM; Client SDKTM; ContentBaseTM; Cyber PlanetTM; DataBlade; DataDirectorTM; Decision FrontierTM; Dynamic Scalable ArchitectureTM; Dynamic ServerTM; Dynamic ServerTM,Developer EditionTM; Dynamic ServerTM with Advanced Decision Support OptionTM; Dynamic ServerTM withExtended Parallel OptionTM; Dynamic ServerTM with MetaCube ROLAP Option; Dynamic ServerTM withUniversal Data OptionTM; Dynamic ServerTM with Web Integration OptionTM; Dynamic ServerTM, WorkgroupEditionTM; 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-EnterpriseGateway 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; UniversalDatabase ComponentsTM; Universal Web ConnectTM; ViewPoint; VisionaryTM; Web Integration SuiteTM. TheInformix logo is registered with the United States Patent and Trademark Office. The DataBlade logo isregistered with the United States Patent and Trademark Office.

    Documentation Team: Tom Houston, Adam Barnett, Mary Leigh Burke, Evelyn Eldridge,Barbara Nomiyama, Elaina Von Haas, Eileen Wollam

    Contributors: Jonathan Leffler, Sudhakar Prabhu, Alan Denney

    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 vendors standard license, as prescribed in FAR 12.212;(2) if for Dept. of Defense use, with rights as restricted by vendors standard license, unless superseded by anegotiated vendor license, as prescribed in DFARS 227.7202. Any whole or partial reproduction of software ordocumentation marked with this legend must reproduce this legend.

    ence Manual

  • Table of Contents

    Table ofContents

    IntroductionIn This Introduction . . . . . . . . . . . . . . . . . 3About This Manual . . . . . . . . . . . . . . . . . . 3

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

    Documentation Conventions . . . . . . . . . . . . . . 8Typographical Conventions . . . . . . . . . . . . . 8Icon Conventions . . . . . . . . . . . . . . . . . 9Example-Code Conventions . . . . . . . . . . . . . 10Syntax Conventions . . . . . . . . . . . . . . . . 10

    Additional Documentation . . . . . . . . . . . . . . . 15Documentation Included with 4GL . . . . . . . . . . . 15On-Line Manuals . . . . . . . . . . . . . . . . . 16On-Line Help . . . . . . . . . . . . . . . . . . 16On-Line Error Messages. . . . . . . . . . . . . . . 16Related Reading . . . . . . . . . . . . . . . . . 18Informix Developer Network . . . . . . . . . . . . . 18

    Informix Welcomes Your Comments . . . . . . . . . . . . 19

    Chapter 1 Compiling INFORMIX-4GL Source FilesIn This Chapter . . . . . . . . . . . . . . . . . . . 1-3Two Implementations of INFORMIX-4GL . . . . . . . . . . 1-3

    Differences Between the C Compiler and RDS Versions . . . . 1-4The C Compiler Version . . . . . . . . . . . . . . . . 1-6

    The Five-Phase 4GL Compilation Process. . . . . . . . . 1-6The Programmers Environment . . . . . . . . . . . . 1-8

  • iv INFOR

    Creating Programs in the Programmers Environment . . . . 1-26Creating Programs at the Command Line . . . . . . . . 1-32Program Filename Extensions . . . . . . . . . . . . 1-45

    The Rapid Development System . . . . . . . . . . . . . 1-47The Programmers Environment . . . . . . . . . . . 1-47Creating Programs in the Programmers Environment . . . . 1-67Creating Programs at the Command Line . . . . . . . . 1-72Program Filename Extensions . . . . . . . . . . . . 1-86

    Chapter 2 The INFORMIX-4GL LanguageIn This Chapter . . . . . . . . . . . . . . . . . . . 2-3Language Features . . . . . . . . . . . . . . . . . 2-3

    Lettercase Insensitivity . . . . . . . . . . . . . . . 2-3Whitespace, Quotation Marks, Escape Symbols,

    and Delimiters . . . . . . . . . . . . . . 2-4Character Set . . . . . . . . . . . . . . . . . . 2-54GL Statements . . . . . . . . . . . . . . . . . 2-5Comments . . . . . . . . . . . . . . . . . . . 2-8Source-Code Modules and Program Blocks. . . . . . . . 2-10Statement Blocks . . . . . . . . . . . . . . . . . 2-12Statement Segments . . . . . . . . . . . . . . . . 2-134GL Identifiers . . . . . . . . . . . . . . . . . 2-14

    Interacting with Users . . . . . . . . . . . . . . . . 2-22Ring Menus . . . . . . . . . . . . . . . . . . 2-22Screen Forms . . . . . . . . . . . . . . . . . . 2-254GL Windows . . . . . . . . . . . . . . . . . . 2-28On-Line Help . . . . . . . . . . . . . . . . . . 2-29Nested and Recursive Statements . . . . . . . . . . . 2-31

    Exception Handling . . . . . . . . . . . . . . . . . 2-39Compile-Time Errors and Warnings . . . . . . . . . . 2-39Runtime Errors and Warnings . . . . . . . . . . . . 2-39Changes to 4GL Error Handling . . . . . . . . . . . 2-43Error Handling with SQLCA . . . . . . . . . . . . 2-44

    Chapter 3 Data Types and ExpressionsIn This Chapter . . . . . . . . . . . . . . . . . . . 3-5Data Values in 4GL Programs . . . . . . . . . . . . . . 3-5Data Types of 4GL . . . . . . . . . . . . . . . . . . 3-6

    Simple Data Types . . . . . . . . . . . . . . . . 3-9Structured Data Types . . . . . . . . . . . . . . . 3-12

    MIX-4GL Reference Manual

  • Large Data Types . . . . . . . . . . . . . . . . 3-12Descriptions of the 4GL Data Types . . . . . . . . . . 3-12ARRAY . . . . . . . . . . . . . . . . . . . 3-13BYTE . . . . . . . . . . . . . . . . . . . . 3-14CHAR . . . . . . . . . . . . . . . . . . . . 3-15CHARACTER . . . . . . . . . . . . . . . . . 3-17DATE . . . . . . . . . . . . . . . . . . . . 3-17DATETIME . . . . . . . . . . . . . . . . . . 3-18DEC. . . . . . . . . . . . . . . . . . . . . 3-23DECIMAL (p, s) . . . . . . . . . . . . . . . . . 3-23DECIMAL (p) . . . . . . . . . . . . . . . . . 3-24DOUBLE PRECISION . . . . . . . . . . . . . . 3-25FLOAT . . . . . . . . . . . . . . . . . . . . 3-25INT . . . . . . . . . . . . . . . . . . . . . 3-26INTEGER . . . . . . . . . . . . . . . . . . . 3-26INTERVAL . . . . . . . . . . . . . . . . . . 3-27MONEY . . . . . . . . . . . . . . . . . . . 3-32NUMERIC . . . . . . . . . . . . . . . . . . 3-33REAL . . . . . . . . . . . . . . . . . . . . 3-33RECORD . . . . . . . . . . . . . . . . . . . 3-34SMALLFLOAT . . . . . . . . . . . . . . . . . 3-36SMALLINT . . . . . . . . . . . . . . . . . . 3-37TEXT . . . . . . . . . . . . . . . . . . . . 3-38VARCHAR . . . . . . . . . . . . . . . . . . 3-39Data Type Conversion . . . . . . . . . . . . . . 3-41Summary of Compatible 4GL Data Types . . . . . . . . 3-45Expressions of 4GL . . . . . . . . . . . . . . . 3-49Differences Between 4GL and SQL Expressions . . . . . . 3-50Components of 4GL Expressions . . . . . . . . . . . 3-52Boolean Expressions . . . . . . . . . . . . . . . 3-60Integer Expressions . . . . . . . . . . . . . . . 3-63Number Expressions . . . . . . . . . . . . . . . 3-66Character Expressions . . . . . . . . . . . . . . 3-68Time Expressions . . . . . . . . . . . . . . . . 3-72Field Clause . . . . . . . . . . . . . . . . . . 3-87Table Qualifiers . . . . . . . . . . . . . . . . . 3-90THRU or THROUGH Keywords and .* Notation . . . . . 3-93ATTRIBUTE Clause . . . . . . . . . . . . . . . 3-97

    Table of Contents v

  • vi INFOR

    Chapter 4 INFORMIX-4GL StatementsIn This Chapter . . . . . . . . . . . . . . . . . . . 4-9The 4GL Statement Set . . . . . . . . . . . . . . . . 4-9

    Types of SQL Statements . . . . . . . . . . . . . . 4-10Other Types of 4GL Statements . . . . . . . . . . . . 4-13

    Statement Descriptions . . . . . . . . . . . . . . . . 4-15CALL. . . . . . . . . . . . . . . . . . . . . 4-16CASE . . . . . . . . . . . . . . . . . . . . . 4-22CLEAR . . . . . . . . . . . . . . . . . . . . 4-28CLOSE FORM . . . . . . . . . . . . . . . . . . 4-31CLOSE WINDOW . . . . . . . . . . . . . . . . 4-33CONSTRUCT . . . . . . . . . . . . . . . . . . 4-35CONTINUE . . . . . . . . . . . . . . . . . . 4-68CURRENT WINDOW . . . . . . . . . . . . . . . 4-70DATABASE. . . . . . . . . . . . . . . . . . . 4-73DEFER . . . . . . . . . . . . . . . . . . . . 4-80DEFINE . . . . . . . . . . . . . . . . . . . . 4-83DISPLAY . . . . . . . . . . . . . . . . . . . 4-93DISPLAY ARRAY . . . . . . . . . . . . . . . . 4-105DISPLAY FORM . . . . . . . . . . . . . . . . . 4-116END . . . . . . . . . . . . . . . . . . . . . 4-119ERROR . . . . . . . . . . . . . . . . . . . . 4-121EXIT . . . . . . . . . . . . . . . . . . . . . 4-124FINISH REPORT . . . . . . . . . . . . . . . . . 4-128FOR . . . . . . . . . . . . . . . . . . . . . 4-131FOREACH . . . . . . . . . . . . . . . . . . . 4-134FUNCTION . . . . . . . . . . . . . . . . . . 4-143GLOBALS . . . . . . . . . . . . . . . . . . . 4-149GOTO . . . . . . . . . . . . . . . . . . . . 4-155IF . . . . . . . . . . . . . . . . . . . . . . 4-158INITIALIZE . . . . . . . . . . . . . . . . . . 4-160INPUT . . . . . . . . . . . . . . . . . . . . 4-164INPUT ARRAY . . . . . . . . . . . . . . . . . 4-190LABEL . . . . . . . . . . . . . . . . . . . . 4-227LET . . . . . . . . . . . . . . . . . . . . . 4-229LOAD . . . . . . . . . . . . . . . . . . . . 4-233LOCATE. . . . . . . . . . . . . . . . . . . . 4-242MAIN . . . . . . . . . . . . . . . . . . . . 4-247MENU . . . . . . . . . . . . . . . . . . . . 4-250MESSAGE . . . . . . . . . . . . . . . . . . . 4-275NEED. . . . . . . . . . . . . . . . . . . . . 4-278OPEN FORM . . . . . . . . . . . . . . . . . . 4-279

    MIX-4GL Reference Manual

  • OPEN WINDOW . . . . . . . . . . . . . . . . 4-281OPTIONS . . . . . . . . . . . . . . . . . . . 4-293OUTPUT TO REPORT . . . . . . . . . . . . . . 4-310PAUSE . . . . . . . . . . . . . . . . . . . . 4-313PREPARE . . . . . . . . . . . . . . . . . . . 4-314PRINT . . . . . . . . . . . . . . . . . . . . 4-326PROMPT . . . . . . . . . . . . . . . . . . . 4-327REPORT . . . . . . . . . . . . . . . . . . . 4-334RETURN . . . . . . . . . . . . . . . . . . . 4-339RUN . . . . . . . . . . . . . . . . . . . . 4-342SCROLL . . . . . . . . . . . . . . . . . . . 4-346SKIP . . . . . . . . . . . . . . . . . . . . 4-348SLEEP . . . . . . . . . . . . . . . . . . . . 4-350SQL . . . . . . . . . . . . . . . . . . . . . 4-351START REPORT . . . . . . . . . . . . . . . . 4-356TERMINATE REPORT . . . . . . . . . . . . . . 4-365UNLOAD. . . . . . . . . . . . . . . . . . . 4-368VALIDATE . . . . . . . . . . . . . . . . . . 4-373WHENEVER. . . . . . . . . . . . . . . . . . 4-377WHILE. . . . . . . . . . . . . . . . . . . . 4-383

    Chapter 5 Built-In Functions and OperatorsIn This Chapter . . . . . . . . . . . . . . . . . . 5-5Functions in 4GL Programs . . . . . . . . . . . . . . 5-5

    Built-In 4GL Functions . . . . . . . . . . . . . . 5-6Built-In and External SQL Functions and Procedures . . . . 5-7C Functions . . . . . . . . . . . . . . . . . . 5-7ESQL/C Functions . . . . . . . . . . . . . . . 5-7Programmer-Defined 4GL Functions . . . . . . . . . 5-8Invoking Functions . . . . . . . . . . . . . . . 5-9

    Operators of 4GL . . . . . . . . . . . . . . . . . 5-11Built-In Functions of Informix Dynamic 4GL . . . . . . . . 5-12Syntax of Built-In Functions and Operators . . . . . . . . 5-13

    Aggregate Report Functions . . . . . . . . . . . . 5-14ARG_VAL( ) . . . . . . . . . . . . . . . . . . 5-18Arithmetic Operators . . . . . . . . . . . . . . . 5-20ARR_COUNT( ) . . . . . . . . . . . . . . . . 5-27ARR_CURR( ) . . . . . . . . . . . . . . . . . 5-29ASCII . . . . . . . . . . . . . . . . . . . . 5-31Boolean Operators . . . . . . . . . . . . . . . . 5-33CLIPPED . . . . . . . . . . . . . . . . . . . 5-44COLUMN . . . . . . . . . . . . . . . . . . 5-46

    Table of Contents vii

  • viii INFO

    Concatenation ( || ) Operator . . . . . . . . . . . . 5-49CURRENT . . . . . . . . . . . . . . . . . . . 5-50CURSOR_NAME( ) . . . . . . . . . . . . . . . . 5-52DATE . . . . . . . . . . . . . . . . . . . . . 5-55DAY( ) . . . . . . . . . . . . . . . . . . . . 5-58DOWNSHIFT( ) . . . . . . . . . . . . . . . . . 5-59ERR_GET( ) . . . . . . . . . . . . . . . . . . 5-60ERR_PRINT( ) . . . . . . . . . . . . . . . . . 5-61ERR_QUIT( ) . . . . . . . . . . . . . . . . . . 5-62ERRORLOG( ) . . . . . . . . . . . . . . . . . . 5-63EXTEND( ) . . . . . . . . . . . . . . . . . . . 5-65FGL_DRAWBOX( ) . . . . . . . . . . . . . . . . 5-68FGL_GETENV( ) . . . . . . . . . . . . . . . . . 5-70FGL_GETKEY( ) . . . . . . . . . . . . . . . . . 5-72FGL_KEYVAL( ) . . . . . . . . . . . . . . . . . 5-73FGL_LASTKEY( ) . . . . . . . . . . . . . . . . 5-75FGL_SCR_SIZE( ) . . . . . . . . . . . . . . . . 5-77FIELD_TOUCHED( ) . . . . . . . . . . . . . . . 5-79GET_FLDBUF( ) . . . . . . . . . . . . . . . . . 5-82INFIELD( ) . . . . . . . . . . . . . . . . . . . 5-85LENGTH( ) . . . . . . . . . . . . . . . . . . 5-87LINENO. . . . . . . . . . . . . . . . . . . . 5-89MDY( ) . . . . . . . . . . . . . . . . . . . . 5-90Membership ( . ) Operator. . . . . . . . . . . . . . 5-91MONTH( ) . . . . . . . . . . . . . . . . . . . 5-92NUM_ARGS( ) . . . . . . . . . . . . . . . . . 5-93ORD( ) . . . . . . . . . . . . . . . . . . . . 5-94PAGENO . . . . . . . . . . . . . . . . . . . 5-95SCR_LINE( ) . . . . . . . . . . . . . . . . . . 5-96SET_COUNT( ) . . . . . . . . . . . . . . . . . 5-98SHOWHELP( ) . . . . . . . . . . . . . . . . . 5-100SPACE . . . . . . . . . . . . . . . . . . . . 5-102STARTLOG( ) . . . . . . . . . . . . . . . . . . 5-103Substring ( [ ] ) Operator . . . . . . . . . . . . . . 5-106TIME . . . . . . . . . . . . . . . . . . . . 5-108TODAY . . . . . . . . . . . . . . . . . . . . 5-110UNITS . . . . . . . . . . . . . . . . . . . . 5-111UPSHIFT( ) . . . . . . . . . . . . . . . . . . . 5-113USING . . . . . . . . . . . . . . . . . . . . 5-115WEEKDAY( ) . . . . . . . . . . . . . . . . . . 5-125WORDWRAP . . . . . . . . . . . . . . . . . . 5-128YEAR( ) . . . . . . . . . . . . . . . . . . . . 5-131

    RMIX-4GL Reference Manual

  • Chapter 6 Screen FormsIn This Chapter . . . . . . . . . . . . . . . . . . 6-54GL Forms . . . . . . . . . . . . . . . . . . . . 6-5

    Form Drivers . . . . . . . . . . . . . . . . . 6-5Form Fields . . . . . . . . . . . . . . . . . . 6-7

    Structure of a Form Specification File . . . . . . . . . . . 6-9DATABASE Section . . . . . . . . . . . . . . . . . 6-12

    Database References in the DATABASE Section. . . . . . 6-13The FORMONLY Option . . . . . . . . . . . . . 6-13The WITHOUT NULL INPUT Option . . . . . . . . . 6-14

    SCREEN Section . . . . . . . . . . . . . . . . . . 6-15The SIZE Option . . . . . . . . . . . . . . . . 6-15The Screen Layout . . . . . . . . . . . . . . . . 6-17Display Fields . . . . . . . . . . . . . . . . . 6-17Literal Characters in Forms. . . . . . . . . . . . . 6-19

    TABLES Section . . . . . . . . . . . . . . . . . . 6-23Table Aliases . . . . . . . . . . . . . . . . . . 6-24

    ATTRIBUTES Section . . . . . . . . . . . . . . . . 6-25FORMONLY Fields . . . . . . . . . . . . . . . 6-29Multiple-Segment Fields . . . . . . . . . . . . . 6-31Field Attributes . . . . . . . . . . . . . . . . 6-32Field Attribute Syntax . . . . . . . . . . . . . . 6-34AUTONEXT . . . . . . . . . . . . . . . . . . 6-35CENTURY . . . . . . . . . . . . . . . . . . 6-36COLOR . . . . . . . . . . . . . . . . . . . 6-38COMMENTS . . . . . . . . . . . . . . . . . 6-44DEFAULT . . . . . . . . . . . . . . . . . . 6-46DISPLAY LIKE . . . . . . . . . . . . . . . . . 6-49DOWNSHIFT . . . . . . . . . . . . . . . . . 6-50FORMAT . . . . . . . . . . . . . . . . . . . 6-51INCLUDE . . . . . . . . . . . . . . . . . . 6-54INVISIBLE . . . . . . . . . . . . . . . . . . 6-57NOENTRY . . . . . . . . . . . . . . . . . . 6-58PICTURE . . . . . . . . . . . . . . . . . . . 6-59PROGRAM . . . . . . . . . . . . . . . . . . 6-61REQUIRED . . . . . . . . . . . . . . . . . . 6-63REVERSE . . . . . . . . . . . . . . . . . . . 6-64UPSHIFT . . . . . . . . . . . . . . . . . . . 6-65VALIDATE LIKE . . . . . . . . . . . . . . . . 6-66VERIFY . . . . . . . . . . . . . . . . . . . 6-67WORDWRAP . . . . . . . . . . . . . . . . . 6-68

    Table of Contents ix

  • x INFOR

    INSTRUCTIONS Section . . . . . . . . . . . . . . . 6-74Screen Records . . . . . . . . . . . . . . . . . 6-74Screen Arrays . . . . . . . . . . . . . . . . . . 6-77Field Delimiters . . . . . . . . . . . . . . . . . 6-79

    Default Attributes . . . . . . . . . . . . . . . . . . 6-81Precedence of Field Attribute Specifications . . . . . . . 6-84Default Attributes in an ANSI-Compliant Database . . . . . 6-84

    Creating and Compiling a Form . . . . . . . . . . . . . 6-85Compiling a Form Through the Programmers

    Environment . . . . . . . . . . . . . . . 6-85Compiling a Form at the Command Line . . . . . . . . 6-88Default Forms . . . . . . . . . . . . . . . . . . 6-89

    Using PERFORM Forms in 4GL . . . . . . . . . . . . . 6-92

    Chapter 7 INFORMIX-4GL ReportsIn This Chapter . . . . . . . . . . . . . . . . . . . 7-3Features of 4GL Reports . . . . . . . . . . . . . . . . 7-4Producing 4GL Reports . . . . . . . . . . . . . . . . 7-5

    The Report Driver . . . . . . . . . . . . . . . . 7-5The Report Definition . . . . . . . . . . . . . . . 7-7

    DEFINE Section . . . . . . . . . . . . . . . . . . 7-10OUTPUT Section . . . . . . . . . . . . . . . . . . 7-12ORDER BY Section . . . . . . . . . . . . . . . . . 7-23FORMAT Section . . . . . . . . . . . . . . . . . . 7-28FORMAT Section Control Blocks . . . . . . . . . . . . 7-32

    AFTER GROUP OF . . . . . . . . . . . . . . . . 7-34BEFORE GROUP OF . . . . . . . . . . . . . . . 7-37FIRST PAGE HEADER . . . . . . . . . . . . . . . 7-40ON EVERY ROW. . . . . . . . . . . . . . . . . 7-42ON LAST ROW . . . . . . . . . . . . . . . . . 7-44PAGE HEADER . . . . . . . . . . . . . . . . . 7-45PAGE TRAILER . . . . . . . . . . . . . . . . . 7-47

    Statements in REPORT Control Blocks . . . . . . . . . . 7-48Statements Valid Only in the FORMAT Section . . . . . . 7-49EXIT REPORT . . . . . . . . . . . . . . . . . . 7-50NEED. . . . . . . . . . . . . . . . . . . . . 7-51PAUSE . . . . . . . . . . . . . . . . . . . . 7-52PRINT . . . . . . . . . . . . . . . . . . . . 7-53SKIP . . . . . . . . . . . . . . . . . . . . . 7-66

    MIX-4GL Reference Manual

  • Appendix A The ASCII Character Set

    Appendix B INFORMIX-4GL Utility Programs

    Appendix C Using C with INFORMIX-4GL

    Appendix D Environment Variables

    Appendix E Developing Applications with Global Language Support

    Appendix F Modifying termcap and terminfo

    Appendix G Reserved Words

    Appendix H The Demonstration Application

    Appendix I SQL Statements That Can Be Embedded in 4GL Code

    Glossary

    Index

    Table of Contents xi

  • xii INFO

    RMIX-4GL Reference Manual
  • Introduction

    Introduction

    In This Introduction . . . . . . . . . . . . . . . . . . 3

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

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

    Feature, Product, and Platform Icons . . . . . . . . . . 9Compliance Icons . . . . . . . . . . . . . . . . 9

    Example-Code Conventions . . . . . . . . . . . . . . 10Syntax Conventions . . . . . . . . . . . . . . . . . 10

    Elements That Can Appear on the Path . . . . . . . . . 11How to Read a Syntax Diagram . . . . . . . . . . . . 13

    Additional Documentation . . . . . . . . . . . . . . . . 15Documentation Included with 4GL . . . . . . . . . . . . 15On-Line Manuals . . . . . . . . . . . . . . . . . . 16On-Line Help . . . . . . . . . . . . . . . . . . . 16On-Line Error Messages. . . . . . . . . . . . . . . . 16Related Reading . . . . . . . . . . . . . . . . . . 18Informix Developer Network . . . . . . . . . . . . . . 18

    Informix Welcomes Your Comments . . . . . . . . . . . . . 19

  • 2 INFOR

    MIX-4GL Reference Manual
  • In This IntroductionThis Introduction provides an overview of the information in this manualand describes the conventions it uses.

    About This ManualThis manual is designed to be a day-to-day, keyboard-side companion for4GL programmers. It describes the features and syntax of the 4GL language,including 4GL statements, forms, reports, and the built-in functions andoperators.

    Organization of This ManualThis manual is divided into two volumes and includes the following chaptersand appendixes:

    Chapter 1, Compiling INFORMIX-4GL Source Files, describes theC Compiler and Rapid Development System implementations ofINFORMIX-4GL. It also explains how to create executable versions of4GL source files, both from the Programmers Environment and fromthe command line.

    Chapter 2, The INFORMIX-4GL Language, provides an overviewof 4GL language features and graphical features of the applicationsthat you can create with INFORMIX-4GL.

    Chapter 3, Data Types and Expressions, describes 4GL data types,expressions, and other syntax topics that affect several statements.

    Introduction 3

  • Organization of This Manual

    Chapter 4, INFORMIX-4GL Statements, describes the statementsof 4GL in alphabetical order.

    Chapter 5, Built-In Functions and Operators, includes an overviewof the predefined functions and operators of 4GL, and describes theirindividual syntax, with examples of usage.

    Chapter 6, Screen Forms, provides an overview of 4GL screenforms and form drivers, and describes the syntax of 4GL form speci-fication files. It also describes how to create forms with the form4glform compiler, and how the upscol utility can set default attributes.

    Chapter 7, INFORMIX-4GL Reports, offers an overview of 4GLreports and report drivers, and describes the syntax of 4GL reportdefinitions. It also describes the syntax of statements and operatorsthat can appear only in 4GL reports.

    Appendix A, The ASCII Character Set, lists the ASCII charactersand their numeric codes.

    Appendix B, INFORMIX-4GL Utility Programs, describes themkmessage and upscol utility programs.

    Appendix C, Using C with INFORMIX-4GL, describes how to callC functions from 4GL programs, and vice versa, and describes afunction library for conversion between the DECIMAL data type of4GL and the C data types.

    Appendix D, Environment Variables, describes the environmentvariables that are used by 4GL.

    Appendix E, Developing Applications with Global LanguageSupport, describes the internationalization and localizationfeatures that are provided with 4GL, and shows how to develop 4GLapplications that are world-ready and easy to localize.

    Appendix F, Modifying termcap and terminfo, describes themodifications you can make to your termcap and terminfo files toextend function key definitions, to specify characters for windowborders, and to enable 4GL programs to interact with terminals thatsupport color displays.

    Appendix G, Reserved Words, lists words that you should notdeclare as identifiers in 4GL programs. It also lists the ANSI reservedwords of SQL.

    Appendix H, The Demonstration Application, lists the code of thedemo4.4ge demonstration application.

    4 INFORMIX-4GL Reference Manual

  • Types of Readers

    Appendix I, SQL Statements That Can Be Embedded in 4GL Code,lists SQL syntax that is directly supported in 4GL.

    The Glossary defines terms used in the 4GL documentation set.

    Types of ReadersThis manual is written for all 4GL developers. You do not need databasemanagement experience nor familiarity with relational database concepts touse this manual. A knowledge of SQL (structured query language), however,and experience using a high-level programming language would be useful.

    Software DependenciesThis manual is written with the assumption that you are using an Informixdatabase server, Version 7.x or later.

    Informix offers two implementations of the 4GL application developmentlanguage:

    The INFORMIX-4GL C Compiler uses a preprocessor to generateInformix ESQL/C source code. This code is preprocessed in turn toproduce C source code, which is then compiled and linked as objectcode in an executable command file.

    The INFORMIX-4GL Rapid Development System (RDS) uses acompiler to produce pseudo-machine code (called p-code) in a singlestep. You then invoke a runner to execute the p-code version of yourapplication.

    Both versions of 4GL use the same 4GL statements. Chapter 1, CompilingINFORMIX-4GL Source Files, describes the differences between the twoversions of 4GL and explains how to use both versions.

    You can easily use applications developed with an earlier version of 4GL,such as Version 4.x or 6.x or 7.2, with this version of 4GL. For RDS programsthat use p-code, however, you must first recompile your 4GL source code.

    Introduction 5

  • Assumptions About Your Locale

    Assumptions About Your LocaleInformix products can support many languages, cultures, and code sets.All culture-specific information is brought together in a single environment,called a GLS (Global Language Support) locale.

    Examples in this manual are written with the assumption that you are usingthe default locale, en_us.8859-1. This supports U.S. English format conven-tions for dates, times, and currency, and the ISO 8859-1 code set. Someversions of this locale support various non-ASCII 8-bit characters such as , ,and . Like all locales that Informix provides with its GLS libraries, however,the default locale supports the ASCII characters (as listed in Appendix A).

    If you plan to use non-ASCII characters in your data or your SQL identifiers,or if you want nondefault collation of character data, you need to specify theappropriate nondefault locale. For instructions on how to specify a nonde-fault locale, additional syntax, and other considerations related to GLS, seethe Informix Guide to GLS Functionality. See also Appendix E, DevelopingApplications with Global Language Support.

    Demonstration Database and Examples4GL includes several 4GL demonstration applications, along with a demon-stration database called stores7 that contains information about a fictitiouswholesale sporting-goods distributor. You can create the stores7 database inthe current directory by entering the following command:

    dbaccessdemo7

    Many (but not all) of the examples in the 4GL documentation set are based onthe stores7 database. This database is described in detail in Appendix A ofINFORMIX-4GL by Example. For more information on creating the demon-stration database and using the examples, see the introduction to INFORMIX-4GL by Example.

    6 INFORMIX-4GL Reference Manual

  • Accessing Databases from Within 4GL

    Accessing Databases from Within 4GLThe 4GL language approximates a superset of the Informix implementationof the industry-standard SQL language. Because the 4GL compiler does notrecognize some SQL statements, however, three methods are supported forincluding SQL statements within the 4GL program:

    For most SQL syntax that was supported by Informix 4.1 databaseservers, you can directly embed SQL statements in 4GL source code.

    For SQL statements that can be prepared, you can use the PREPAREfeature of SQL to include SQL statements as text in prepared objects.

    For all SQL statements that can be prepared, you can also use theSQL ... END SQL delimiters to enclose the SQL statement. UnlikePREPARE, these can include host variables for input and output.

    You must use one of the last two methods for SQL statements that includesyntax that was introduced later than Informix 4.1 database servers. Suchembedded, prepared, or delimited SQL statements are passed on to thedatabase server for execution, as in the following 4GL program fragment:

    DEFINE bugfile, setdeb CHAR(255)DATABASE stores7 --Directly embedded SQLLET setdeb = "set debug file to /u/tanya/bugfile"PREPARE bugfile FROM setdeb --Prepared SQL (post-4.1)EXECUTE IMMEDIATE bugfile --Directly embedded SQLSQL SET PDQPRIORITY HIGH --Delimited SQL (post-4.1)END SQL

    Appendix I, SQL Statements That Can Be Embedded in 4GL Code, lists thesupported SQL syntax.

    If you are uncertain which method is needed, use SQLEND SQL delimiters,which generally offer wider functionality and greater ease of coding thanPREPARE for SQL statements that cannot be directly embedded.

    For additional information on SQL statements, see Informix Guide to SQL:Syntax.

    Introduction 7

  • Documentation Conventions

    Documentation ConventionsThis section describes certain conventions that this manual uses.

    These conventions make it easier to gather information from this and othervolumes in the documentation set. The following conventions are discussed:

    Typographical conventions

    Icon conventions

    Example-code conventions

    Syntax conventions

    Typographical ConventionsThis manual uses the following conventions to introduce new terms,illustrate screen displays, describe command syntax, and so forth.

    Tip: When you are instructed to enter characters or to execute a command,immediately press RETURN after the entry. When you are instructed to type thetext or to press other keys, no RETURN is required.

    Convention Meaning

    KEYWORD All primary elements in a programming language statement(keywords) appear in uppercase letters in a serif font.

    italicsitalicsitalics

    Within text, new terms and emphasized words appear in italics.Within syntax diagrams and code examples, identifiers or valuesthat you are to specify appear in italics.

    boldfaceboldface

    Names of program entities (such as classes, events, and tables),environment variables, file and pathnames, and interfaceelements (such as icons, menu items, and buttons) appear inboldface.

    monospacemonospace

    Information that the product displays and information that youenter appear in a monospace typeface.

    KEYSTROKE Keys to press appear in uppercase letters in a sans serif font.

    8 INFORMIX-4GL Reference Manual

  • Icon Conventions

    Icon ConventionsThroughout the documentation, you will find text that is identified by severaldifferent types of icons. This section describes these icons.

    Feature, Product, and Platform Icons

    Feature, product, and platform icons identify paragraphs that containfeature-specific, product-specific, or platform-specific information.

    These icons can apply to a row in a table, one or more paragraphs, or an entiresection. A symbol indicates the end of the feature-specific, product-specific, or platform-specific information.

    Compliance Icons

    Compliance icons indicate paragraphs that provide guidelines for complyingwith a standard.

    These icons can apply to a row in a table, one or more paragraphs, or an entiresection. A symbol indicates the end of the compliance information.

    Icon Description

    Identifies information that relates to the Informix GlobalLanguage Support (GLS) feature.

    Identifies information or syntax that is specific to InformixDynamic Server.

    Identifies information or syntax that is specific toINFORMIX-SE.

    Identifies SQL statements that you must put in an SQLblock or prepare statement.

    Icon Description

    Identifies information that is specific to an ANSI-compliantdatabase

    GLS

    IDS

    SE

    SQL

    ANSI

    Introduction 9

  • Example-Code Conventions

    Example-Code ConventionsExamples of 4GL source code occur in several sections of this manual.For readability, 4GL or SQL keywords generally appear in uppercasecharacters in code examples, and identifiers usually appear in lowercase ormixed case.

    For instance, you might see code as in the following example:

    MENU "CUSTOMER"COMMAND "Query" "Search for a customer"

    CALL query_data( )NEXT OPTION "Modify"

    ...COMMAND "Modify" "Modify a customer"...

    END MENU

    Ellipsis ( ) symbols in a code example indicate that more code would beadded in a complete application, but for clarity and simplicity, the exampleomits code that is extraneous to the current topic. (In most contexts, acompile-time or runtime error occurs if literal ellipsis symbols appear incode, or if you omit code that is necessary to your program logic.) Ellipsissymbols do not begin or end code examples, however, even if additional codewould be required for a complete program, or for a complete statement.

    Most 4GL code examples are fragments of programs, rather than completeprograms that can be compiled and executed. Because most examples areprovided to illustrate some specific topic, the examples sometimes do notstrictly conform to good programming practice. For example, they might notcheck to verify that an operation successfully executed without error, or theymight not include the comments that normally should be included toimprove readability and simplify maintenance of your code.

    Syntax ConventionsSQL statement syntax is described in the Informix Guide to SQL: Syntax.The syntax for 4GL statements is described in Chapter 4 of this manual.Most chapters of this book describe the syntax of some aspect of the 4GLlanguage, such as expressions, form specifications, and reports.

    10 INFORMIX-4GL Reference Manual

  • Syntax Conventions

    This section describes conventions for syntax diagrams. Each diagramdisplays the sequences of required and optional keywords, terms, andsymbols that are valid in a given statement or segment. Figure 1 shows thesyntax diagram of the OPEN FORM statement.

    Each syntax diagram begins at the upper-left corner and ends at the upper-right corner with a vertical terminator. Between these points, any path thatdoes not stop or reverse direction describes a possible form of the statement.(For a few diagrams, however, notes in the text identify path segments thatare mutually exclusive.)

    Syntax elements in a path represent terms, keywords, symbols, and segmentsthat can appear in your statement. The path always approaches elementsfrom the left and continues to the right, except in the case of separators inloops. For separators in loops, the path approaches counterclockwise. Unlessotherwise noted, at least one blank character separates syntax elements.

    Elements That Can Appear on the Path

    You might encounter one or more of the following elements on a path.

    Figure 1Example of a Simple Syntax Diagram

    Element Description

    KEYWORD A word in UPPERCASE letters is a keyword. You mustspell the word exactly as shown; you can, however,use either uppercase or lowercase letters.

    ( . , ; @ + * - / ) Punctuation and other nonalphanumeric charactersare literal symbols that you must enter exactly asshown.

    " "

    ' '

    Double quotation marks must be entered as shown. Ifyou prefer, a pair of double quotation marks canreplace a pair of single quotation marks, but youcannot mix double and single quotation marks.

    (1 of 3)

    OPEN FORM form FROM "filename"

    Introduction 11

  • Syntax Conventions

    variable A word in italics represents a value that you mustsupply. A table that follows the diagram explains thevalue.

    A reference in a box represents a subdiagram. Imaginethat the subdiagram is spliced into the main diagramat this point. When a page number is not specified, thesubdiagram appears on the same page. The aspectratios of boxes are not significant.

    A reference to SQL:S in a syntax diagram represents anSQL statement or segment that is described in theInformix Guide to SQL: Syntax. Imagine that thesegment were spliced into the diagram at this point.

    An icon is a warning that this path is valid only forsome products, or conditions. The following iconsappear in some syntax diagrams:

    This path is valid only forINFORMIX-SE database servers.

    This path is valid only for InformixDynamic Server.

    This path is an Informix extension tothe ANSI SQL-92 entry-level SQLstandard.

    A shaded option is the default, if you provide no otherspecification.

    A syntax segment within a pair of arrows is asubdiagram.

    The vertical line terminates the syntax diagram.

    A branch below the main path indicates an optionalpath. (Any term on the main path is required, unlessa branch can circumvent it.)

    Element Description

    (2 of 3)

    ATTRIBUTEClausep. 3-288

    ATTRIBUTE Clause

    SELECT Statementsee SQL:S

    SE

    SE

    IDS

    +

    ALL

    . . .

    NOT

    IS NULL

    12 INFORMIX-4GL Reference Manual

  • Syntax Conventions

    How to Read a Syntax Diagram

    Figure 2 shows a syntax diagram that uses some of the path elements that theprevious table lists.

    The Case III label above the diagram implies that this statement can have atleast two other syntax patterns. To use this diagram to construct a statement,start at the top left with the keyword DISPLAY. Then follow the diagram tothe right, proceeding through the options that you want.

    A set of multiple branches indicates that a choiceamong more than two different paths is available.

    A loop indicates a path that you can repeat.Punctuation along the top of the loop indicates theseparator symbol for list items.

    If no symbol appears, a blank space is the separator, or(as here) the Linefeed that separates successive state-ments in a source module.

    A gate ( ) on a path indicates that you can only usethat path the indicated number of times, even if it ispart of a larger loop. You can specify size no more thanthree times within this statement segment.

    Element Description

    (3 of 3)

    ERROR

    NOT FOUND

    WARNING

    ,

    variable

    statement

    3

    ,

    size

    3

    Figure 2Example of a Syntax Diagram

    ATTRIBUTE Clause

    variable

    ,

    value

    ,

    DISPLAY

    BY NAME

    Field Clause

    ,

    TO

    Case III: (display output in a screen form)

    Introduction 13

  • Syntax Conventions

    Figure 2 illustrates the following steps:

    1. Type the keyword DISPLAY.

    2. You can display the values of a list of variables to an explicit list offields within the current screen form:

    Type the name of a value. If you want to display several values,separate successive values by a comma.

    Type the keyword TO after the name of the last value.

    Type the name of a field in the current form in which to displaythe first value. To find the syntax for specifying field names, go tothe Field Clause segment on the specified page.

    3. If you are using a form whose fields have the same names as thevalues that you want to display, you can follow the lower path:

    Type the keywords BY NAME after DISPLAY.

    Type the name of a variable. If you want to display the values ofseveral variables, separate successive variables by comma.

    4. You can optionally set a screen attribute for the displayed values:

    Use the syntax of the ATTRIBUTE Clause segment on thespecified page to specify the screen attribute that you desire.

    5. Follow the diagram to the terminator.

    Your DISPLAY TO or DISPLAY BY NAME statement is now complete.

    A restriction on step 2 (that there must be as many fields as variables)appears in notes that follow the diagram, rather than in the diagramitself. If 4GL issues an error when you compile a statement that seemsto follow the syntax diagram, it might be a good idea to also read theusage notes for that statement.

    14 INFORMIX-4GL Reference Manual

  • Additional Documentation

    Additional DocumentationFor additional information, you might want to refer to the following types ofdocumentation:

    Documentation included with 4GL

    On-line manuals

    On-line help

    On-line error messages

    Related reading

    Documentation Included with 4GLThe INFORMIX-4GL documentation set includes the following additionalmanuals:

    INFORMIX-4GL Installation Guide is a pamphlet that describes how toinstall the various 4GL products.

    INFORMIX-4GL Concepts and Use introduces 4GL and provides thecontext needed to understand the other manuals in the documen-tation set. It covers 4GL goals (what kinds of programming thelanguage is meant to facilitate), concepts and nomenclature (parts ofa program, ideas of database access, screen form, and report gener-ation), and methods (how groups of language features are usedtogether to achieve particular effects).

    INFORMIX-4GL by Example is a collection of 30 annotated 4GLprograms. Each is introduced with an overview; then the programsource code is shown with line-by-line notes. The program sourcefiles are distributed as text files with the product; scripts that createthe demonstration database and copy the applications are alsoincluded.

    Documentation Notes, which contain additions and corrections to themanuals, and Release Notes are located in the directory where theproduct is installed. Please examine these files because they containvital information about application and performance issues.

    Introduction 15

  • On-Line Manuals

    If you have also purchased the INFORMIX-4GL Interactive Debugger product(which requires the INFORMIX-4GL Rapid Development System), your 4GLdocumentation also includes the following manual:

    Guide to the INFORMIX-4GL Interactive Debugger is both an intro-duction to the Debugger and a comprehensive reference of Debuggercommands and features. The Debugger allows you view the sourcecode and to interact with your 4GL programs while they are running.It helps you to analyze the logic of your 4GL program and todetermine the source of runtime errors within your programs.

    On-Line ManualsThe Informix Answers OnLine CD allows you to print chapters or entirebooks and perform full-text searches for information in specific books orthroughout the documentation set. You can install the documentation oraccess it directly from the CD. For information about how to install, read, andprint on-line manuals, see the installation insert that accompanies AnswersOnLine. You can also access Answers OnLine on the Web at the followingURL:

    http://www.informix.com/answers

    On-Line HelpThe Programmers Environment of 4GL provides on-line help; you caninvoke help by pressing CONTROL-W.

    On-Line Error MessagesUse the finderr script to display a particular error message or messages onyour screen. The script is located in the $INFORMIXDIR/bin directory.

    16 INFORMIX-4GL Reference Manual

  • On-Line Error Messages

    The finderr script has the following syntax.

    For example, to display the -359 error message, you can enter either of thefollowing:

    finderr -359

    or, equivalently:

    finderr 359

    The following example demonstrates how to specify a list of error messages.The example also pipes the output to the UNIX more command to control thedisplay. You can also direct the output to another file so that you can save orprint the error messages:

    finderr 233 107 113 134 143 144 154 | more

    A few messages have positive numbers. These messages are used solelywithin the application tools. In the unlikely event that you want to displaythem, you must precede the message number with the + sign.

    The messages numbered -1 to -100 can be platform-dependent. If the messagetext for a message in this range does not apply to your platform, check theoperating system documentation for the precise meaning of the messagenumber.

    msg_num Indicates the number of the error message to display. Error messagenumbers range from -1 to -32000. Specifying the - sign is optional.

    finderr msg_num

    Introduction 17

  • Related Reading

    Related ReadingThe following Informix database server publications provide additionalinformation about the topics that this manual discusses:

    Informix database servers and the SQL language are described inseparate manuals, including Informix Guide to SQL: Tutorial, InformixGuide to SQL: Syntax, and Informix Guide to SQL: Reference.

    Information about setting up Informix database servers is providedin the Administrators Guide for your Informix database server.

    Informix Press, in partnership with Prentice Hall, publishes books aboutInformix products. Authors include experts from Informix user groups,employees, consultants, and customers. Recent titles about INFORMIX-4GLinclude:

    Advanced INFORMIX-4GL Programming, by Art Taylor, 1995.

    Programming Informix SQL/4GL: A Step-by-Step Approach, by CathyKipp, 1998.

    Informix Basics, by Glenn Miller, 1998.

    You can access Informix Press on the Web at the following URL:

    http://www.informix.com/ipress

    Informix Developer NetworkInformix maintains the Informix Developer Network (IDN) as a resource bywhich developers of Informix-based applications can exchange informationwith their peers and with Informix experts. You can access the InformixDeveloper Network on the Web at the following URL:

    http://www.informix.com/idn

    18 INFORMIX-4GL Reference Manual

  • Informix Welcomes Your Comments

    Informix Welcomes Your CommentsLet us know what you like or dislike about our manuals. To help us withfuture versions of our manuals, we want to know about any corrections orclarifications that you would find useful. Include the following information:

    The name and version of the manual that you are using

    Any comments that you have about the manual

    Your name, address, and phone number

    Write to us at the following address:

    Informix Software, Inc.Technical Publications Department4100 Bohannon DriveMenlo Park, CA 94025

    If you prefer to send electronic mail, our address is:

    [email protected]

    We appreciate your suggestions.

    Important: The doc alias is monitored only by the Informix departments that createand maintain manuals and on-line documentation files. It is not an appropriatechannel for technical support issues, sales inquiries, or questions about the avail-ability of Informix products.

    Introduction 19

  • 1Chapter

    Compiling INFORMIX-4GLSource Files

    In This Chapter . . . . . . . . . . . . . . . . . . . . 1-3

    Two Implementations of INFORMIX-4GL . . . . . . . . . . . 1-3Differences Between the C Compiler and RDS Versions . . . . . 1-4

    Differences in the Programmers Environment . . . . . . 1-4Differences in Commands . . . . . . . . . . . . . 1-5Differences in Filename Extensions . . . . . . . . . . 1-5

    The C Compiler Version . . . . . . . . . . . . . . . . . 1-6The Five-Phase 4GL Compilation Process. . . . . . . . . . 1-6The Programmers Environment . . . . . . . . . . . . . 1-8

    The INFORMIX-4GL Menu . . . . . . . . . . . . . 1-8The MODULE Design Menu . . . . . . . . . . . . 1-9The FORM Design Menu . . . . . . . . . . . . . . 1-14The PROGRAM Design Menu . . . . . . . . . . . . 1-19The QUERY LANGUAGE Menu . . . . . . . . . . . 1-26

    Creating Programs in the Programmers Environment . . . . . 1-26Creating a New Source Module . . . . . . . . . . . . 1-27Revising an Existing Module . . . . . . . . . . . . . 1-27Compiling a Source Module . . . . . . . . . . . . . 1-28Linking Program Modules . . . . . . . . . . . . . 1-29Executing a Compiled Program . . . . . . . . . . . . 1-31

    Creating Programs at the Command Line. . . . . . . . . . 1-32Creating or Modifying a 4GL Source File . . . . . . . . 1-33Compiling a 4GL Module . . . . . . . . . . . . . . 1-33Compiling and Linking Multiple Source Files . . . . . . . 1-33Using the c4gl Script for Compilation . . . . . . . . . . 1-34The -globcurs and -localcurs Options . . . . . . . . . . 1-38Shared Libraries . . . . . . . . . . . . . . . . . 1-40Invoking a Compiled 4GL Program at the Command Line . . 1-44

    Program Filename Extensions . . . . . . . . . . . . . 1-45

  • 1-2 INFO

    The Rapid Development System . . . . . . . . . . . . . . 1-47The Programmers Environment . . . . . . . . . . . . . 1-47

    The INFORMIX-4GL Menu . . . . . . . . . . . . . 1-47The MODULE Design Menu . . . . . . . . . . . . . 1-48The FORM Design Menu . . . . . . . . . . . . . . 1-54The PROGRAM Design Menu . . . . . . . . . . . . 1-59The QUERY LANGUAGE Menu . . . . . . . . . . . 1-66

    Creating Programs in the Programmers Environment . . . . . 1-67Creating a New Source Module . . . . . . . . . . . . 1-67Revising an Existing Module . . . . . . . . . . . . . 1-68Compiling a Source Module . . . . . . . . . . . . . 1-68Combining Program Modules . . . . . . . . . . . . 1-69Executing a Compiled RDS Program . . . . . . . . . . 1-71Invoking the Debugger . . . . . . . . . . . . . . . 1-72

    Creating Programs at the Command Line . . . . . . . . . . 1-72Creating or Modifying a 4GL Source File . . . . . . . . . 1-74Compiling an RDS Source File . . . . . . . . . . . . 1-74Concatenating Multi-Module Programs . . . . . . . . . 1-76Running RDS Programs . . . . . . . . . . . . . . 1-77Running Multi-Module Programs . . . . . . . . . . . 1-78Running Programs with the Interactive Debugger . . . . . 1-79RDS Programs That Call C Functions . . . . . . . . . . 1-79Editing the fgiusr.c File . . . . . . . . . . . . . . . 1-80Creating a Customized Runner . . . . . . . . . . . . 1-82Running Programs That Call C Functions . . . . . . . . 1-85

    Program Filename Extensions . . . . . . . . . . . . . . 1-86

    RMIX-4GL Reference Manual

  • In This ChapterThis chapter describes how to create INFORMIX-4GL source-code modules,and how to produce executable 4GL programs from these modules, both atthe operating system prompt and in the Programmers Environment.Procedures to do this are shown for the INFORMIX-4GL C Compiler, as well asfor the INFORMIX-4GL Rapid Development System. These two implementa-tions of 4GL differ in how they process 4GL source-code modules. Thischapter begins by identifying differences between the two implementationsof 4GL. It then goes on to describe each implementation of 4GL.

    Except as otherwise noted, the other chapters and appendixes of this manualdescribe features that are identical in both the C Compiler and the RapidDevelopment System implementations of 4GL.

    Two Implementations of INFORMIX-4GLTo write a 4GL program, you must first create an ASCII file of 4GL statementsthat perform logical tasks to support your application. This chapter explainsthe procedures by which you can transform one or more source-code files of4GL statements into an executable 4GL program. Informix offers two imple-mentations of the 4GL application development language:

    The INFORMIX-4GL C Compiler, whose preprocessor generatesextended ESQL/C source code. This code is further processed inseveral steps to produce C source code, which is compiled and linkedas object code in an executable command file.

    The INFORMIX-4GL Rapid Development System (RDS), which uses acompiler to produce pseudo-machine code (called p-code) in a singlestep. You then invoke a runner to execute the p-code version of yourapplication. For more details, see Compiling and Linking MultipleSource Files on page 1-33.

    Compiling INFORMIX-4GL Source Files 1-3

  • Differences Between the C Compiler and RDS Versions

    Important: This version of the runner or Debugger cannot interpret programscompiled to p-code by releases of 4GL earlier than Version 7.30. You must firstrecompile your source files and form specifications. Similarly, releases of the 4GLrunner or Debugger earlier than Version 7.30 cannot interpret p-code that thisrelease produces.

    Differences Between the C Compiler and RDS VersionsBoth implementations of 4GL use the same 4GL statements and nearlyidentical Programmers Environments. Because they use different methodsto compile 4GL source files into executable programs, however, there are afew differences in the user interfaces.

    Differences in the Programmers Environment

    The Programmers Environment is a system of menus that supports thevarious steps in the process of developing 4GL application programs. TheDrop option on the PROGRAM design menu of the C Compiler is calledUndefine in the Rapid Development System implementation.

    The New and Modify options of the PROGRAM design menu display adifferent screen form in the two implementations. Both of these screen formsare illustrated later in this chapter.

    The Rapid Development System includes a Debug option on its MODULEdesign menu and PROGRAM design menu. This option does not appear inthe C Compiler. (The Debugger is based on p-code, so it can execute only 4GLprograms and modules that have been compiled by the Rapid DevelopmentSystem.)

    The INFORMIX-4GL Interactive Debugger is available as a separate product.

    1-4 INFORMIX-4GL Reference Manual

  • Differences Between the C Compiler and RDS Versions

    Differences in Commands

    The commands you use to enter the Programmers Environments, compileand execute 4GL programs, and build or restore the stores7 demonstrationdatabase vary between implementations of 4GL.

    The C Compiler requires no equivalent command to the fglgo command,because its compiled object files are executable without a runner. The RapidDevelopment System also contains a command-file script to compile andexecute 4GL programs that call C functions or INFORMIX-ESQL/C functions,as described in RDS Programs That Call C Functions on page 1-79.

    Differences in Filename Extensions

    The differences in filename extensions are as follows.

    The backup file extensions .4bo and .4be for compiled modules andprograms have the same names in both implementations. These files are notinterchangeable between the two 4GL implementations, however, becauseobject code produced by a C compiler is different from p-code.

    Other filename extensions that are the same in both the C Compiler and theRapid Development System designate interchangeable files, if you use bothimplementations of 4GL to process the same 4GL source-code module.

    C Compiler RDS Effect of Command

    i4gl r4gl Enter Programmers Environment

    c4gl sfile.4gl fglpc sfile Compile 4GL source file sfile.4gl

    xfile.4ge fglgo xfile Execute compiled 4GL program xfile

    i4gldemo r4gldemo Create the demonstration database

    C Compiler RDS Significance of Extension

    .o .4go Compiled 4GL source-code module

    .4ge .4gi Executable (runable) 4GL program file

    Compiling INFORMIX-4GL Source Files 1-5

  • The C Compiler Version

    The C Compiler VersionThis section describes the following aspects of the C compiler version of 4GL:

    The five steps of the compilation process

    All the menu options and screen form fields of the ProgrammersEnvironment

    The steps for compiling and executing 4GL programs from theProgrammers Environment

    The equivalent command-line syntax for compiling and executing4GL programs

    The filename extensions of 4GL source-code, object, error, andbackup files

    The Five-Phase 4GL Compilation ProcessVersions of 4GL earlier than 6.0 were built on ESQL/C. To make 4GL moreindependent of ESQL/C, the compilation sequence requires one or more extraprocesses. Figure 1-1 on page 1-7 shows the five compilation phases inINFORMIX-4GL 6.0 and subsequent release versions. The five phases are asfollows:

    1. The i4glc1 preprocessor converts a 4GL source file with .4gl extensioninto a file with .4ec extension. It parses the 4GL language andgenerates C code to handle function and report definitions, compu-tations, and function calls. It generates extended ESQL/C statementsto handle forms, menus, input statements, and display statements,and pure ESQL/C to handle SQL statements and declarations ofvariables. i4glc1 is similar to Version 4.12 and earlier fglc, except thati4glc1 generates a .4ec file instead of a .ec file.

    2. The i4glc2 preprocessor translates the extended form, menu, input,and display statements to pure C code but leaves variable declara-tions and SQL statements unchanged. i4glc2 accepts a .4ec filegenerated by i4glc1 as input and produces a .ec file containing pureESQL/C code.

    1-6 INFORMIX-4GL Reference Manual

  • The Five-Phase 4GL Compilation Process

    3. The i4glc3 preprocessor is a copy of the ESQL/C compiler. The i4glc3preprocessor accepts a .ec file (produced by i4glc2 or written as pureESQL/C code), and produces a .c file. The declarations and the SQLstatements are mapped to pure C language code.

    4. The i4glc4 preprocessor converts C code, which may contain non-ASCII characters in variable names, into de-internationalized names.This step ensures that defining a record like table.* or a field liketable.column does not produce C code that contains non-ASCIIcharacter in identifiers (because very few C compilers accept non-ASCII characters in the names of variables).

    5. Informix uses the system C compiler to convert the C code generatedby i4glc3 or i4glc4 into object files (a file with .o extension) andexecutable programs (a file with .4ge extension).

    Figure 1-1Five-Phase

    CompilationProcess

    i4glc1

    \ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \

    file.4gl

    file.4ec

    \ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \

    file.ec

    \ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \

    file.c

    \ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \ \ \

    file.cfile.oorfile.4ge

    i4glc2i4glc3

    i4glc4CC

    Compiling INFORMIX-4GL Source Files 1-7

  • The Programmers Environment

    The Programmers EnvironmentThe C Compiler provides a series of nested menus, called the ProgrammersEnvironment. These menus support the steps of 4GL program developmentand keep track of the components of your application. You can invoke theProgrammers Environment by entering i4gl at the system prompt.

    The INFORMIX-4GL Menu

    The i4gl command briefly displays the INFORMIX-4GL banner. Then a menuappears, called the INFORMIX-4GL menu.

    This is the highest menu, from which you can reach any other menu of theProgrammers Environment. You have five options:

    Module. Work on a 4GL program module.

    Form. Work on a screen form.

    Program. Specify components of a multi-module program.

    Query-language. Use an SQL interactive interface, if you have eitherINFORMIX-SQL or DB-Access installed on your system. (See thedocumentation of these Informix products for details of their use.)

    Exit. Terminate i4gl and return to the operating system.

    The first three options display new menus that are described in the pages thatfollow. (You can also press CONTROL-W at any menu to display an on-line helpmessage that describes your options.) As at any 4GL menu, you can choosean option in either of two ways:

    By typing the first letter of the option

    By using the SPACEBAR or arrow keys to move the highlight to theoption that you choose, and then pressing RETURN

    INFORMIX-4GL: Module Form Program Query-language ExitCreate, modify, or run individual 4GL program modules.

    -------------------------------------------------Press CTRL-W for Help------

    1-8 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The MODULE Design Menu

    You can press RETURN or type m or M to choose the Module option of theINFORMIX-4GL menu. This displays a new menu, called the MODULE designmenu. Use this menu to work on an individual 4GL source-code module.

    Use this menu to create and compile source-code modules of a 4GL appli-cation. (For information on creating and compiling 4GL screen forms, seeThe FORM Design Menu on page 1-14. For details of how to create andcompile help messages, see the mkmessage utility in Appendix B,INFORMIX-4GL Utility Programs.)

    The MODULE design menu supports the following options:

    Modify. Change an existing 4GL source-code module.

    New. Create a new source-code module.

    Compile. Compile a source-code module.

    Program_Compile. Compile a 4GL application program.

    Run. Execute a compiled 4GL program module or a multi-moduleapplication program.

    Exit. Return to the INFORMIX-4GL menu.

    Within the Programmers Environment, the Exit option returns control to thehigher menu from which you accessed the current menu (or, when youchoose Exit from the INFORMIX-4GL menu, terminates the 4GL session andreturns to the system prompt).

    MODULE: Modify New Compile Program_Compile Run ExitChange an existing 4GL program module.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-9

  • The Programmers Environment

    The Modify Option

    Choose this option to edit an existing 4GL source-code module. If you choosethis option, 4GL requests the name of the 4GL source-code file to be modifiedand then prompts you to specify a text editor. If you have designated adefault editor with the DBEDIT environment variable (which is described inAppendix D) or if you specified an editor at the Programmers Environmentpreviously in this session, 4GL invokes that editor. The .4gl source file whosefilename you specified is the current file.

    When you leave the editor, 4GL displays the MODIFY MODULE menu, withthe Compile option highlighted.

    If you press RETURN or type c or C to choose the Compile option, 4GL displaysthe COMPILE MODULE menu:

    The Object option creates a compiled file with the .o extension but makes noattempt to link the file with other files.

    MODIFY MODULE: Compile Save-and-exit Discard-and-exitCompile the 4GL module specification.

    -------------------------------------------------Press CTRL-W for Help------

    COMPILE MODULE: Object Runable ExitCreate object file only; no linking to occur.

    -------------------------------------------------Press CTRL-W for Help------

    1-10 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The Runable option creates a compiled file with the .4ge extension. 4GLassumes that the current module is a complete 4GL program, and that noother module needs to be linked to it. Choose the Runable option if thecurrent program module is a stand-alone 4GL program. If this is not the case(that is, if the file is one of several 4GL source-code modules within a multi-module program), then you should use the Object option instead, and youmust use the PROGRAM design menu to specify all the component modules.

    After you choose Object or Runable, a message near the bottom of the screenwill advise you if 4GL issues a compile-time warning or error. If there arewarnings (but no errors), an object file is produced. Choose the Exit option ofthe next menu, and then Save-and-exit at the MODIFY MODULE menu, if youwish to save the executable file without reading the warnings.

    Alternatively, you can examine the warning messages by choosing Correctat the next menu. When you finish editing the .err file that contains thewarnings, you must choose Compile again from the MODIFY MODULEmenu, because the Correct option deletes the executable file.

    If there are compilation errors, the following menu appears.

    If you choose to correct the errors, an editing session begins on a copy of yoursource module with embedded error messages. You do not need to delete theerror messages because 4GL does this for you. Correct your source file, saveyour changes, and exit from the editor. The MODIFY MODULE menureappears, prompting you to recompile, save, or discard your changeswithout compiling.

    If you choose not to correct the errors, you are prompted to Save or Discardthe file.

    COMPILE MODULE: Correct ExitCorrect errors in the 4GL module.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-11

  • The Programmers Environment

    If there are no compilation errors, the MODIFY MODULE menu appears withthe Save-and-Exit option highlighted. Choose this option to save the currentsource-code module as a file with extension .4gl, and create an object file withthe same filename, but with the extension .o. If you specified Runable whenyou compiled, the executable version is saved with the extension .4ge. TheDiscard-and-Exit option discards any changes that were made to your fileafter you chose the Modify option.

    The New Option

    Choose this option to create a new 4GL source-code module.

    This option resembles the Modify option, but NEW MODULE is the menutitle, and you must enter a new module name, rather than choose it from alist.

    The filename of the module must be unique among source-code modules ofthe same 4GL program, and can include up to 10 characters, not including the.4gl file extension. If you have not designated an editor previously in thissession or with DBEDIT, you are prompted for an editor. Then an editingsession begins.

    MODULE: Modify New Compile Program_Compile Run ExitCreate a new 4GL program module.

    -------------------------------------------------Press CTRL-W for Help------

    1-12 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The Compile Option

    The Compile option enables you to compile an individual 4GL source-codemodule.

    After you specify the name of a 4GL source-code module to compile, thescreen displays the COMPILE MODULE menu. Its Object, Runable, and Exitoptions were described earlier in the discussion of the Modify option.

    The Program_Compile Option

    The Program_Compile option of the MODULE design menu is the same asthe Compile option of the PROGRAM design menu. This option can compileand link modules, as described in the program specification database, takinginto account the time when the modules were last updated.

    This option is useful after you modify a single module of a complex program,and need to test it by compiling and linking it with the other modules.

    The Run Option

    Choose the Run option to begin execution of a compiled 4GL program.

    MODULE: Modify New Compile Program_Compile Run ExitCompile an existing 4GL program module.

    -------------------------------------------------Press CTRL-W for Help------

    MODULE: Modify New Compile Program_Compile Run ExitExecute an existing 4GL program module or application program.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-13

  • The Programmers Environment

    The RUN PROGRAM screen lists compiled modules and programs, with thehighlight on the module corresponding to the current file, if any has beenspecified. Only compiled programs with extension .4ge are listed. If youcompile a program outside the Programmers Environment and you want itto appear in this list, give it the extension .4ge.

    If no compiled programs exist, 4GL displays an error message and returns tothe MODULE design menu. You can exit to the maine INFORMIX-4GL menu,and select the Program option to create the database.

    The Exit Option

    Choose this option to exit from the MODULE design menu and display theINFORMIX-4GL menu.

    The FORM Design Menu

    You can type f or F at the INFORMIX-4GL menu to choose the Form option.This option displays a menu, called the FORM design menu.

    MODULE: Modify New Compile Program_Compile Run ExitReturns to the INFORMIX-4GL menu.

    -------------------------------------------------Press CTRL-W for Help------

    FORM: Modify Generate New Compile ExitChange an existing form specification.

    -------------------------------------------------Press CTRL-W for Help------

    1-14 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    You can use this menu to create, modify, and compile screen form specifica-tions. These define visual displays that 4GL applications can use to query andmodify the information in a database. 4GL form specification files are ASCIIfiles that are described in Chapter 6, Screen Forms.

    The FORM design menu supports the following options:

    Modify. Change an existing 4GL screen form specification.

    Generate. Create a default 4GL screen form specification.

    New. Create a new 4GL screen form specification.

    Compile. Compile an existing 4GL screen form specification.

    Exit. Return to the INFORMIX-4GL menu.

    Readers familiar with INFORMIX-SQL may notice that this resembles themenu displayed by the Form option of the INFORMIX-SQL main menu.

    The Modify Option

    The Modify option of the FORM design menu enables you to edit an existingform specification file. It resembles the Modify option in the MODULE designmenu, because both options are used to edit program modules.

    If you choose this option, you are prompted to choose the name of a formspecification file to modify. Source files created at the FORM design menuhave the file extension .per. (If you use a text editor outside of theProgrammers Environment to create form specification files, you must givethem the extension .per before you can compile them with the FORM4GLscreen form facility.)

    FORM: Modify Generate New Compile ExitChange an existing form specification.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-15

  • The Programmers Environment

    If you have not already designated a text editor in this 4GL session or withDBEDIT, you are prompted for the name of an editor. Then an editing sessionbegins, with the form specification source-code file that you specified as thecurrent file. When you leave the editor, 4GL displays the MODIFY FORMmenu with the Compile option highlighted. Now you can press RETURN tocompile the revised form specification file.

    If there are compilation errors, 4GL displays the COMPILE FORM menu.

    Press RETURN to choose Correct as your option. An editing session beginson a copy of the current form, with diagnostic error messages embeddedwhere the compiler detected syntax errors. 4GL automatically deletes thesemessages when you save the file and exit from the editor. After you havecorrected the errors, the MODIFY FORM menu appears again, with theCompile option highlighted. Press RETURN to recompile. Repeat these stepsuntil the compiler reports no errors. (If you choose Exit instead of Correct,you are prompted to Save or Discard the file.)

    If there are no compilation errors, you are prompted to save the modifiedform specification file and the compiled form, or to discard the changes.(Discarding the changes restores the version of your form specifications frombefore you chose the Modify option.)

    MODIFY FORM: Compile Save-and-exit Discard-and-exitCompile the form specification.

    -------------------------------------------------Press CTRL-W for Help------

    COMPILE FORM: Correct ExitCorrect errors in the form specification.

    -------------------------------------------------Press CTRL-W for Help------

    1-16 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The Generate Option

    You can type g or G to choose the Generate option. This option creates asimple default screen form that you can use directly in your program, or thatyou can later edit by choosing the Modify option.

    When you choose this option, 4GL prompts you to select a database, to choosea filename for the form specification, and to identify the tables that the formwill access. After you provide this information, 4GL creates and compiles aform specification file. (This is equivalent to running the -d (default) optionof the form4gl command, as described in Compiling a Form at theCommand Line on page 6-88.)

    The New Option

    The New option of the FORM design menu enables you to create a new screenform specification.

    After prompting you for the name of your form specification file, 4GL placesyou in the editor where you can create a form specification file. When youleave the editor, 4GL transfers you to the NEW FORM menu that is like theMODIFY FORM menu. You can compile your form and correct it in the sameway.

    FORM: Modify Generate New Compile ExitGenerate and compile a default form specification.

    -------------------------------------------------Press CTRL-W for Help------

    FORM: Modify Generate New Compile ExitCreate a new form specification.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-17

  • The Programmers Environment

    The Compile Option

    The Compile option enables you to compile an existing form specificationfile without going through the Modify option.

    4GL compiles the form specification file whose name you specify. If thecompilation fails, 4GL displays the COMPILE FORM menu with the Correctoption highlighted.

    The Exit Option

    The Exit option restores the INFORMIX-4GL menu.

    FORM: Modify Generate New Compile ExitCompile an existing form specification.

    -------------------------------------------------Press CTRL-W for Help------

    FORM: Modify Generate New Compile ExitReturns to the INFORMIX-4GL menu.

    -------------------------------------------------Press CTRL-W for Help------

    1-18 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The PROGRAM Design Menu

    A 4GL program can be a single source-code module that you create andcompile at the MODULE design menu. For applications of greater complexity,however, it is often easier to create separate 4GL modules. TheINFORMIX-4GL menu includes the Program option to create multi-moduleprograms. If you choose this option, 4GL searches your DBPATH directoriesfor the program design database, which stores the names of the objects that areused to create programs and their build dependencies. (For more informationon the DBPATH environment variable, see Appendix D.)

    This program design database describes the component modules andfunction libraries of your 4GL program. By default, its name is syspgm4gl,but you can use the PROGRAM_DESIGN_DBS environment variable tospecify some other name. (For more information on thePROGRAM_DESIGN_DBS environment variable, see Appendix D.)

    If 4GL cannot find this database, you are asked if you want one created. If youenter y in response, 4GL creates the syspgm4gl database, grants CONNECTprivileges to PUBLIC, and displays the PROGRAM design menu. As databaseadministrator of syspgm4gl, you can later restrict the access of other users.

    If syspgm4gl already exists, the PROGRAM design menu appears.

    You can use this menu to create or modify a multi-module 4GL programspecification, to compile and link a program, or to execute a program.

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitChange the compilation definition of a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-19

  • The Programmers Environment

    The PROGRAM design menu supports the following options:

    Modify. Change an existing program specification.

    New. Create a new program specification.

    Compile. Compile an existing program.

    Planned_Compile. List the steps necessary to compile and link anexisting program.

    Run. Execute an existing program.

    Drop. Delete an existing program specification.

    Exit. Return to the INFORMIX-4GL menu.

    You must first use the MODULE design menu and the FORM design menu toenter and edit the 4GL statements within the component source-codemodules of a 4GL program. Then you can use the PROGRAM design menu toidentify which modules are part of the same application program, and to linkall the modules as an executable command file.

    The Modify Option

    The Modify option enables you to modify the specification of an existing 4GLprogram. (This option is not valid unless at least one program has alreadybeen specified. If none has, you can create a program specification bychoosing the New option from the same menu.)

    4GL prompts you for the name of the program specification to be modified. Itthen displays a menu and form that you can use to update the information inthe program specification database, as shown in Figure 1-2.

    1-20 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    Figure 1-2Example of a Program Specification Entry

    The name of the program appears in the Program field. In Figure 1-2 thename is myprog. You can change this name by choosing the Rename option.4GL assigns the program name, with the extension .4ge, to the executableprogram produced by compiling and linking all the source files and libraries.(Compiling and linking occurs when you choose the Compile_Optionsoption, as described on page 1-22.) In this example, the resulting executableprogram would have the name myprog.4ge.

    Use the 4GL option to update the entries for the 4gl Source fields and the 4glSource Path fields on the form. The five rows of fields under these labels forma screen array. When you choose the 4GL option, 4GL executes an INPUTARRAY statement so you can move and scroll through the array. See theINPUT ARRAY statement in Chapter 4, INFORMIX-4GL Statements, forinformation about how to use your function keys to scroll, delete rows, andinsert new rows. (You cannot redefine the function keys, however, as you canwith a 4GL program.)

    MODIFY PROGRAM: 4GL Other Libraries Compile_Options Rename ExitEdit the 4GL sources list.

    -------------------------------------------------Press CTRL-W for Help------Program[myprog ]

    4gl Source 4gl Source Path[main ] [/u/john/appl/4GL ][funct ] [/u/john/appl/4GL ][rept ] [/u/john/appl/4GL ][ ] [ ][ ] [ ]

    Other Source Ext Other Source Path[cfunc ] [c ] [/u/john/appl/C ][ ] [ ] [ ][ ] [ ] [ ][ ] [ ] [ ]

    Libraries [m ] Compile Options [ ][ ] [ ]

    Compiling INFORMIX-4GL Source Files 1-21

  • The Programmers Environment

    The 4GL source program that appears in Figure 1-2 contains three modules:

    One module contains the main program (main.4gl).

    One module contains functions (funct.4gl).

    One module contains REPORT statements (rept.4gl).

    Each module is located in the directory /u/john/appl/4GL.

    If your program includes a module containing only global variables (forexample, global.4gl), you must also list that module in this section.

    Use the Other option to include non-4GL source modules or object-codemodules in your program. Enter this information into the three-columnscreen array with the headings Other Source, Ext, and Other Source Path.Enter the filename and location of each non-4GL source-code or object-codemodule in these fields. Enter the name of the module in the Other Sourcefield, the filename extension of the module (for example, ec for anINFORMIX-ESQL/C module, or c for a C module) in the Ext field, and the fulldirectory path of the module in the Other Source Path field. The example inFigure 1-2 includes a file containing C function source-code (cfunc.c) locatedin /u/john/appl/C. You can list up to 100 files in this array.

    The Libraries option enables you to indicate the names of up to ten speciallibraries to link with your program. 4GL calls the C compiler to do the linkingand adds the appropriate -l prefix, so you should enter only what follows theprefix. The example displayed in Figure 1-2 calls only the standard C mathlibrary.

    Use the Compile_Options option to indicate up to ten C compiler options.Enter this information in the Compile Options field. Do not, however,specify the -e or -a options of c4gl in this field, because they will cause thecompilation to fail. (See Creating Programs at the Command Line onpage 1-32 for more information about the options of the c4gl command.)

    The Exit option exits from the MODIFY PROGRAM menu and displays thePROGRAM design menu.

    1-22 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The New Option

    Use the New option on the PROGRAM design menu to create a newspecification of the program modules and libraries that make up anapplication program. You can also specify any necessary compiler or loaderoptions.

    The submenu screen forms displayed by the New and the Modify options ofthe PROGRAM design menu are identical, except that you must first supplya name for your program when you choose the New option. (4GL displays ablank form in the NEW PROGRAM menu.) The NEW PROGRAM menu hasthe same options as the MODIFY PROGRAM menu, as illustrated earlier.

    The Compile Option

    The Compile option performs the compilation and linking described in theprogram specification database, taking into account the time when each filewas last updated. It compiles only those files that have not been compiledsince they were last modified.

    4GL lists each step of the preprocessing and compilation as it occurs. Anexample of these messages appears in the illustration of thePlanned_Compile option, next.

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitAdd the compilation definition of a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitCompile a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-23

  • The Programmers Environment

    The Planned_Compile Option

    Taking into account the time when the various files in the dependencyrelationships last changed, the Planned_Compile option prompts for aprogram name and displays a summary of the steps that will be executed ifyou choose the Compile option. No compilation actually takes place.

    In this instance, changes were made to all the components of the 4GLprogram that were listed in Figure 1-2. This display indicates that nosource-code module has been compiled after the program was changed.

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitShow the planned compile actions of a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------Compiling INFORMIX-4GL sources:

    /u/john/appl/4GL/main.4gl/u/john/appl/4GL/funct.4gl/u/john/appl/4GL/rept.4gl

    Compiling Embedded SQL sources:Compiling with options:Linking with libraries:

    mCompiling/Linking other sources:

    /u/john/appl/C/cfunc.c

    1-24 INFORMIX-4GL Reference Manual

  • The Programmers Environment

    The Run Option

    The Run option of the PROGRAM design menu is the same as the Run optionof the MODULE design menu. It displays a list of any compiled programs(files with the extension .4ge) and highlights the current program, if aprogram has been specified. 4GL then executes the program that you choose.

    The Drop Option

    The Drop option of the PROGRAM design menu prompts you for a programname and removes the compilation and linking definition of that programfrom the syspgm4gl database. This action removes the definition only. Yourprogram and 4GL modules are not removed.

    The Exit Option

    The Exit option clears the PROGRAM design menu and restores theINFORMIX-4GL menu.

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitExecute a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------

    PROGRAM: Modify New Compile Planned_Compile Run Drop ExitDrop the compilation definition of a 4GL application program.

    -------------------------------------------------Press CTRL-W for Help------

    Compiling INFORMIX-4GL Source Files 1-25

  • Creating Programs in the Programmers Environment

    The QUERY LANGUAGE Menu

    The SQL interactive interface is identical to the interactive SQL interface ofINFORMIX-SQL. If you do not have INFORMIX-SQL, 4GL uses the DB-Accessutility. The Query-language option is placed at the top-level menu so you cantest SQL statements without leaving the 4GL Programmers Environment.You can also use this option to create, execute, and save SQL scripts.

    Creating Programs in the Programmers EnvironmentTo invoke the C Compiler version of the Programmers Environment, enterthe following command at the system prompt:

    i4gl

    After a sign-on message is displayed, the INFORMIX-4GL menu appears.

    To create a 4GL application with the C Compiler version of 4GL

    1. Create a new source module or revising an existing source module

    2. Compile the source module

    3. Link the program modules

    4. Execute the compiled program

    This process is described in the sections that follow.

    1-26 INFORMIX-4GL Reference Manual

  • Creating Programs in the Programmers Environment

    Creating a New Source Module

    This section outlines the procedure for creating a new source module. If yoursource module already exists, see Revising an Existing Module, next.

    To create a source module

    1. Choose the Module option of the INFORMIX-4GL menu.

    The MODULE design menu is displayed.

    2. If you are creating a new .4gl source module, choose the New optionof the MODULE design menu.

    3. Enter a name for the new module.

    The name must begin with a letter and can include letters, numbers,and underscores. No more than 10 characters are allowed in thisname, which must be unique among the files in the same directory,and among any other modules of the same program. 4GL attaches theextension .4gl to this filename of your new module.

    4. Press RETURN.

    Revising an Existing Module

    If you are revising an existing 4GL source file, use the following procedure.

    To modify a source file

    1. Choose the Modify option of the MODULE design menu.

    The screen lists the names of all the .4gl source modules in thecurrent directory and prompts you to choose a source file to edit.

    2. Use the arrow keys to highlight the name of a source module andpress RETURN, or enter a filename (with no extension).

    If you specified the name of an editor with the DBEDIT environmentvariable, an editing session with that editor begins automatically.Otherwise, the screen prompts you to specify a text editor.

    Specify a text editor, or press RETURN for vi, the default editor. Nowyou can begin an editing session by entering 4GL statements.

    3. When you have finished entering or editing your 4GL code, use anappropriate editor command to save your source file and end the textediting session.

    Compiling INFORMIX-4GL Source Files 1-27

  • Creating Programs in the Programmers Environment

    Compiling a Source Module

    The .4gl source file module that you create or modify is an ASCII file that mustbe compiled before it can be executed.

    To compile a module

    1. Choose the Compile option from the MODULE design menu.

    2. Choose the type of module that you are compiling, either Runable orObject.

    If the module is a complete 4GL program that requires no othermodules, choose Runable.

    If the module is one module of a multi-module 4GL program, chooseObject. This option creates a compiled object file module, with thesame filename, but with extension .o. See also the next section,Linking Program Modules.

    3. If the compiler detects errors, no compiled file is created, and you areprompted to fix the problem.

    Choose Correct to resume the previous text editing session, with thesame 4GL source code, but with error messages in the file. Edit the fileto correct the error, and choos