EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types,...

4
Operators (in precedence order) . record.field, library.function, variable.property new new myPart {value} [] myArray[index], mySubstr = myStr[begin:end] +, - Unary plus or minus ** To the power of *, /, &, |, xor Multiply, divide, bitwise and, or, exclusive or % Remainder. 17%5 = 2 +, - Binary add and subtract as Casting. v1 = v2 as v1_type ::, + Concatenation ==, !=, <, >, <=, >=, isa Boolean comparison. myVar isa v1_type ! not. !(expression) is, not, in, like, matches Boolean comparison. value in myArray, myString like sql_reg_ex, myString matches unix_reg_ex &&, and Binary and ||, or Binary or EGL Quick Reference Primitive data types Character CHAR(n) 1 byte Max n = 32767 DBCHAR(n) 2 bytes Max n = 16383 MBCHAR(n) 1 or 2 bytes Max n = 32767 STRING varies Max 16383 Unicode chars UNICODE(n) 2 bytes Max n = 16383 HEX(n) 4 bits Max n = 65534 Date/time DATE 8 digits Gregorian yyyyMMdd INTERVAL 1-21 digits Based on mask TIME 6 digits HHmmss TIMESTAMP 1-20 digits Based on mask Number BIGINT 18 digits Binary BIN(n,n) 18 digits Binary DECIMAL(n,n) 32 digits Packed decimal characters FLOAT 18 digits Double-precision floating point INT 9 digits Binary MONEY(n,n) 32 digits Packed decimal characters NUM(n,n) 32 digits Numeric chars SMALLFLOAT 9 digits Single-precision floating point SMALLINT 4 digits Binary Other BOOLEAN 1 byte YES/NO or TRUE/FALSE ANY Any Reference type EGL syntax Literals Numerals, strings in quotation marks, or boolean (TRUE, FALSE, YES, NO) Identifiers Names users assign to variables, files, and more Keywords Names that EGL reserves for statements, types, and operators Operators Symbols that define relationships Special characters Punctuation such as commas, semicolons, and parentheses This reference shows only the most common elements and variations in EGL. For complete information, see the EGL documentation. Join the EGL community for updates, blogs, Q&A, samples, tutorials, and more at: www.ibm.com/rational/eglcafe. Core elements Complex assignment a += b, a –=b a = a + b, a = a – b a *= b, a /= b a = a * b, a = a / b a **= b a = a ** b a %= b a = a % b a |= b, a &= b a = a | b, a = a & b a xor= b a = a xor b a ::= b a = a :: b

Transcript of EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types,...

Page 1: EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types, and operators Operators Symbols that define relationships Special characters Punctuation

Operators (in precedence order). record.field,

library.function, variable.property

new new myPart {value}

[] myArray[index], mySubstr = myStr[begin:end]

+, - Unary plus or minus** To the power of*, /, &, |, xor Multiply, divide, bitwise and, or,

exclusive or% Remainder. 17%5 = 2+, - Binary add and subtractas Casting. v1 = v2 as v1_type::, + Concatenation==, !=, <, >, <=, >=, isa

Boolean comparison. myVar isa v1_type

! not. !(expression)is, not, in, like, matches

Boolean comparison. value in myArray, myString like sql_reg_ex, myString matches unix_reg_ex

&&, and Binary and||, or Binary or

EGL Quick Reference

Primitive data typesCharacter

CHAR(n) 1 byte Max n = 32767DBCHAR(n) 2 bytes Max n = 16383MBCHAR(n) 1 or 2 bytes Max n = 32767STRING varies Max 16383

Unicode chars UNICODE(n) 2 bytes Max n = 16383HEX(n) 4 bits Max n = 65534Date/time

DATE 8 digits Gregorian yyyyMMdd

INTERVAL 1-21 digits Based on maskTIME 6 digits HHmmssTIMESTAMP 1-20 digits Based on maskNumber

BIGINT 18 digits BinaryBIN(n,n) 18 digits BinaryDECIMAL(n,n) 32 digits Packed decimal

charactersFLOAT 18 digits Double-precision

floating pointINT 9 digits BinaryMONEY(n,n) 32 digits Packed decimal

charactersNUM(n,n) 32 digits Numeric charsSMALLFLOAT 9 digits Single-precision

floating pointSMALLINT 4 digits BinaryOther

BOOLEAN 1 byte YES/NO or TRUE/FALSE

ANY Any Reference type

EGL syntaxLiterals Numerals, strings in quotation marks, or

boolean (TRUE, FALSE, YES, NO)Identifiers Names users assign to variables, files, and

moreKeywords Names that EGL reserves for statements,

types, and operatorsOperators Symbols that define relationshipsSpecial characters

Punctuation such as commas, semicolons, and parentheses

This reference shows only the most common elements and variations in EGL. For complete information, see the EGL documentation.

Join the EGL community for updates, blogs, Q&A, samples, tutorials, and more at:www.ibm.com/rational/eglcafe.

Core elements

Complex assignmenta += b, a –=b a = a + b, a = a – b

a *= b, a /= b a = a * b, a = a / b

a **= b a = a ** b

a %= b a = a % b

a |= b, a &= b a = a | b, a = a & b

a xor= b a = a xor b

a ::= b a = a :: b

Page 2: EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types, and operators Operators Symbols that define relationships Special characters Punctuation

StatementsData access

add myRec;

close myRec;

delete myRec [cursor | nocursor | usingKeys] [from myResults];

execute sqlStmt [using vars] | id [for myRec];

get [myRec] [singleRow | forUpdate] [with sqlStmt [using vars]] [into vars] [usingKeys fields];

get absolute(n) | current | first | last | next | previous | relative(n) myRec | from myResults [into vars];

open myResults [forUpdate] [with sqlStmt [using vars]] [usingKeys fields] [into vars] [for myRec];

prepare id from string [for myRec];

replace myRec [cursor | nocursor | usingKeys] [from myResults];

Data movement

move source to target [byName | byPosition | for count];

set myRecord | myVar empty | initial;

Conditional and loop

case (var) when (value) stmts …[otherwise stmts] … end

case when (expression) statements …[otherwise statements] … end

continue [for | forEach | while];

exit [case | for | forEach | if | program | rununit | stack | while];

for (counter [from value] to value [decrement] [by value]) … end

forEach (myRec | from myResults [into vars]) … end

if (expression) stmts else stmts end

while (expression) stmts end

Transfer of control

call myProgram [(args)];

call myService.myFunction1([args]) returning to myFunction2 [onException myFunction3];

forward [myVar] to url;

return (value);

transfer to program | transaction myProgram [passing myRec];

Exceptions

try stmts onException(myException) stmts … end

throw myException;

Other built-in data typesArray

myArray data_type[]

myArray.function()

appendAll(myArray2)

appendElement(myVar)

getMaxSize() returns INT

getSize() returns INT

insertElement(myVar, index)

removeAll()

removeElement(index)

resize(size)

resizeAll(sizes[])

setElementsEmpty()

setMaxSize(size)

setMaxSizes(sizes[])

Dictionary

myDictionary Dictionary {entry1 = value1, entryn = valuen}

myDictionary.entry1 = value1

myDictionary.function()

containsKey(myString) returns BOOLEAN

getKeys() returns STRING[]

getValues() returns ANY[]

insertAll(myDictionary2)

removeAll()

removeElement(myString)

size() returns INT

EGL Quick Reference Core elements

Part typesDataItem myType primitive end

DataTable myTable [type table_type] {contents = []} end

Function myFunction ([parameters]) [returns (type)] … end

Interface myInterface … end

Library myLibrary [type BasicLibrary | RUIPropertiesLibrary] … end

Program myProgram [type BasicProgram | TextUI ] ... end

Record myRecord [type BasicRecord | Exception | SQLRecord | IndexedRecord | RelativeRecord | Serialrecord] … end

Service myService [implements myInterface] … end

Page 3: EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types, and operators Operators Symbols that define relationships Special characters Punctuation

DateTimeLibcurrentDate() returns DATE

currentTime() returns TIME

currentTimestamp() returns TIMESTAMP

dateOf(myTimestamp) returns DATE

dateValue(dateAsString) returns DATE

dateValueFromGregorian(dateAsGregorianInt) returns DATE

dateValueFromJulian(dateAsJulianInt) returns DATE

dayOf(myTimestamp) returns INT

extend(myDate | myTime | myTimestamp [,pattern]) returns TIMESTAMP

intervalValue(intervalAsString) returns INTERVAL

intervalValueWithPattern(intervalAsString [,pattern]) returns INTERVAL

mdy(month, day, year) returns DATE

monthOf(myTimestamp) returns INT

timeOf([myTimestamp]) returns TIME

timestampFrom(myDate, myTime) returns TIMESTAMP

timestampValue(timestampAsString) returns TIMESTAMP

timestampValueWithPattern(timestampAsString [,pattern]) returns TIMESTAMP

timeValue(timeAsString) returns TIME

weekdayOf(myTimestamp) returns INT

yearOf(myTimestamp) returns INT

MathLibTrig functions take a single argument, which can be any of the following types: SMALLINT, INT, BIGINT, DECIMAL, SMALLFLOAT, or FLOAT. The return value has the same type as the argument:

abs()acos()asin()atan()

atan2()cos()cosh()exp()

log()log10()sin()sinh()

sqrt()tan()tanh()

The following functions are also in mathLib:ceiling(myFloat) returns BIGINT | FLOAT

decimals(myDecimal) returns INT

floor(myFloat) returns BIGINT | FLOAT

frexp(myFloat,exponent) returns FLOAT

ldexp(myFloat,exponent) returns FLOAT

max(num1,num2) returns num1 | num2

min(num1,num2) returns num1 | num2

modf(myFloat,integer) returns FLOAT

precision(num) returns INT

round(decimal,myInt) returns decimal

J2EELibclearRequestAttr(myString)

getRequestAttr(myString) returns ANY

setRequestAttr(myString, myVar)

getRemoteUser() returns STRING

isUserInRole(myString) returns BOOLEAN

ServiceLibbindService(bindingKey) returns

Service | Interface

convertFromJSON(myString,myRecord | myDictionary)

convertFromURLEncoded(myString) returns STRING

convertToJSON(myRecord | myDictionary) returns STRING

convertToURLEncoded(myString) returns STRING

endStatefulServiceSession(myService | myInterface)

getCurrentCallbackResponse() returns HTTPResponse

getOriginalRequest() returns HTTPRequest

getRestRequestHeaders(myService | myInterface) returns Dictionary

getRestServiceLocation(myService | myInterface) returns STRING

getTCPIPLocation(myService | myInterface) returns STRING

getWebServiceLocation(myService | myInterface) returns STRING

setHTTPBasicAuthentication(myService | myInterface,pwd,uid)

setProxyBasicAuthentication(myService | myInterface,pwd,uid)

setRestRequestHeaders(myService | myInterface,headerDictionary)

setRestServiceLocation(myService | myInterface,myString)

setTCPIPLocation(myService | myInterface,myString)

setWebServiceLocation(myService | myInterface,myString)

EGL Quick Reference System libraries

Page 4: EGL Quick Reference - IBM · 2010-08-13 · Keywords Names that EGL reserves for statements, types, and operators Operators Symbols that define relationships Special characters Punctuation

SQLLibbeginDatabaseTransaction([myString])

connect(dbname,uid,pwd[,my DisconnectKind[,myIsolationLevelKind[,myCommitControlKind]]])

constructQuery(myRecord,myDictionary,flag) returns STRING

disconnect([myString])

disconnectAll()

loadTable(fileName,insertClause[,delimiter])

setCurrentDatabase([myString])

unloadTable(fileName,selectStmt[,delimiter])

StrLibbooleanAsString(expression) returns

“true” | “false”

byteLen(charVar) returns INT

characterLen(charVar) returns INT

charAsInt(myChar) returns INT

clip(myString,flag) returns STRING

formatDate(myDate,[format]) returns STRING

formatNumber(expression,[format]) returns STRING

formatTime(myTime,[format]) returns STRING

formatTimestamp(myTimestamp,[format]) returns STRING

getNextToken(myString,index,delimiters) returns STRING

getTokenCount(myString,delimiters) returns INT

indexOf(myString,pattern,[start]) returns INT

intAsChar(myInt) returns CHAR(1)

intAsUnicode(myInt) returns UNICODE(1)

lowercase(myString) returns STRING

spaces(count) returns STRING

unicodeAsInt(myUnicode) returns INT

upperCase(myString) returns STRING

SysLibbytes(myVar) returns INT

errorLog(myString)

getCmdLineArg(myInt) returns STRING

getCmdLineArgCount() returns INT

getMessage(key[,inserts]) returns STRING

getProperty(name) returns STRING

maximumSize(arrayName) returns INT

setError(field,key[,insert])

setError(myString)

setLocale(language,country[,variant])

setRemoteUser(uid,pwd)

size(array) returns INT

startLog(myString)

wait(myBin)

writeStdErr(myString)

writeStdOut(myString)

EGL quick reference System libraries

EGLQR 1.0