EGL Language Reference - IBM · iv EGL Language Reference. Error conditions .....249 ... #dli...

1056
Rational Business Developer EGL Language Reference Version 7 Release 5.1

Transcript of EGL Language Reference - IBM · iv EGL Language Reference. Error conditions .....249 ... #dli...

  • Rational Business Developer

    EGL Language ReferenceVersion 7 Release 5.1

  • Rational Business Developer

    EGL Language ReferenceVersion 7 Release 5.1

  • NoteBefore using this information and the product it supports, read the information in Notices, on page 1025.

    This edition applies to version 7.5.1 of Rational Business Developer and to all subsequent releases and modificationsuntil otherwise indicated in new editions.

    Copyright International Business Machines Corporation 1996, 2008.US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

  • Contents

    General syntax. . . . . . . . . . . . 1Expressions and operators . . . . . . . . . . 2

    Special characters . . . . . . . . . . . . 2Operators and precedence . . . . . . . . . 3Expression types . . . . . . . . . . . . 6Logical expressions . . . . . . . . . . . 7@ operator . . . . . . . . . . . . . . 9as operator . . . . . . . . . . . . . 10Concatenation operators . . . . . . . . . 11in operator . . . . . . . . . . . . . 11is/not operator . . . . . . . . . . . . 13isa operator . . . . . . . . . . . . . 14like operator . . . . . . . . . . . . . 15matches operator . . . . . . . . . . . 16new operator . . . . . . . . . . . . . 18

    Scope . . . . . . . . . . . . . . . . 20Parts. . . . . . . . . . . . . . . . 20Types . . . . . . . . . . . . . . . 21Qualifiers . . . . . . . . . . . . . . 21Name resolution in an expression . . . . . . 22The this keyword . . . . . . . . . . . 23Namespace . . . . . . . . . . . . . 24Naming conventions . . . . . . . . . . 24EGL projects, packages, and files . . . . . . 25package . . . . . . . . . . . . . . 26import . . . . . . . . . . . . . . . 27use . . . . . . . . . . . . . . . . 28private and public . . . . . . . . . . . 29EGL part resolution rules . . . . . . . . . 30

    Variables . . . . . . . . . . . . . . . 31Declaring variables and constants . . . . . . 31Literals . . . . . . . . . . . . . . . 34Data initialization . . . . . . . . . . . 35Reference variables . . . . . . . . . . . 38Records. . . . . . . . . . . . . . . 39Arrays . . . . . . . . . . . . . . . 44Dynamic array properties. . . . . . . . . 50Dynamic array functions . . . . . . . . . 50

    Specializing parts with properties and stereotypes 53Properties . . . . . . . . . . . . . . 53Enumerations. . . . . . . . . . . . . 56Field-level properties . . . . . . . . . . 57redefines . . . . . . . . . . . . . . 57Specializing primitive types as DataItem parts . . 61Stereotypes . . . . . . . . . . . . . 62The Exception stereotype . . . . . . . . . 63

    System data parts . . . . . . . . . . 65Primitive data types . . . . . . . . . . . 66

    Character types . . . . . . . . . . . . 66Date/time types . . . . . . . . . . . . 68Large object types . . . . . . . . . . . 69Numeric types . . . . . . . . . . . . 69Logical types . . . . . . . . . . . . . 71ANY type . . . . . . . . . . . . . . 71

    Substrings . . . . . . . . . . . . . . . 72Syntax . . . . . . . . . . . . . . . 72Examples . . . . . . . . . . . . . . 73

    Date/time masks and format specifiers . . . . . 73Creating an INTERVAL mask . . . . . . . 74Creating a TIMESTAMP mask . . . . . . . 74Creating a display or parsing format . . . . . 75Calendar specifiers . . . . . . . . . . . 78Compatibility. . . . . . . . . . . . . 79

    Date and time expressions . . . . . . . . . 80Using INTERVAL variables . . . . . . . . 80

    Loose types . . . . . . . . . . . . . . 81Null values and the nullable type . . . . . . . 82

    Examples . . . . . . . . . . . . . . 83Dictionary part . . . . . . . . . . . . . 83Dictionary properties . . . . . . . . . . . 85

    Compatibility. . . . . . . . . . . . . 86Dictionary functions . . . . . . . . . . . 87

    containsKey() . . . . . . . . . . . . . 87getKeys() . . . . . . . . . . . . . . 88getValues() . . . . . . . . . . . . . 88insertAll() . . . . . . . . . . . . . . 88removeAll() . . . . . . . . . . . . . 89removeElement() . . . . . . . . . . . 89size() . . . . . . . . . . . . . . . 89

    ArrayDictionary . . . . . . . . . . . . . 90Dynamic types and dynamic access . . . . . . 91

    Example . . . . . . . . . . . . . . 92

    User-defined data parts . . . . . . . 93DataItem part . . . . . . . . . . . . . 93

    Syntax . . . . . . . . . . . . . . . 94Example . . . . . . . . . . . . . . 94DataItem properties . . . . . . . . . . 95

    Record part . . . . . . . . . . . . . . 95Syntax . . . . . . . . . . . . . . . 95Example . . . . . . . . . . . . . . 96BasicRecord stereotype . . . . . . . . . 96

    DataTable part . . . . . . . . . . . . . 98Syntax . . . . . . . . . . . . . . . 98DataTable stereotypes . . . . . . . . . . 99Using the data table . . . . . . . . . . 99Examples . . . . . . . . . . . . . . 99Compatibility . . . . . . . . . . . . 101DataTable properties . . . . . . . . . . 101use considerations for DataTable parts . . . . 104

    Logic parts . . . . . . . . . . . . 107Functions. . . . . . . . . . . . . . . 108

    Syntax. . . . . . . . . . . . . . . 108Example . . . . . . . . . . . . . . 109Parameter modifiers . . . . . . . . . . 109Return type . . . . . . . . . . . . . 111Overloaded functions . . . . . . . . . . 111Function prototypes . . . . . . . . . . 112

    Copyright IBM Corp. 1996, 2008 iii

  • Program part . . . . . . . . . . . . . 113Syntax . . . . . . . . . . . . . . . 113Main versus called programs . . . . . . . 114Compatibility . . . . . . . . . . . . 114Program properties . . . . . . . . . . 115

    Library part . . . . . . . . . . . . . . 120Syntax. . . . . . . . . . . . . . . 121Compatibility . . . . . . . . . . . . 121Library properties . . . . . . . . . . . 122

    Service part . . . . . . . . . . . . . . 124Service properties . . . . . . . . . . . 125

    Interface part . . . . . . . . . . . . . 128Interface properties . . . . . . . . . . 129

    ExternalType part . . . . . . . . . . . . 129External type for Java code . . . . . . . . 131External type for JavaScript code . . . . . . 133Accessing IBM i programs as Web services . . 139

    Delegate part . . . . . . . . . . . . . 142Syntax. . . . . . . . . . . . . . . 143Example . . . . . . . . . . . . . . 143Compatibility . . . . . . . . . . . . 143

    Standalone function part . . . . . . . . . 144Example . . . . . . . . . . . . . . 144Compatibility . . . . . . . . . . . . 144containerContextDependent . . . . . . . 145

    EGL statements . . . . . . . . . . 147Comments . . . . . . . . . . . . . . 148Data movement . . . . . . . . . . . . 148

    move . . . . . . . . . . . . . . . 149set . . . . . . . . . . . . . . . . 154Assignments. . . . . . . . . . . . . 155Assignment compatibility in EGL. . . . . . 157Converting text to date/time types . . . . . 164Converting date/time types to text . . . . . 165Reference compatibility in EGL . . . . . . 167Set-value blocks . . . . . . . . . . . 167

    Conditional and loop statements . . . . . . . 173case . . . . . . . . . . . . . . . 174continue . . . . . . . . . . . . . . 176exit . . . . . . . . . . . . . . . . 177for . . . . . . . . . . . . . . . . 179forEach . . . . . . . . . . . . . . 181if, else . . . . . . . . . . . . . . . 181while . . . . . . . . . . . . . . . 182

    Transfer of control within a program . . . . . 183Calling a function . . . . . . . . . . . 183goTo . . . . . . . . . . . . . . . 184return . . . . . . . . . . . . . . . 184

    Transfer of control across programs . . . . . . 185Transfer of control statement properties . . . 186Run unit . . . . . . . . . . . . . . 187Using linkage options parts in a call or transfer 189call . . . . . . . . . . . . . . . . 190forward . . . . . . . . . . . . . . 194transfer . . . . . . . . . . . . . . 194

    Exception handling . . . . . . . . . . . 197System exceptions . . . . . . . . . . . 198try . . . . . . . . . . . . . . . . 199throw . . . . . . . . . . . . . . . 200Using V6 exception compatibility. . . . . . 201

    I/O error values . . . . . . . . . . . 202

    EGL core system libraries andvariables . . . . . . . . . . . . . 207EGL library dateTimeLib . . . . . . . . . 207

    currentDate() . . . . . . . . . . . . 209currentTime() . . . . . . . . . . . . 209currentTimeStamp() . . . . . . . . . . 210dateOf() . . . . . . . . . . . . . . 211dateValue() . . . . . . . . . . . . . 211dateValueFromGregorian() . . . . . . . . 211dateValueFromJulian() . . . . . . . . . 212dayOf() . . . . . . . . . . . . . . 212extend() . . . . . . . . . . . . . . 213intervalValue() . . . . . . . . . . . . 213intervalValueWithPattern() . . . . . . . . 214mdy() . . . . . . . . . . . . . . . 215monthOf() . . . . . . . . . . . . . 216timeOf() . . . . . . . . . . . . . . 216timestampFrom() . . . . . . . . . . . 217timestampValue() . . . . . . . . . . . 217timestampValueWithPattern() . . . . . . . 218timeValue() . . . . . . . . . . . . . 218weekdayOf() . . . . . . . . . . . . 219yearOf() . . . . . . . . . . . . . . 219

    EGL library javaLib . . . . . . . . . . . 220Compatibility . . . . . . . . . . . . 220Java access functions . . . . . . . . . . 220getField() . . . . . . . . . . . . . . 225invoke() . . . . . . . . . . . . . . 227isNull() . . . . . . . . . . . . . . 229isObjID() . . . . . . . . . . . . . . 230qualifiedTypeName() . . . . . . . . . . 231remove() . . . . . . . . . . . . . . 232removeAll() . . . . . . . . . . . . . 233setField() . . . . . . . . . . . . . . 233store() . . . . . . . . . . . . . . . 235storeCopy() . . . . . . . . . . . . . 237storeField() . . . . . . . . . . . . . 238storeNew() . . . . . . . . . . . . . 239

    EGL library lobLib . . . . . . . . . . . 241Compatibility . . . . . . . . . . . . 242attachBlobToFile() . . . . . . . . . . . 242attachBlobToTempFile() . . . . . . . . . 242attachClobToFile() . . . . . . . . . . . 243attachClobToTempFile() . . . . . . . . . 243freeBlob(). . . . . . . . . . . . . . 244freeClob() . . . . . . . . . . . . . 244getBlobLen(). . . . . . . . . . . . . 244getClobLen() . . . . . . . . . . . . 245getStrFromClob() . . . . . . . . . . . 245getSubstrFromClob() . . . . . . . . . . 245loadBlobFromFile() . . . . . . . . . . 246loadClobFromFile() . . . . . . . . . . 246setClobFromString() . . . . . . . . . . 247setClobFromStringAtPosition(). . . . . . . 247truncateBlob() . . . . . . . . . . . . 247truncateClob() . . . . . . . . . . . . 248updateBlobToFile() . . . . . . . . . . 248updateClobToFile() . . . . . . . . . . 248

    EGL library mathLib . . . . . . . . . . . 249

    iv EGL Language Reference

  • Error conditions . . . . . . . . . . . 249Functions. . . . . . . . . . . . . . 249abs() . . . . . . . . . . . . . . . 251acos() . . . . . . . . . . . . . . . 251asin() . . . . . . . . . . . . . . . 252assign() . . . . . . . . . . . . . . 252atan() . . . . . . . . . . . . . . . 253atan2(). . . . . . . . . . . . . . . 253ceiling() . . . . . . . . . . . . . . 254cos() . . . . . . . . . . . . . . . 254cosh() . . . . . . . . . . . . . . . 255decimals() . . . . . . . . . . . . . 255exp() . . . . . . . . . . . . . . . 256floor() . . . . . . . . . . . . . . . 256frexp() . . . . . . . . . . . . . . . 257ldexp() . . . . . . . . . . . . . . 257log() . . . . . . . . . . . . . . . 258log10(). . . . . . . . . . . . . . . 258max() . . . . . . . . . . . . . . . 259min() . . . . . . . . . . . . . . . 259modf(). . . . . . . . . . . . . . . 260pow() . . . . . . . . . . . . . . . 261precision() . . . . . . . . . . . . . 262round() . . . . . . . . . . . . . . 262sin() . . . . . . . . . . . . . . . 263sinh() . . . . . . . . . . . . . . . 264sqrt() . . . . . . . . . . . . . . . 264tan() . . . . . . . . . . . . . . . 265tanh() . . . . . . . . . . . . . . . 265

    EGL library serviceLib . . . . . . . . . . 265bindService() . . . . . . . . . . . . 267convertFromJSON() . . . . . . . . . . 267convertFromURLEncoded() . . . . . . . . 268convertToJSON() . . . . . . . . . . . 268convertToURLEncoded(). . . . . . . . . 268endStatefulServiceSession . . . . . . . . 269getCurrentCallbackResponse . . . . . . . 269getOriginalRequest . . . . . . . . . . 270getRestRequestHeaders() . . . . . . . . 271getRestServiceLocation() . . . . . . . . . 271getTCPIPLocation() . . . . . . . . . . 272getWebServiceLocation() . . . . . . . . . 272setHTTPBasicAuthentication() . . . . . . . 273setProxyBasicAuthentication() . . . . . . . 273setRestRequestHeaders(). . . . . . . . . 274setRestServiceLocation() . . . . . . . . . 275setTCPIPLocation() . . . . . . . . . . 275setWebServiceLocation() . . . . . . . . . 276

    EGL library strLib . . . . . . . . . . . . 276Variables . . . . . . . . . . . . . . 277Constants . . . . . . . . . . . . . 278Compatibility . . . . . . . . . . . . 278Default formats in COBOL . . . . . . . . 278booleanAsString() . . . . . . . . . . . 279byteLen() . . . . . . . . . . . . . . 279characterLen() . . . . . . . . . . . . 280charAsInt() . . . . . . . . . . . . . 280clip() . . . . . . . . . . . . . . . 281defaultDateFormat (EGL system variable) . . . 282defaultMoneyFormat (EGL system variable) . . 283defaultNumericFormat (EGL system variable) 284

    defaultTimeFormat (EGL system variable) . . . 284defaultTimestampFormat (EGL system variable) 285formatDate(). . . . . . . . . . . . . 286formatNumber() . . . . . . . . . . . 287formatTime() . . . . . . . . . . . . 288formatTimestamp() . . . . . . . . . . 289getNextToken() . . . . . . . . . . . . 290getTokenCount() . . . . . . . . . . . 292indexOf() . . . . . . . . . . . . . . 293intAsChar() . . . . . . . . . . . . . 294intAsUnicode() . . . . . . . . . . . . 295lowerCase() . . . . . . . . . . . . . 295setBlankTerminator() . . . . . . . . . . 296setNullTerminator() . . . . . . . . . . 296spaces() . . . . . . . . . . . . . . 297unicodeAsInt() . . . . . . . . . . . . 297upperCase() . . . . . . . . . . . . . 298

    EGL library sysLib . . . . . . . . . . . 299audit(). . . . . . . . . . . . . . . 301bytes(). . . . . . . . . . . . . . . 303calculateChkDigitMod10() . . . . . . . . 304calculateChkDigitMod11() . . . . . . . . 305callCmd(). . . . . . . . . . . . . . 306commit() . . . . . . . . . . . . . . 307conditionAsInt() . . . . . . . . . . . 309convert() . . . . . . . . . . . . . . 310convertBidi(). . . . . . . . . . . . . 311convertNumberToUnicodeNum() . . . . . . 312convertNumberToUnsignedUnicodeNum() . . 313convertUnicodeNumToNumber() . . . . . . 315convertUnsignedUnicodeNumToNumber() . . 316currentException (EGL system variable) . . . 318errorLog() . . . . . . . . . . . . . 321getCmdLineArg() . . . . . . . . . . . 321getCmdLineArgCount() . . . . . . . . . 322getMessage() . . . . . . . . . . . . 323getProperty() . . . . . . . . . . . . 324maximumSize(). . . . . . . . . . . . 325purge() . . . . . . . . . . . . . . 326rollback() . . . . . . . . . . . . . . 326setError() . . . . . . . . . . . . . . 328setErrorForComponentID() . . . . . . . . 329setLocale() . . . . . . . . . . . . . 331setRemoteUser() . . . . . . . . . . . 332size() . . . . . . . . . . . . . . . 333startCmd() . . . . . . . . . . . . . 334startLog(). . . . . . . . . . . . . . 335verifyChkDigitMod10() . . . . . . . . . 335verifyChkDigitMod11() . . . . . . . . . 336wait() . . . . . . . . . . . . . . . 337writeStdErr() . . . . . . . . . . . . 338writeStdout() . . . . . . . . . . . . 339

    sysVar system variable (core fields) . . . . . . 340arrayIndex . . . . . . . . . . . . . 342callConversionTable . . . . . . . . . . 342errorCode . . . . . . . . . . . . . 344formConversionTable . . . . . . . . . . 347overflowIndicator . . . . . . . . . . . 347remoteSystemID . . . . . . . . . . . 348returnCode . . . . . . . . . . . . . 350sessionID . . . . . . . . . . . . . . 352

    Contents v

  • sysVar.sqlData . . . . . . . . . . . . 353systemType . . . . . . . . . . . . . 354terminalID . . . . . . . . . . . . . 355transactionID . . . . . . . . . . . . 356transferName . . . . . . . . . . . . 357userID. . . . . . . . . . . . . . . 358

    Accessing data in EGL . . . . . . . 361resourceAssociation variable for file I/O . . . . 361

    Definition considerations . . . . . . . . 362Compatibility . . . . . . . . . . . . 364Example . . . . . . . . . . . . . . 366

    Logical unit of work . . . . . . . . . . . 366Compatibility . . . . . . . . . . . . 368

    Data access statements . . . . . . . . . . 370add. . . . . . . . . . . . . . . . 371close . . . . . . . . . . . . . . . 372delete . . . . . . . . . . . . . . . 372execute . . . . . . . . . . . . . . 373get . . . . . . . . . . . . . . . . 373open . . . . . . . . . . . . . . . 374prepare . . . . . . . . . . . . . . 375replace . . . . . . . . . . . . . . 375

    Data access technologies. . . . . . . . . . 377SQL data access . . . . . . . . . . . . 377

    Typical SQL processing . . . . . . . . . 377Implicit SQL statements . . . . . . . . . 378Embedded SQL statements . . . . . . . . 379Dynamic SQL . . . . . . . . . . . . 379Host variables . . . . . . . . . . . . 380SQLRecord stereotype . . . . . . . . . 380Logical expressions for SQL records . . . . . 382SQLRecord field level properties . . . . . . 383Exception record for SQL . . . . . . . . 388sqlNullable . . . . . . . . . . . . . 388#sql directive . . . . . . . . . . . . 389#sqlCondition directive . . . . . . . . . 389add considerations for SQL. . . . . . . . 390close considerations for SQL . . . . . . . 392delete considerations for SQL . . . . . . . 393execute considerations for SQL . . . . . . 394forEach considerations for SQL . . . . . . 399freeSQL . . . . . . . . . . . . . . 400get considerations for SQL . . . . . . . . 401open considerations for SQL . . . . . . . 407prepare considerations for SQL . . . . . . 412replace considerations for SQL . . . . . . 414set considerations for SQL . . . . . . . . 416EGL library sqlLib. . . . . . . . . . . 417Additional properties for programs using anSQL database . . . . . . . . . . . . 433Sample EGL SQL program . . . . . . . . 434

    Data access using PSBs and PCBs . . . . . . 437Requirements for the PSB record definition . . 437When callInterface is AIBTDLI . . . . . . 438When callInterface is CBLTDLI . . . . . . 438Compatibility . . . . . . . . . . . . 439PSBRecord stereotype . . . . . . . . . 442PSBRecord properties. . . . . . . . . . 442PCB record stereotypes . . . . . . . . . 443Additional properties for PCB records . . . . 445

    PSB scheduling for CICS environments . . . . 448PSB scheduling for non-CICS environments . . 452

    DL/I database support . . . . . . . . . . 453Typical DL/I processing . . . . . . . . . 454DLISegment stereotype . . . . . . . . . 454DLISegment properties . . . . . . . . . 455Exception record for DL/I . . . . . . . . 457#dli directive . . . . . . . . . . . . 457add considerations for DL/I . . . . . . . 458delete considerations for DL/I. . . . . . . 460get considerations for DL/I. . . . . . . . 462replace . . . . . . . . . . . . . . 465Additional properties for programs using aDL/I database . . . . . . . . . . . . 467EGL library dliLib . . . . . . . . . . . 470dliVar system variable . . . . . . . . . 473

    File I/O . . . . . . . . . . . . . . . 479VSAM file access . . . . . . . . . . . 479IndexedRecord stereotype . . . . . . . . 480RelativeRecord stereotype . . . . . . . . 484SerialRecord stereotype . . . . . . . . . 485CSVRecord stereotype . . . . . . . . . 486add considerations for file I/O . . . . . . 489close considerations for file I/O . . . . . . 491delete considerations for VSAM . . . . . . 492get considerations for file I/O . . . . . . . 492replace considerations for file I/O . . . . . 498set considerations for file I/O . . . . . . . 499

    GSAM and IMS message queue access . . . . . 500Using serial files as GSAM files . . . . . . 501Using serial files as IMS message queues . . . 501Checking the results of serial file I/O statements 501SerialRecord for GSAM and IMS message queueaccess . . . . . . . . . . . . . . . 502add considerations for GSAM and IMS messagequeues . . . . . . . . . . . . . . 502close considerations for GSAM and IMSmessage queues . . . . . . . . . . . 503get considerations for GSAM and IMS messagequeues . . . . . . . . . . . . . . 503

    MQ message queue access . . . . . . . . . 504Connections . . . . . . . . . . . . . 505Include message in transaction . . . . . . 505Customization . . . . . . . . . . . . 506Features supported only for COBOL. . . . . 507MQRecord stereotype . . . . . . . . . 507MQRecord properties. . . . . . . . . . 508Options records for MQRecords . . . . . . 514add considerations for MQ message queues . . 515close considerations for MQ message queues 516get next considerations for MQ message queues 516Exception record for MQ message queues . . . 516

    iSeries object access . . . . . . . . . . . 517iSeries Record definitions . . . . . . . . 517iSeries function calls . . . . . . . . . . 518

    Creating applications with userinterfaces . . . . . . . . . . . . . 525Enumerations for user interface properties andfields . . . . . . . . . . . . . . . . 526Common UI statements . . . . . . . . . . 527

    vi EGL Language Reference

  • converse . . . . . . . . . . . . . . 528show . . . . . . . . . . . . . . . 528Behavior of a segmented program on CICS orIMS . . . . . . . . . . . . . . . 529

    Common UI properties . . . . . . . . . . 530addSpaceForSOSI . . . . . . . . . . . 530align . . . . . . . . . . . . . . . 531bypassValidation . . . . . . . . . . . 531color . . . . . . . . . . . . . . . 532columns . . . . . . . . . . . . . . 533dateFormat . . . . . . . . . . . . . 533displayName . . . . . . . . . . . . 535fieldLen . . . . . . . . . . . . . . 536formSize . . . . . . . . . . . . . . 536help . . . . . . . . . . . . . . . 537helpForm. . . . . . . . . . . . . . 537helpKey . . . . . . . . . . . . . . 538highlight . . . . . . . . . . . . . . 539indexOrientation . . . . . . . . . . . 540initialized . . . . . . . . . . . . . 540inputRequired . . . . . . . . . . . . 541inputRequiredMsgKey . . . . . . . . . 541intensity . . . . . . . . . . . . . . 542labelKey . . . . . . . . . . . . . . 543labelText . . . . . . . . . . . . . . 543lineWrap . . . . . . . . . . . . . . 543linesBetweenRows. . . . . . . . . . . 544lowerCase . . . . . . . . . . . . . 544masked . . . . . . . . . . . . . . 545minimumInput . . . . . . . . . . . . 545minimumInputMsgKey . . . . . . . . . 546msgField . . . . . . . . . . . . . . 546needsSOSI . . . . . . . . . . . . . 547numElementsItem . . . . . . . . . . . 547position . . . . . . . . . . . . . . 548protect . . . . . . . . . . . . . . 548screenSizes . . . . . . . . . . . . . 549spacesBetweenColumns . . . . . . . . . 549timeFormat . . . . . . . . . . . . . 550timestampFormat . . . . . . . . . . . 551title. . . . . . . . . . . . . . . . 552upperCase . . . . . . . . . . . . . 553validationOrder . . . . . . . . . . . 553validValues . . . . . . . . . . . . . 553validValuesMsgKey . . . . . . . . . . 555value . . . . . . . . . . . . . . . 555zeroFormat . . . . . . . . . . . . . 556

    Validation properties . . . . . . . . . . . 557Handler part . . . . . . . . . . . . . 557

    Syntax. . . . . . . . . . . . . . . 557Basic handler properties . . . . . . . . . 558

    Web pages with JavaServer Faces. . . . . . . 558JSF Handler part . . . . . . . . . . . 559Component tree access . . . . . . . . . 562findComponent() . . . . . . . . . . . 563Exception record for JSF . . . . . . . . . 563JSF handler properties . . . . . . . . . 564JSF handler field properties. . . . . . . . 575Enumerations for Web pages with JavaServerFaces . . . . . . . . . . . . . . . 584forward considerations for JSF. . . . . . . 585

    EGL library j2eeLib . . . . . . . . . . 586Rich UI programming model . . . . . . . . 594

    Rich UI handler part . . . . . . . . . . 595Rich UI widgets . . . . . . . . . . . 596Creating a Rich UI application with multiplehandlers . . . . . . . . . . . . . . 608Event handling in Rich UI . . . . . . . . 609Rich UI validation and formatting . . . . . 612Rich UI date and time support . . . . . . 618Form processing with Rich UI . . . . . . . 619Use of properties files for displayable text . . . 620Browser history . . . . . . . . . . . 625Rich UI Infobus . . . . . . . . . . . 628Non-Infobus communication between Rich UIhandlers . . . . . . . . . . . . . . 630Rich UI debugging . . . . . . . . . . 634Rich UI drag and drop . . . . . . . . . 635Overview of service access . . . . . . . . 636External type for JavaScript code . . . . . . 640Extending the Rich UI widget set. . . . . . 646

    Accessing a service in EGL Rich UI . . . . . . 653Accessing a REST service in Rich UI. . . . . 654Accessing a SOAP (Web) service in Rich UI . . 669Copying a JSON string to and from an EGLvariable . . . . . . . . . . . . . . 675Copying an XML string to and from an EGLvariable . . . . . . . . . . . . . . 680ServiceLib entries for Rich UI . . . . . . . 689EGL library XMLLib . . . . . . . . . . 697

    Reference to widgets . . . . . . . . . . . 699Rich UI BidiTextArea . . . . . . . . . . 700Rich UI BidiTextField . . . . . . . . . . 700Rich UI Box . . . . . . . . . . . . . 701Rich UI Button . . . . . . . . . . . . 702Rich UI Checkbox . . . . . . . . . . . 703Rich UI Combo. . . . . . . . . . . . 703Rich UI Div, FloatLeft, and FloatRight . . . . 704Rich UI Grid and GridTooltip . . . . . . . 705Rich UI Grouping . . . . . . . . . . . 709Rich UI HTML . . . . . . . . . . . . 710Rich UI Hyperlink . . . . . . . . . . . 711Rich UI Image . . . . . . . . . . . . 712Rich UI List . . . . . . . . . . . . . 713Rich UI ListMulti . . . . . . . . . . . 714Rich UI Menu . . . . . . . . . . . . 715Rich UI PasswordTextField . . . . . . . . 721Rich UI RadioGroup . . . . . . . . . . 721Rich UI Shadow . . . . . . . . . . . 723Rich UI Span . . . . . . . . . . . . 725Rich UI TextArea . . . . . . . . . . . 726Rich UI TextField . . . . . . . . . . . 727Rich UI TextLabel . . . . . . . . . . . 728Rich UI Tooltip . . . . . . . . . . . . 729Rich UI Tree and TreeTooltip . . . . . . . 731

    EGL portlets. . . . . . . . . . . . . . 733EGL library portalLib. . . . . . . . . . 734Enumerations for portals . . . . . . . . 743

    EGL reports . . . . . . . . . . . . . . 744JasperReports . . . . . . . . . . . . 744BIRT Reports . . . . . . . . . . . . 756EGL text reports . . . . . . . . . . . 789

    Contents vii

  • Text UI . . . . . . . . . . . . . . . 808Program part stereotype for Text UI . . . . . 809Additional program properties for Text UI . . 809Form part . . . . . . . . . . . . . 810Form fields . . . . . . . . . . . . . 815FormGroup part . . . . . . . . . . . 817FormGroup properties . . . . . . . . . 818use considerations for FormGroup parts . . . 823Logical expressions for Text UI forms . . . . 824Segmentation in Text UI programs . . . . . 825EGL statements for Text UI . . . . . . . . 828Form field properties . . . . . . . . . . 835Modified data tag and modified property . . . 855Enumerations for Text UI . . . . . . . . 858EGL library converseLib . . . . . . . . . 859converseVar . . . . . . . . . . . . . 861

    Console UI . . . . . . . . . . . . . . 869Binding variables in Console UI . . . . . . 870Using console UI in line mode . . . . . . 870Compatibility . . . . . . . . . . . . 871Console UI parts . . . . . . . . . . . 871Console UI widgets . . . . . . . . . . 874openUI . . . . . . . . . . . . . . 877openUI properties . . . . . . . . . . . 882Using an array dictionary in Console UI . . . 886PresentationAttributes properties . . . . . . 888Window properties in consoleUI . . . . . . 888Prompt properties in consoleUI . . . . . . 891MenuItem properties in consoleUI . . . . . 892Menu properties in consoleUI . . . . . . . 893ConsoleForm properties . . . . . . . . . 894Console field properties . . . . . . . . . 895Enumerations for Console UI . . . . . . . 906continue considerations for Console UI . . . . 907Set-value block considerations for Console UI 907EGL library consoleLib . . . . . . . . . 908

    Web transaction support in EGL . . . . . . . 945Requirements . . . . . . . . . . . . 946Development process . . . . . . . . . . 946Segmentation in Web transactions . . . . . 947VGUIRecord part . . . . . . . . . . . 947VGWebTransaction part . . . . . . . . . 948VGWebTransaction program properties . . . . 948VGUIRecord properties . . . . . . . . . 950VGUIRecord field properties . . . . . . . 951Enumerations for Web transactions . . . . . 957converse considerations for Web transactions 957show considerations for Web transactions . . . 958sysVar system variable (Web transaction fields) 958

    VisualAge Generator compatibility 961EGL library vgLib . . . . . . . . . . . . 962

    compareBytes() . . . . . . . . . . . . 963compareNum() . . . . . . . . . . . . 964compareStr(). . . . . . . . . . . . . 965

    concatenate() . . . . . . . . . . . . 967concatenateBytes() . . . . . . . . . . . 967concatenateWithSeparator() . . . . . . . . 968connectionService() . . . . . . . . . . 969copyBytes() . . . . . . . . . . . . . 973copyStr() . . . . . . . . . . . . . . 974findStr() . . . . . . . . . . . . . . 975floatingDifference() . . . . . . . . . . 976floatingMod() . . . . . . . . . . . . 977floatingProduct() . . . . . . . . . . . 978floatingQuotient() . . . . . . . . . . . 978floatingSum() . . . . . . . . . . . . 979getVAGSysType() . . . . . . . . . . . 979setSubstr() . . . . . . . . . . . . . 981startTransaction() . . . . . . . . . . . 982

    vgVar system variable . . . . . . . . . . 986currentFormattedGregorianDate . . . . . . 987currentFormattedJulianDate . . . . . . . 988currentFormattedTime . . . . . . . . . 989currentGregorianDate . . . . . . . . . 989currentJulianDate . . . . . . . . . . . 990currentShortGregorianDate . . . . . . . . 991currentShortJulianDate . . . . . . . . . 991handleHardIOErrors . . . . . . . . . . 992handleOverflow . . . . . . . . . . . 992handleSysLibraryErrors . . . . . . . . . 993sqlIsolationLevel . . . . . . . . . . . 994systemGregorianDateFormat . . . . . . . 994systemJulianDateFormat . . . . . . . . . 995

    Appendices . . . . . . . . . . . . 997EGL reserved words . . . . . . . . . . . 997

    Words that are reserved outside of a directive 997Words that are reserved in a #sql directive . . 998SQL reserved words requiring special treatment 999

    Master list of all EGL properties . . . . . . . 999National language codes . . . . . . . . . 1009EGL core Exception records . . . . . . . . 1009Numeric formatting symbols . . . . . . . . 1012

    Examples . . . . . . . . . . . . . 1012Record and file type cross-reference . . . . . 1013Mapping EGL primitives to Java . . . . . . 1014

    ExternalType functions . . . . . . . . . 1015Report functions . . . . . . . . . . . 1017JavaLib functions. . . . . . . . . . . 1018JSF handler functions . . . . . . . . . 1019

    Passing arguments to Java types . . . . . . 1020Names for keyboard keys in EGL . . . . . . 1022

    Appendix. Notices . . . . . . . . . 1025Programming interface information . . . . . 1027Trademarks and service marks . . . . . . . 1027

    Index . . . . . . . . . . . . . . 1029

    viii EGL Language Reference

  • General syntax

    EGL is a specification-level language. Using EGL, you can perform the followingtasks:v Define data.v Generate the logic that operates on the data.v Customize user interfaces to present the data.

    The syntax for these definitions uses five different types of tokens (the smallestmeaningful particles in a program). Consider the following line of EGL code:while (customerNumber != 0)

    This line contains the following tokens:v whilev (v customerNumberv !v =v 0v )

    The EGL parser examines these tokens and classifies them. There are five differenttypes of tokens:

    LiteralsLiterals can be numeric (numbers) or strings (characters, in quotationmarks). For example, 0 is a literal.

    IdentifiersIdentifiers are names you assign to functions, variables, libraries, and othernamed entities in the program. For example, customerNumber is anidentifier.

    KeywordsKeywords are names EGL reserves for functions, properties, statements,constants, and other special purposes. For example, the keyword whilesignals the beginning of an EGL loop statement. For more on statements,see EGL statements on page 147.

    OperatorsOperators are symbols that define relationships between identifiers, orkeywords, or both. For example, not equal to (!=) is an operator.

    Special charactersSpecial characters provide the punctuation in EGL statements. For example,parentheses surround a logical expression like customerNumber != 0.

    Related reference:

    Literals on page 34Naming conventions on page 24EGL statements on page 147Expressions and operators on page 2

    Copyright IBM Corp. 1996, 2008 1

  • Expressions and operatorsAn expression is a sequence of operators, operands, and special characters thatEGL evaluates at run time. Operands can be literals, identifiers, or keywords (seeGeneral syntax on page 1). EGL can evaluate the following kinds of expressions:v Logical expressions evaluate to either TRUE or FALSE; see Logical expressions

    on page 7.v Numeric and text expressions evaluate to numeric or character values

    respectively; see Expression types on page 6.v Date/time expressions are a special and complex case; see Date and time

    expressions on page 80.

    EGL evaluates expressions according to a set of precedence rules (see Operatorsand precedence on page 3) and (within a given level of precedence) from left toright, but you can use parentheses to force a different ordering. A nestedparenthetical subexpression is evaluated before the enclosing parentheticalsubexpression, and all parenthetical expressions are evaluated before theexpression as a whole.

    As well as a value, expressions also have a type. A type is a set of formal limits tothe values that an expression can have. For more about the typing of expressions,see Expression types on page 6. For more about types, see Types on page 21and Primitive data types on page 66.

    Related reference

    General syntax on page 1Logical expressions on page 7Operators and precedence on page 3Expression types on page 6Date and time expressions on page 80Types on page 21Primitive data types on page 66

    Special charactersYou can use non-alphanumeric characters in EGL in any of the following roles:v operators (see Operators and precedence on page 3)v delimiters (see Delimiters in this topic)v type extension characters (see Type extension characters on page 32)

    DelimitersDelimiters mark the beginning and end of an entity. EGL uses the followingdelimiters:

    quotation marks Quotation marks in EGL always enclose a STRING literal.

    braces { }Braces can enclose any of the following things:v Property value assignments, as in the following example:

    username STRING {inputRequired = YES, upperCase = YES};

    v Initial value assignments for record fields, as in the following example:

    2 EGL Language Reference

  • record CustomerRecord type BasicRecord {customerNumber=0,customerBalance=0}

    customerNumber INT;customerBalance MONEY;

    end

    v Initialization for variables (usually with arrays), as in the followingexample:myStringsInit string[2] {"Hello", "Goodbye"};

    v Any combination of the above. Set variables or fields first, thenproperties:myDecimals decimal(10,2)[3] {55.43, 22.12, 4.34, CurrencySymbol = "$"};

    brackets [ ]Brackets can enclose any of the following things:v The number of elements in an array, as in the following example:

    myBigInts bigint[2];

    v An array literal, as in the following example:myBigInts = [10, 40];

    v The index of an array, as in the following example:myBigInts[2] = 5;

    v A range of values in a regular expression, as in the following example(see matches operator on page 16):if (myVar01 matches "[a-c]*")

    parentheses ( )Parentheses can enclose any of the following things:v The parameters, arguments, or return values of a function, as in the

    following example:function testFunction1(myInt INT in) returns(INT)

    return(5);end

    function testFunction2()testFunction1(12);

    end

    v Parts of an expression to be evaluated first, as in the following example:newVar INT = (5-2)*4;

    v The range of a variable (required for certain types), as in the followingexample:newDecimal DECIMAL(10,2);

    v Negative numbers in a mask, as in the following example:result = strLib.formatNumber(myNum,"(*,***,###.##)");

    Related reference

    Operators and precedenceType extension characters on page 32

    Operators and precedenceThe following table lists the EGL operators in order of decreasing precedence.Some operators have multiple meanings, depending on context. EGL sometimesuses special characters to represent type extensions (see Type extensioncharacters on page 32) and delimiters (see Delimiters on page 2).

    General syntax 3

  • This table does not include the assignment operator (=) or complex assignmentoperators (such as +=). For more information on these special cases, seeAssignments on page 155.

    Operators (separated by commas) Meaning

    . The member access operator (a dot) provides access tomembers of an entity, such as fields within records,functions within libraries, or properties withinvariables. Multiple levels of qualification arepermitted. Members become more specific as youmove from left to right.

    @ The @ operator indicates that a name refers to aproperty rather than a field.

    new The new operator calls the constructor function (aspecial function that creates a new variable) for areference variable (a variable that contains an addressrather than a value). Except in the case of someExternalType parts, this is a default constructor thattakes no parameters; see new operator.

    [] The array access operator (brackets) separates an indexvalue from an array name, or a substring value from acharacter variable name. a[x] is an array subscript andb[x:y] is a substring.

    +, - Unary plus (+) or minus (-) is a sign that precedes anoperand or parenthesized expression, not an operatorbetween two expressions.

    ** ** is the exponent operator, which can be read as tothe power of. For example c = a**b means that c isassigned the value of a to the power of b. The firstoperand (a in the example above) is a FLOAT thatcannot have a negative value. The second operand (bin the example above) is a FLOAT literal or variable,positive, negative or 0.

    *, /, &, |, xor Multiplication (*), integer division (/), and threebitwise operators are of equal precedence. Division ofintegers can result in a fractional value; for example,7/5 yields 1.4.

    Each of the bitwise operators and (&) , or (|), andexclusive or (xor) perform a bitwise operation on twooperands, returning a value of type INT. Eitheroperand may be of type HEX(2), HEX(4), HEX(8), INT,or SMALLINT. The operation begins by convertingany HEX or SMALLINT operand to type INT. In thecase of HEX, the operation left-pads the operandsvalue with zeros until the length is 4 bytes.

    % % is the remainder operator. It resolves to the moduluswhen the first of two operands or numeric expressionsis divided by the second. For example, 7%5 yields 2.

    +, - Addition (+) and subtraction (-) are binary operations(requiring two operands) of equal precedence.

    as The casting operator specifies a type (second operand)for the first operand; see as operator on page 10.

    4 EGL Language Reference

  • Operators (separated by commas) Meaning

    ::, ?:, + EGL uses two operators exclusively for concatenation(:: and ?:). The plus sign is also used as aconcatenation operator. For distinctions between them,see Concatenation operators on page 11.

    ==, !=, , =, isa Logical operators for Boolean comparison are of equalprecedence; each expression that contains one of theseoperators evaluates to either TRUE or FALSE.

    ! ! is the not operator, which EGL evaluates to a Booleanvalue (true or false) opposite to the value of a logicalexpression that immediately follows. That subsequentexpression must be in parentheses.

    is, not, in, like, matches These logical operators used for comparison are ofequal precedence; each expression that contains one ofthese operators is evaluated as true or false. See inoperator, like operator, matches operator.

    &&, and && (also spelled out as and) means both must betrue. An expression resolves to TRUE if both logicalexpressions on either side of the and operator are true;otherwise, the expression resolves to FALSE.

    ||, or || (also spelled out as or) means one or the other orboth. An expression resolves to FALSE if both logicalexpressions on either side of the or operator are false;otherwise, the expression resolves to TRUE.

    ExamplesFailure to observe the rules of precedence can cause unexpected errors, as in thefollowing examples.

    In the first example, the developer wrongly assumes that subtraction hasprecedence over multiplication:n NUM(3) = 100 - 98 * 100;

    EGL parses the right side of the equation as 100 - (98 * 100), giving a result that istoo large for a NUM(3):EGL0049E An overflow error occurred when assigning a value of -9,700 to n.

    In the second example, the developer intends the following expression to be true ifelement is not a member of the array myArray :if (!element in myArray)

    Instead, the not operator takes precedence over the in operator, so EGL searchesthe array for a false value, which is not what the developer expected.

    In both cases, using parentheses to force the intended precedence not only preventsthese errors, but makes the code more readable:n NUM(3) = (100 - 98) * 100;if (!(element in myArray))

    General syntax 5

  • CompatibilityTable 1. Compatibility considerations for operators

    Platform Issue

    COBOL generation vs.Java generation

    The remainder operator (%) produces consistent resultsbetween COBOL and Java when both operands are integers.When the operands contain decimals, however, the twolanguages use different rounding algorithms and remainderscan differ between the two.

    Rich UI The three bitwise operators (& | Xor) are not supported; nor isthe in operator.

    Related reference

    General syntax on page 1Type extension characters on page 32Assignments on page 155as operator on page 10Concatenation operators on page 11in operator on page 11like operator on page 15matches operator on page 16new operator on page 18

    Expression typesAn expression has both a value and a type, type being a set of limits that the valuemust fall within. The following rules make use of EGL primitive types; seePrimitive data types on page 66.

    The following rules determine the type of an expression. These rules do not coverthe possible conversion (promotion) of individual operands, which isplatform-dependent:

    Numeric expressionsThese rules apply to expressions involving arithmetic operators. The rulesdefine the expected type of the expression independent of precision orlength, and do not state how operands are converted, as this process isdifferent for each target language. The following binary operators canrequire promotion of one or more operands:v Arithmetic operators +, -, *, /, %, **v Numeric comparison operators ==, !=, , =v Bitwise operators &, |, ^The following rules apply, in order, to the arithmetic and numericcomparison operators:v If either operand is a text type, the type of the expression is NUMBERv Otherwise if either operand is a FLOAT, the type of the expression is

    FLOATv Otherwise if either operand is a SMALLFLOAT the type of the

    expression is SMALLFLOATv Otherwise if either operand is a NUM the type of the expression is

    NUM

    6 EGL Language Reference

  • v Otherwise if either operand is a NUMC the type of the expression isNUMC

    v Otherwise if either operand is a DECIMAL the type of the expression isDECIMAL

    v Otherwise if either operand is a BIN the type of the expression is BINv Otherwise if either operand is a BIGINT the type of the expression is

    BIGINTv Otherwise if either operand is an INT the type of the expression is INTv Otherwise if either operand is a SMALLINT the type of the expression is

    SMALLINT

    Each of the bitwise operators and (&) , or (|), and exclusive or (^) perform abitwise operation on two operands, returning a value of type INT. Eitheroperand may be of type HEX(2), HEX(4), HEX(8), INT, or SMALLINT. Theoperation begins by converting any HEX or SMALLINT operand to typeINT. In the case of HEX, the operation left-pads the operands value withzeros until the length is 4 bytes.

    Text expressionsThese rules apply to operands of binary operations that must have texttype values. The assumption here is that neither operand is a numeric typeas then the rules for numeric expressions apply. The following textcomparison operators can require promotion of one or more operands: ==,!=, , =.

    The following rules apply, in order:v If either operand is a STRING, the other is converted to STRINGv Otherwise if either operand is STRING(i), the second is converted to

    STRING(j), where j is the larger of the length of the second operand andi.

    v Otherwise if either operand is UNICODE(i), the second is converted toUNICODE(j), where j is the larger of the length of the second operandand i.

    v Otherwise if either operand is MBCHAR(i), the second is converted toMBCHAR(j), where j is the larger of the length of the second operandand i.

    v Otherwise if either operand is CHAR(i), the second is converted toCHAR(j), where j is the larger of the length of the second operand and i.

    Related reference:

    Expressions and operators on page 2Primitive data types on page 66

    Logical expressionsLogical expressions determine the path your program logic takes throughconditional and looping statements like if, while, for, and case.

    The following table summarizes the operators and operands for elementary logicalexpressions. Elementary expressions consist of an operand, a comparison operator,and a second operand.

    General syntax 7

  • Table 2. Elementary logical expressions

    First operand ComparisonOperator

    Second operand

    date/time expression ==, != , , = date/time expression

    The first and second expressions must be ofcompatible types. See Assignmentcompatibility in EGL on page 157.

    For date/time comparisons, the greaterthan sign (>) means later in time; and theless than (

  • Complex logical expressionsYou can use and (&&) and or operators (||) to build complex expressions bycombining pairs of more elementary expressions. In addition, you can use the notoperator (!) to reverse the value of an expression (changing TRUE to FALSE andFALSE to TRUE).

    If a logical expression contains elementary logical expressions that are theoperands of one or more or operators, EGL evaluates the expression inaccordance with the rules of precedence. The evaluation stops if one of theelementary logical expressions resolves to TRUE. Consider the following example:var01 == var02 || 3 in array03 || x == y

    If var01 does not equal var02, evaluation proceeds. If the value 3 is in array03, theoverall expression is TRUE, and EGL does not need to evaluate the last elementarylogical expression (x == y).

    Similarly, if elementary logical expressions are combined by and operators, EGLstops the evaluation as soon as one of the elementary logical expressions resolvesto FALSE. In the following example, evaluation stops as soon as var01 is found tobe unequal to var02:var01 == var02 && 3 in array03 && x == y

    You can use paired parentheses in a logical expression for any of these purposes:v To change the order of evaluation.v To clarify your meaning.v To make possible the use of the not operator (!), which resolves to a Boolean

    value (TRUE or FALSE) opposite to the value of a logical expression, containedin parentheses, that immediately follows.

    CompatibilityTable 3. Compatibility considerations for logical expressions

    Platform Issue

    COBOL generation COBOL does not offer a way to compare MBCHAR orDBCHAR to UNICODE or STRING.

    VisualAge Generatorcompatibility mode

    You cannot use is or not to test a value returned byvgLib.getVAGSysType().

    Related reference

    Expressions and operators on page 2Assignment compatibility in EGL on page 157Logical expressions for SQL records on page 382Logical expressions for Text UI forms on page 824systemType on page 354

    @ operatorThe @ operator indicates that the name following the operator refers to a propertyand not a field. This is necessary because you can use a set-value block (seeSet-value blocks on page 167) to set values both for properties and for fieldswithin a record.

    Complex properties contain one or more property fields. Complex propertiesrequire the @ operator to distinguish them from the property fields (see

    General syntax 9

  • Properties on page 53). Otherwise this operator is rarely used. If there is no fieldin the same set-value block with a conflicting name, EGL does not need the @operator to recognize a property name.

    ExampleAn EGL Dictionary part is a list of name-value pairs. Use a set-value block toassign those name-value pairs; you can use the same set-value block to assignvalues to properties of the dictionary itself. The following statement declares a newdictionary variable:myRef Dictionary {

    displayName = "myNewDictionary"};

    Because of part resolution rules (see EGL part resolution rules on page 30), EGLassumes that displayName = "myNewDictionary" is a name-value pair in the newdictionary. If you want to assign a value to the displayName property for thedictionary, you must use an @ operator, as in the following example:myRef Dictionary {

    @displayName {"myNewDictionary"}};

    Related reference

    Expressions and operators on page 2Set-value blocks on page 167Properties on page 53EGL part resolution rules on page 30

    as operatorThe as operator casts a value of one EGL type to another type. The most commonuse for the as operator is in conjunction with objects that Java returns through theExternalType syntax. This access is strictly static; therefore, you need to cast objectsto types that you have defined to EGL. For more information, see ExternalTypepart on page 129.

    The operator is also useful in dealing with ANY type variables.

    Syntax

    expressionAny valid EGL expression.

    typeAny EGL type except DataItem. A DataItem part does not define a typeseparate from the primitive type it represents. In the case of ExternalTypereferences, the runtime code needs to reference the actual type represented bythe EGL ExternalType. The type can include the nullable type specificationcharacter ? (see Null values and the nullable type).

    ExampleIn the following example, the default primitive type for a dictionary value is ANY.You cannot use the ANY type in a numeric expression, so you must cast the valuesas numeric types.

    expression as type

    10 EGL Language Reference

  • aDict Dictionary{ a = 1, b = 4 };result int;result = (aDict.a as INT) + (aDict.b as INT);

    Error conditionsIf you try to cast a value that is not appropriate to the target type, EGL throws aTypeCastException.

    Related reference

    Expressions and operators on page 2Null values and the nullable type on page 82

    Concatenation operatorsEGL offers two concatenation operators in addition to the plus sign. You can usethe following operators for concatenation:

    :: This operator (two colons) converts simple, assignment compatible types toSTRING and concatenates them; the operator can also append an elementto an array. Variable length null elements are ignored; fixed length nullelements are considered to be all spaces. If both operands are null, theoperator returns null.

    ?: This operator behaves the same way as :: except in regard to null values. Ifany element in the concatenation has a null value, the result will be null.This operator allows the migration of the I4GL || operator.

    + If you use + for concatenation, the left hand side of the expressiondetermines the type of the result. If the left hand side is a numericvariable, the result will be a number; if the left hand side is a text variable,the result will be concatenated text.

    ExamplesThe following code snippet shows varying results from the three operators:result, var1, var2, var3 STRING?;result2 INT?;

    var1="Sun";var3="day";result = var1 :: var2 :: var3; // result is "Sunday"result = var1 ?: var2 ?: var3; // result is nullvar1 = "123";var3 = "456";result1 = var1 + var2 + var3; // result is "123456" (STRING)result2 = var1 + var2 + var3; // result is 123456 (numeric)

    Related reference

    Operators and precedence on page 3

    in operatorThe in operator searches for a value either in an array or in a column of aDataTable. If the value is found, the expression evaluates to TRUE and thesysVar.arrayIndex system variable is set to the index of the element that containsthe value. If the value is not found, the expression evaluates to FALSE, andsysVar.arrayIndex is set to zero.

    General syntax 11

  • Syntax

    searchValueAn expression.

    arrayA one-dimensional array, or an element of a multidimensional array.

    dataTableColumnThe name of a column in a DataTable part. The in operator interacts with thatcolumn as if the column were a one-dimensional array.

    startAn integer, or an expression that resolves to an integer. The value of startspecifies the index of the first element to be searched for searchValue. If thevalue of start is greater than the number of elements in the array, theexpression evaluates to false, and sysVar.arrayIndex is set to zero. If the inexpression does not include from start, the search begins at the first element ofthe array or column. (EGL array indexes begin at 1 rather than 0.)

    ExamplesThe following table shows the effect of the in operator when you refer to acharacter array named myArray, defined as follows:myArray CHAR(1)[3] {"A", "B", "C"};

    Table 4. Effects of the in operator

    Logical expression Value ofexpression

    Value ofsysVar.

    ArrayIndex

    Comment

    A in myArray true 1

    C in myArray from 2 true 3 Search begins at secondelement (B)

    A in myArray from 2 false 0 Search begins at secondelement (B)

    In the next example, myArray01D is a one-dimensional array of strings, defined asfollows:myArray01D STRING[] = ["ABC", "DEF", "GHI"];

    myArray02D is a two-dimensional array, with each element (such asmyArray02D[1,1]) containing a single character, defined as follows:myArray02D CHAR(1)[3][3] = [["A", "B", "C"],

    ["D", "E", "F"],["G", "H", "I"]];

    searchValue in

    from start

    array

    dataTableColumn

    12 EGL Language Reference

  • The next table shows the effect of the in operator on myArray02D:

    Table 5. Further effects of the in operator

    Logical expression Value ofexpression

    Value ofsysVar.

    ArrayIndex

    Comment

    DEF in myArray01D true 2

    C in myArray02D[1] true 1

    I in myArray02D[3] from 2 true 3 Search begins at the thirdrow, second element

    G in myArray02D[2] from 2 false 0 Search ends at the lastelement of the row beingreviewed

    G in myArray02D[2] from 4 false 0 The second index is greaterthan the number ofcolumns available to search

    CompatibilityTable 6. Compatibility considerations for the in operator

    Platform Issue

    Rich UI The in operator is not supported.

    Related reference

    Expressions and operators on page 2Arrays on page 44The rules for an EGL array depend on the type of the array.

    is/not operatorThe is operator indicates whether the first of two operands is in the category of thesecond. The not operator indicates the opposite, that is, whether the first operandis not in the category of the second. The meaning of the operator depends on theleft side of the comparison.

    Syntax

    testExpressionA field in a record or form, sysVar.systemType, a record variable, or an arrayof record variables.

    keywordA keyword appropriate to the left side of the comparison. For details onsysVar.systemType keywords, see systemType on page 354; for fields andrecords, see the following categories.

    Record fieldsUse the following keywords for comparison to a field name in any type of recordor in a form:

    testExpression keywordis

    not

    General syntax 13

  • blanksA TRUE comparison means the text field on the left side of the comparisoncontains only blanks or nulls.

    numericA TRUE comparison means the character field on the left side of thecomparison contains only numeric characters.

    Use the following keyword for comparison to a field name in an SQL record:

    trunc A TRUE comparison means non-blank or non-null characters weredropped from the text field on the left side of the comparison after the lastread.

    Note that as of Version 7.0, the is operator is no longer used in comparisons withthe null keyword. Instead use the == operator.

    Use the following keywords for comparison to a field name in a form:

    cursor A TRUE comparison means the screen cursor is in the field on the left sideof the comparison.

    data A TRUE comparison means non-blank or non-null characters exist in thetext field on the left side of the comparison.

    modifiedA TRUE comparison means the modified data tag has been set for field onthe left side of the comparison.

    RecordsUse the is or not operator to check for I/O errors. If you are in V6 exception mode(see v60ExceptionCompatibility on page 120), you can compare a record (orrecord array) to both hard and soft errors. In normal exception mode, you cancompare only to soft I/O errors; hard I/O errors will throw either aFileIOException (file I/O) or an SQLException (SQL I/O). For a complete list ofI/O errors, see I/O error values on page 202.

    CompatibilityTable 7. Compatibility considerations for the is/not operator

    Platform Issue

    Rich UI Only the following variations of the is and not operators aresupported: use of sysVar.systemType and record-specific testsof blanks and numeric.

    Related reference

    Expressions and operators on page 2I/O error values on page 202systemType on page 354v60ExceptionCompatibility on page 120

    isa operatorThe isa operator is a binary operator that tests whether an expression resolves to aparticular EGL part. The logical expression resolves to TRUE if the expressionmatches the part identified; otherwise it resolves to FALSE. The most commonpurpose of the operator is to test the type of the data in an ANY type field.

    14 EGL Language Reference

  • Syntax

    testExpressionA numeric, text, or date/time expression. The expression can be a single fieldor literal.

    partSpecificationA part specification. The specification can be a system-defined part (like aprimitive part), or a user-defined part. If you can specify the primitive partwith a length (for example, CHAR(25)), partSpecification must include a lengthspecifier. partSpecification can be a dynamic array.

    Related reference

    Expressions and operators on page 2

    like operatorUse the like operator to compare a string to a regular expression. The regularexpressions available with like include wildcard and escape characters. The likeoperator resembles the LIKE keyword in SQL. For more robust regular expressions,see matches operator on page 16. The operator makes the comparison characterby character, left to right, and ends when one of the following conditions is met:v a character in the source string fails to match a position in the regular expression

    (comparison is false)v one string ends but the other does not (comparison is false)v both strings end (comparison is true)

    Syntax

    stringA STRING variable to compare to a regular expression.

    regExA regular expression to compare string to. The regular expression can be anyliteral or variable that is assignment compatible with STRING, except forDBCHAR. (EGL cannot recognize double byte wildcard characters.) For moreinformation, see Regular expression rules in this topic.

    Regular expression rulesYou can include any of the following special characters in a regular expressionwith the like operator:

    % Acts as a wildcard, matching zero or more characters in the source string.

    _ (underscore)Acts as a wildcard, matching a single character in the source string.

    \ (backslash)Indicates that the next character is to be compared to a single character inthe source string. The backslash (\) is called an escape character because itcauses an escape from the usual processing; the escape character is not

    testExpression partSpecificationisa

    string like regEx

    General syntax 15

  • compared to any character in the source string. The escape characterusually precedes a percent sign (%), an underscore (_), or anotherbackslash.

    When you use the backslash as an escape character (as is the defaultbehavior), a problem arises because EGL uses the same escape character toallow inclusion of a double quotation mark in any text expression. In thecontext of a regular expression, you must specify two backslashes becausethe text available at run time is the text that lacks the initial backslash. Toavoid this problem, specify another character as the escape character byusing the escape keyword, as shown in Examples in this topic. Note thatyou cannot use a double quotation mark () as an escape character.

    Any other character in the regular expression is a literal that is compared to asingle character in the source string.

    ExamplesThe following example uses wildcards in a regular expression:myVar01 = "abcdef";

    // evaluates as TRUEif (myVar01 like "a_c%")

    ;end

    The following example shows the use of an escape character. Note the use ofdoubled backslashes:myVar01 = "ab%def";

    // evaluates as trueif (myVar01 like "ab\\%def")

    ;end

    The following example uses the escape keyword to make the plus sign the escapecharacter for the regular expression:myVar01 = "ab%def";

    // evaluates as trueif (myVar01 like "ab+%def" escape "+")

    ;end

    The like operator ignores trailing blanks in both operands:// evaluates as trueif ("hello " like "hello ")

    ;end

    Related reference

    Expressions and operators on page 2matches operator

    matches operatorUse the matches operator to compare a string to a regular expression. Use of thelike operator resembles the use of regular expressions in UNIX or Perl; forsimpler regular expressions, see like operator on page 15.

    16 EGL Language Reference

  • The matches operator makes its comparison character by character, left to right,and ends when one of the following conditions is met:v a character in the source string fails to match a position in the regular expression

    (comparison is false)v one string ends but the other does not (comparison is false)v both strings end (comparison is true)

    Syntax

    stringA STRING variable to compare to a regular expression.

    regExA regular expression to compare string to. The regular expression can be aCHAR or MBCHAR literal or variable, or a UNICODE variable. For moreinformation, see Regular expression rules in this topic.

    Regular expression rulesYou can include any of the following special characters in the regular expression:

    * Acts as a wildcard, matching zero or more characters in the stringexpression

    ? Acts as a wildcard, matching a single character in the string expression

    [ ] Any one of the characters between the two brackets is valid as a match forthe next character in the string expression. For example, the followingcomponent of a regular expression indicates that a, b, or c is valid as amatch:[abc]

    - Creates a range within the bracket delimiters, such that any characterwithin the range is valid as a match for the next character in the stringexpression. For example, the following component of a regular expressionindicates that a, b, or c is valid as a match:[a-c]

    The hyphen (-) has no special meaning outside of bracket delimiters.

    ^ The caret reverses the meaning of the bracket delimiters. Any characterother than the delimited characters is valid as a match for the nextcharacter in the string expression. For example, the following componentof a regular expression indicates that any character other than a, b, or c isvalid as a match:

    [^abc]

    The caret has no special meaning other than in the first position withinbrackets.

    \ Indicates that the next character is to be compared to a single character inthe string expression. The backslash (\) is called an escape character becauseit causes an escape from the usual processing; the escape character is notcompared to any character in the string expression. The escape character

    string matches regEx

    General syntax 17

  • usually precedes a character that is otherwise meaningful in the regularexpression, such as an asterisk (*) or a question mark (?).

    When you use the backslash as an escape character (as is the defaultbehavior), a problem arises because EGL uses the same escape character toallow inclusion of a double quotation mark in any text expression. In thecontext of a regular expression, you must specify two backslashes becausethe text available at run time is the text that lacks the initial backslash. Toavoid this problem, specify another character as the escape character byusing the escape keyword, as shown in Examples in this topic. Note thatyou cannot use a double quotation mark () as an escape character.

    Any other character in the regular expression is a literal that is compared to asingle character in the source string.

    ExamplesThe following example uses wildcards in a regular expression:myVar01 = "abcdef";

    // evaluates as TRUEif (myVar01 matches "a?c*")

    ;end

    The following example shows the use of the escape character. Note the use ofdoubled backslashes:myVar01 = "ab*def";

    // evaluates as TRUEif (myVar01 matches "ab\\*[abcd][abcde][^a-e]")

    ;end

    The following example uses the escape keyword to make the plus sign the escapecharacter for the regular expression:myVar01 = "ab*def";

    // the next logical expression evaluates to "true"if (myVar01 matches "ab+*def" escape "+")

    ;end

    Related reference

    Expressions and operators on page 2like operator on page 15

    new operatorUse the EGL new operator to dynamically create storage of a specified type. If youare creating a reference type variable, new creates a reference to the storage;otherwise it creates the storage itself.

    You can specify a set-value block with the new operator. Note that a set-valueblock automatically turns off the null flag for a nullable variable. For moreinformation, see Set-value blocks on page 167. For examples, see When to usethe new operator in this topic.

    18 EGL Language Reference

  • Syntax

    partNameThe name of an EGL part.

    When to use the new operatorThe only efficient use of the new operator is when you use it to create storagewithout assigning a name to it. In the following example, a function takes adictionary as its parameter:func( new Dictionary{ key1 = 3, key2 = "Hello", key3 = false } );

    In the following example, the record contains a field that is an array of anotherkind of record. In this case, you must use the new operator:record CustomerArraymyCustomers CustomerRec[] =

    [ new CustomerRec { idNum = 101 },new CustomerRec { idNum = 102 } ];

    end

    The alternative, declaring CustomerRec variables to put in the array, is impossible.A initializer for the record cannot access any variables other than the fields withinthat record.

    You can use the new operator in a variable declaration in the following manner:myInt INT = new INT;

    This declaration offers no benefit and one major disadvantage compared to astandard declaration such as the following:myInt INT;

    When you use the new operator, storage is reserved twice. First the left hand sideof the assignment creates storage for an INT and names it myInt. Then the newoperator creates a second INT, and assigns its value to the first. The second INT isnot used again.

    You can use the following declaration to create a nullable variable (indicated bythe question mark) whose initial value is not null:myInt INT? = new INT;

    The left hand side creates a nullable variable. The new operator creates an INTthat is not nullable and assigns its value to the first INT. You can get the sameeffect with the following line, which creates a single variable:myInt INT?{};

    Related reference

    Expressions and operators on page 2Reference variables on page 38Set-value blocks on page 167

    new partName

    General syntax 19

  • ScopeScope refers to the largest region of a program where you can refer to a namewithout having to qualify it. That is, scope is the context that you can use todifferentiate entities that have the same name. Most procedural languages have theconcept of a subroutine; typically, if you declare a variable myVar in a subroutine,its value is local to that subroutine. Local means that the program that called thesubroutine cannot see the variable and does not have access to its value.

    To understand scope in EGL, you need to understand the structure that providesscope for the names in a program; see Parts.

    Related reference

    PartsEGL projects, packages, and files on page 25

    PartsThe part is a crucial concept in EGL. A part refers to an independent part of anapplication. No part can exist inside of another part. Parts can be as large as aProgram, or as small as a single DataItem. You use three main kinds of parts inEGL programming:v Data parts contain values.v Logic parts perform operations on data.v User Interface (UI) parts provide specialized data structures for interaction with a

    user.

    Generatable parts differ from other parts. Generatable parts, such as FormGroups,Libraries, and Programs, must each occupy a separate source file and generate acompilable unit.

    A variable is a named entity in either an EGL logic part or Record. Variables arebased on data parts, which means that a variable reserves storage for a particularkind of data. For more information, see Variables on page 31.

    If you declare a variable or constant in a part, that identifier is in scope throughoutthe part:v If the declaration is in a function, the identifier is in the local scope of the

    function. For example, if the function getCustomer() declares the variablerunningBalance, any code in getCustomer() that follows the declaration canreference runningBalance.You can pass the variable as an argument to another function, but the originalidentifier is not available in the called function. Instead, the name of thecorresponding parameter in the receiving function declaration is available in thecalled function.

    v If the declaration is in a generatable part (such as a Program) but is outside ofany function (including the main() function), the name is global to that part.Refer to the name without qualifying it in any function called by the part. Forexample, if a program declares runningBalance outside of a function andinvokes getCustomer(), which in turn invokes getCustomerBalance(),runningBalance is available throughout both functions.

    v If the declaration is in a Library part, but outside of a function, the identifier isin scope within the run unit (a set of programs that operate together; see Rununit on page 187).

    20 EGL Language Reference

  • v For an explanation of scope issues relating to a DataTable part, see DataTablepart on page 98.Related reference

    Variables on page 31DataTable part on page 98Run unit on page 187EGL part resolution rules on page 30

    TypesA type resembles a part, but the terms are not interchangeable. In any computerlanguage, a type is a modifier that limits the set of values appropriate for avariable. For example, INT is a numeric type that guarantees that a variablecontains a whole number.

    EGL primitive parts are also types. When you declare a variable based on an INTpart, you set limits for that variable, that is, you are typing that variable as an INT.Other parts, like the Dictionary or the Record, are also types because they limitpossible values. The DataItem is an exception. A DataItem has the same type as theprimitive part it is based on.

    EGL is strict about its types. For example, when you create a variable based on aDictionary part, there are rules for how you can construct an expression using thatvariable. You cannot equate a Dictionary type variable to an INT or any otherprimitive type variable.

    Related reference

    Parts on page 20DataItem part on page 93Dictionary part on page 83Dictionary parts contain lists of data that you can access via a key. For example,you can create a message handling facility that uses a library and a dictionarypopulated with keys and messages read from a database.

    QualifiersYou cannot have two identical names in scope at the same time. However, mostidentifiers that you can access from another part refer to an area of memory that islogically inside a container (a generatable logic part, like a Program). In those casesyou can qualify a name with the name of the enclosing container, using dot syntax.You can qualify the following identifiers in this way:v fields within recordsv fields within formsv variables or functions within librariesv parts within packages

    For example, if the variable customerBalance is in a record variable namedmyCustomer, your code refers to the variable as a field of the record:

    myCustomer.customerBalance

    If the same identifier is in two scopes, any unqualified reference to the identifier isa reference to the most local scope. You can use qualifiers to override that behavior.Consider a program with a use declaration to access the library customerLib. Theprogram and the library each declare a function named getCustomer(). You canqualify variable names in the following ways:

    General syntax 21

  • v If a function in the program invokes getCustomer() with no qualifier, EGL callsthe local (program) version.

    v If you qualify the function name with the name of the library, EGL calls thefunction from the library:

    customerLib.getCustomer();

    v If you preface the part name with the package name (such as customerPackage),EGL can call the library or data table from a different package, even though youhave not referenced the part in an import statement:

    customerPackage.customerLib.getCustomer();

    The package name always qualifies a logic part name and cannot immediatelyprecede a variable, constant, or function name. A local identifier can be the sameas a data table or library name if the local identifier is in a different packagefrom the one where the data table or library resides. To reference the data tableor library name, include the package name.

    For more information, see Name resolution in an expression.Related reference

    The this keyword on page 23DataTable part on page 98Run unit on page 187Name resolution in an expression

    Name resolution in an expressionA name in an EGL expression can refer to any of the following:v a parameterv a variablev a fieldv a functionv a part (if the name is qualified)

    The name resolution process is the same no matter where the expression is located(the expression might be in an assignment statement, a function call, or otherposition). The rules for resolving a part name are different; see EGL partresolution rules on page 30.

    To resolve a name in an expression, EGL looks at the following declarations, inorder:1. Current variables. These are the variables declared within the current function.

    This includes the parameter list for the function, and any record variable names(but not field names within those records). No duplicate names are allowed inthis category.

    2. Current I/O objects. These are I/O objects and other fields specific to thecurrent function. I/O objects might include an array of SQL records referencedin a get statement. At the same level are fields in record variables that aredeclared or passed as parameters to the function. Record variables declared atthe current function level are found in step 1; record variables declared at theprogram level are found in this step. It is possible to have duplicate names inthis category.

    22 EGL Language Reference

  • For example, two record variables might be based on the sameCustomerRecord definition, each with a customerNumber field. In this case,you must qualify the name customerNumber with the name of the recordvariable to prevent ambiguity.Another example might be a program-level record variable and a function-levelfield with the same name. In this case, take one or more of the followingactions:v Qualify the name of the program-level record variable with the this

    keyword.v Set the allowUnqualifiedItemReferences property to YES.v Qualify the field with the name of the DataTable, form, or structured record

    that contains it. Field names in non-structured records must always bequalified with the record name.

    3. Program variables. These are the variables declared at the program level. Theyinclude the parameter list (in the case of a called program), and any recordvariable names (but not field names in those records). No duplicate names areallowed in this category.

    4. Form names. These form names can be declared in any of the following ways:v In use declarations.v Specified by the inputForm property.v In the parameter list of the program.v In any I/O statements in any function in the program.If the use declaration refers to a FormGroup, EGL looks at all form nameswithin the group. No duplicate names are allowed in this category.

    5. Data table names. It looks at data table names in a use declaration. Noduplicate names are allowed in this category.

    6. Fields. EGL now looks at all fields within the records, forms, and data tables insteps 3-5. Duplicate names in this category must be qualified to preventambiguity.

    7. Library variables. These are the variables in a user library specified in a usedeclaration. Duplicate names in this category must be qualified with the nameof the library.

    8. System variables. Finally EGL looks at the variables in the EGL system libraries.There are no duplicate names in this category.Related reference

    EGL part resolution rules on page 30Qualifiers on page 21

    The this keywordThe this keyword provides a predefined qualifier that refers to the container (thegeneratable logic part) that holds the current function. Consider the followingsituation: A program declares a global variable named runningTotal, then, fromthe main() function, calls the function getCustomer(). That function declares itsown local variable named runningTotal. The original runningTotal is theoreticallyin scope within the function, but the unqualified name now refers to the localversion. To access the original, use the qualifier this:runningTotal = this.runningTotal + myCustomer.customerBalance;

    Here the local runningTotal variable is initialized with the value of therunningTotal variable from main(), then the balance from the current customer isadded to the local total.

    General syntax 23

  • In rare cases, you can use the this keyword to override a behavior of a set-valueblock in an assignment statement. Here this establishes the scope as being thedeclaration in which the set-value block resides. For details, see Set-value blockson page 167.

    ExampleAssume you have a program, myProgramA, that calls a function, main(), that inturn calls myFunctionB(). Assume that each of these parts declares a variable, varX:program myProgramA type BasicProgramvarX STRING = "program";

    function main()varX STRING = "main";myFunctionB();

    end

    function myFunctionB()varX STRING = "Function B";writeStdErr(this.varX);

    endend

    The variable this.varX displays the value program on the console, because theprogram is the generatable logic part that holds myFunctionB().

    Related reference

    Set-value blocks on page 167

    NamespaceA namespace is an identifier for a set of unique names. Use the namespace as aqualifier to resolve conflicts in a larger context. For example, if you have an EGLlibrary named CustomerLib, all names within that library must be unique (with theunderstanding that some of those names might have qualifiers to make themunique). Therefore, if you declare a variable named runningBalance within thenamespace of CustomerLib, you can refer to that variable outside of that namespaceby adding the namespace to the variable name (using dot syntax):CustomerLib.runningBalance = CustomerLib.runningBalance +

    myCustomer.customerBalance;

    Related reference

    package on page 26EGL projects, packages, and files on page 25

    Naming conventionsThis topic describes the rules for naming parts and variables and for assigningvalues to properties such as name.

    EGL has three categories of identifiers:v EGL part and variables names.v External resource names that are specified as property values in part definitions

    or variable declarations. These names represent special cases, and the namingconventions depend on the conventions of the runtime system.

    v EGL package names such as com.mycom.mypack. In this case, each charactersequence is separated from the next by a period, and each sequence follows thenaming convention for an EGL part name. For details on the relationship ofpackage names and file structure, see EGL projects, packages, and files onpage 25.

    24 EGL Language Reference

  • An EGL part or variable name is a series of 1 to 128 characters. Except as noted, aname must begin with a letter or an underscore and can include additionalUnicode letters as well as digits and currency symbols. The following additionalrestrictions apply:v The first characters cannot be EZE in any combination of uppercase and

    lowercase.v A name cannot contain embedded blanks or be an EGL reserved word (see

    EGL reserved words on page 997).v A name cannot include hyphens (unless you are running in VisualAge Generator

    compatibility mode). Otherwise, it is difficult for the programmer to distinguishwhether X-Y in the following example is an expression or a name:if(X-Y)

    addToTotal();end

    Special considerations apply to parts:v In a Record part, the name of a logical file or queue can be no more than 8

    charactersv In various parts, the alias is incorporated into the names of generated output

    files and Java classes. If you do not specify the alias, EGL uses the name of theProgram part, but truncates it (if necessary) to the maximum number ofcharacters allowed in the runtime environment. See Compatibility in this topic.

    CompatibilityTable 8. Compatibility considerations for naming conventions

    Platform Issue

    COBOL generation The maximum name length is as follows:

    v Service and Interface part names have a 7 charactermaximum.

    v Program and Library part names have an 8 charactermaximum on zSeries, and a 7 character maximum oniSeries.

    VisualAge Generatorcompatibility mode

    The following rule applies to part and variable names but hasno effect on package names: Characters after the initialcharacter can include at signs (@), hyphens (-), and poundsigns (#).

    Related reference

    Scope on page 20EGL projects, packages, and filesEGL reserved words on page 997

    EGL projects, packages, and filesProjects and packages are arbitrary categories you can use to organize your EGLsource files. Use them to keep some parts of your application together, and isolatethose parts from others. In practice, EGL architects tend to divide an applicationaccording to one or more of the following criteria:v Business problems to be solvedv Technology types to be usedv Development groups who do the coding

    General syntax 25

  • v Archival methods to be used to store the source code and maintain sourcecontrol

    v Optimum program sizev Testing strategies

    A small application typically consists of a single project. A large enterpriseapplication can include a number of projects, each with several packagesunderneath. Dividing applications into projects and packages is a highly subjectiveprocess that varies from one company to another. Be sure to keep your focus on:v what the business problems arev who does the developmentv where the programs are written, run, and maintained

    As well as being conceptual units, projects and packages also represent specificfolders in your EGL workspace. The project is at the highest level, with underlyingpackages created in the EGLSource folder below it.

    Projects differ from packages in one important way. You can use the name of apackage as a qualifier to bring a part or variable into your current scope (seeScope on page 20). In contrast, you never use the name of a project within anEGL program. For information about importing information from other projects,refer to the EGL Generation Guide.

    Related reference

    packageScope on page 20

    packageThe EGL package statement assigns a name to a collection of related parts.

    All EGL source files should contain a package statement. Any number of files canbelong to the same package, therefore a package can contain multiple packagestatements (one for each source file). If you do not specify a package statement ina file, the file is stored directly in the source folder and is said to be in the defaultpackage. Parts in the default package cannot be shared by parts in other packagesor projects. For this reason, avoid using the default package by always specifying apackage statement.

    Two parts with the same name cannot be defined in the same package. You shouldalso avoid using the same package name under different projects or differentfolders.

    Syntax

    packageNameSee Naming conventions in this topic for more information about how toname your package.

    Naming conventionsBy convention, you make your package name unique by prefacing it with aninversion of the Internet domain name for your organization. For example, theIBM domain name is ibm.com, and the EGL packages begin with com.ibm. The

    package packageName ;

    26 EGL Language Reference

  • package name (a sequence of identifiers separated by periods) serves to identifythe folders for package files, as in the following example:

    com.CompanyB.Customer

    Each name corresponds to a subfolder, so the directory structure for the previousexample is financialProjects\EGLSource\com\CompanyB\Customer. When EGLcreates directories in the Java Resources directory, it changes all names to lowercase. This is because EGL is not case sensitive, but Java is.

    ExampleThe following example shows the beginning and end of a library file. Because theCustomerRecord declaration lies outside the Library part, its scope is global to thepackage (see Scope on page 20).package com.companyb.customer;

    Record CustomerRecord type SQLRecord{ keyItems=["customerNumber"] }customerNumber INT; // key itemcustomerName STRING;customerBalance DECIMAL(9,2);end

    Library CustomerLib

    myCustomer CustomerRecord;

    getCustomer()...end // end function

    end // end libary

    Related reference

    Scope on page 20

    importThe EGL import statement identifies a set of parts that are in a specified package,and allows you to reference the imported parts as if they were in the same packageas the file containing the import statement. If the statement identifies a fullyqualified part name, it is called a single part import.

    You can use the wildcard character (*) to import any referenced parts within agiven package, as in the following example:import com.companyb.crmpackage.*;

    This is called an on demand import; parts are imported only as needed.

    You can also import packages from outside your current project. For moreinformation, refer to the EGL Generation Guide.

    To understand how EGL resolves potential conflicts between part names, see EGLpart resolution rules on page 30.

    General syntax 27

  • Syntax

    packageNameThis is the name of the package to search for the requested part. You cannotimport parts from the default package.

    partNameThe name of the part to be imported. You can replace this name with anasterisk to import all parts as needed.

    Related reference

    Import and use statementsUse the EGL import and use statements to expand the visibility of codeelements.use

    useYou can include EGL use statements to simplify your references to variables andfunctions in other parts. You can, for example, write a use statement that givesyour program eas