Transcription of INFORMIX-4GL by Example
1 INFORMIX- 4 GLby ExampleVersion 1999 Part No. 000-5451iiINFORMIX-4GL by ExamplePublished byINFORMIX PressInformix 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 ;ClientSDKTM; 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.
2 If you can imagine it, you can manage itSM; Illustra ;INFORMIX ;Informix Data Warehouse Turning Data Into Business AdvantageTM;INFORMIX -EnterpriseGateway withDRDA ; 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.
3 The DataBlade logo isregistered with the United States Patent and Trademark Team: Elaina Von Haas, Adam Barnett, Mary Leigh Burke, Mary Kraemer, Eileen WollamGOVERNMENT LICENSE RIGHTSS oftware 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 ;(2) if for Dept. of Defense use, with rights as restricted by vendor s standard license, unless superseded by anegotiated vendor license, as prescribed in DFARS Any whole or partial reproduction of software ordocumentation marked with this legend must reproduce this ExampleIntroduction 15 About This Manual 15 Summary of Chapters 16 How to Use This Manual 18 How to Use The Examples 18 Typographical Conventions 19 The Demonstration Database and Application Files 19 Creating the Demo Database on Informix Dynamic Server 20 Creating the Demo Database on INFORMIX-SE 21 Copying the Example Files 22 Running an Example 22 Files Used in Each Example 24 Naming Conventions 25 Using the Examples with Prior Releases 25 Additional
4 Documentation 26 Documentation Included with 4GL 26On-Line Manuals 27On-Line Help 27On-Line Error Messages 27 Related Reading 28 Informix Welcomes Your Comments 28 Example 1 Writing a Simple 4GL Program 31 Displaying Information Using a Form 32 The MAIN Function 32 The DISPLAY Statements 33 Function Overview 33 The f_logo Form Specification 34 The MAIN Function 36 The dsply_logo() Function 364 Table of ContentsExample 2 Displaying a Message Window 43 Defining Global Variables 44 The MAIN Function 44 Displaying Messages in a Window 44 Function Overview 45 The GLOBALS Statement and MAIN Function 46 The message_window() Function 48 The init_msgs() Function 52 Example 3 Populating a Ring Menu with Options 55 Opening a Menu 55 Demonstrating the Choice of a Menu Option 56 Executing a Command Supplied by the User 56 Function Overview 56 The MAIN Function 58 The dsply_option() Function 62 The bang()
5 Function 64 The hlpmsgs Message File 66 Example 4 Displaying a Row on a Form 69 Defining Records 70 Returning Values from Functions 70 Entering Information on a Form 71 Selecting Database Information 71 Recovering from Runtime Errors 72 Function Overview 73 The f_custkey and f_custsum Forms 74 The DATABASE and GLOBALS Statements 76 The MAIN Function 76 The cust_summary() Function 78 The get_custnum() Function 80 The get_summary() Function 84 The dsply_summary() Function 86 The tax_rates() Function 88 The prompt_window() Function 88 Example 5 Programming a Query by Example 95 Constructing Criteria from the User s Entry 96 Executing an SQL Query Dynamically 97 Accessing Multiple Rows with Cursors 97 Handling User Interrupts 98 Utility Functions 100 Function Overview 100 Table of Contents5 The f_customer Form 102 The GLOBALS Statement and MAIN Function 104 The query_cust1() Function 106 The answer_yes() Function 114 The msg()
6 Function 114 Example 6 Querying and Updating117 Modifying the Rows Qualified by a Query 117 Checking for Dependent Rows 118 Function Overview 118 The GLOBALS Statement and MAIN Function 120 The query_cust2() Function 120 The browse_custs Function 124 The next_action() Function 126 The change_cust() Function 128 The update_cust() Function 130 The delete_cust() Function 130 The verify_delete() Function 132 The clear_lines() Function 134 Example 7 Validating and Inserting a Row 137 Validating Data Entry 137 Retrieving Information from Multiple Tables 138 Function Overview 138 The f_stock Form 140 The GLOBALS Statement 142 The MAIN Function 142 The input_stock() Function 144 The unique_stock() Function 146 The insert_stock() Function 148 Example 8 Displaying a Screen Array in a Popup Window151 Displaying Information in an Array Form 152 Triggering Form Actions with Keys 153 Function Overview 153 The f_manufsel Form 154 The input_stock2() Function 156 The manuf_popup()
7 Function 1586 Table of ContentsExample 9 Accessing a Table with a Single-Row Form 165 Function Overview 166 The f_statesel Form 168 The MAIN Function 170 The cust_menu1() Function 170 The browse_custs1() Function 172 The next_action2() Function 172 The addupd_cust() Function 174 The state_popup() Function 180 The insert_cust() Function 182 Example 10 Accessing a Table with a Multi-Row Form 185 Modifying Information in an Array Form 186 Handling Empty Fields 186 Identifying Keystrokes 187 Function Overview 189 The f_manuf Form 190 The DATABASE and GLOBALS Statements 192 The MAIN Function 192 The dsply_manuf() Function 194 The valid_null() Function 204 The reshuffle() Function 206 The verify_mdel() Function 208 The choose_op() Function 210 The insert_manuf() Function 210 The update_manuf() Function 212 The delete_manuf() Function 212 The verify_rowid() Function 214 The save_rowid()
8 Function 214 Example 11 Implementing a Master-Detail Relationship 217 Program Overview 217 Function Overview 222 The f_orders Form 224 The f_custsel Form 226 The f_stocksel Form 226 The f_ship Form 228 The DATABASE and GLOBALS Statements 230 The MAIN Function 232 The add_order() Function 232 The input_cust() Function 234 The cust_popup() Function 238 The input_order() Function 240 The input_items() Function 242 Table of Contents7 The renum_items() Function 248 The stock_popup() Function 250 The dsply_taxes() Function 252 The order_amount() Function 254 The ship_order() Function 254 The input_ship() Function 256 The order_tx() Function 258 The insert_order() Function 260 The insert_items() Function 260 Example 12 Displaying an Unknown Number of Rows 263 Paging Through Rows Using Array Form 264 Function Overview 265 The f_ordersel File 266 The GLOBALS Statement 268 The MAIN Function 268 The find_order() Function 270 The cust_popup2() Function 276 The order_popup() Function 282 The calc_order() Function 288 The upd_order()
9 Function 288 Example 13 Calling a C Function 291 The Interface Between C and 4GL 291 The Argument Stack 291 Passing Arguments to a C Function 292 Returning Values from a C Function 292 The Module 293 Using fglgets() 293 The Design of fglgets() 294 Returning Both a Value and a Code 294 Handling Arguments 296 Running the Example 297 Creating the Executable Files 298 Calling the Executable File 299C Module Overview 300 Function Overview 301 The f_name Form 302 The MAIN Function 304 The fdump() Function 3068 Table of ContentsThe Module 308 The Module 310 The getquote() Function 312 The fglgetret() Function 312 The fglgets() Function 314 Example 14 Generating a Report 319 The Program Model 320 Steps in Generating a Report 320 Basic Parts of a Report 321 Directing a Report to the Screen 323 Function Overview 323 The MAIN Function 324 The manuf_listing() Function 324 The manuf_rpt() Report Function 326 Example 15 Reporting Group Totals329 Choosing a Report Destination 329 The Report Contents 331 Function Overview 332 The DATABASE and GLOBALS Statements 334 The MAIN Function 334 The add_order2() Function 336 The invoice()
10 Function 338 The report_output() Function 340 The invoice_rpt() Report Function 342 Example 16 Creating Vertical Menus 351A Hard-Coded Vertical Menu Example 16a 352A Generic Vertical Menu Example 16b 353 Example 16a: The f_menu Form 356 The DATABASE and GLOBALS Statements 358 The MAIN Function 358 The main_menu() Function 358 The cust_maint() Function 360 The Remaining maint() Functions 360 Example 16b: The f_menu2 Form 362 The DATABASE and GLOBALS Stat