EGL (programming Language) - Code Examples

Code Examples

Program

An EGL Program part is a generatable logic part with one entry point. Each Program part contains a main function, which represents the logic that runs at program start up. A program can include other functions and can access functions that are outside of the program. The function main can invoke those other functions. Program functions are composed of a set of EGL statements, variables, and constants.

Program HelloWorld const GREETING string = "Hello, "; function main myName string = "John"; sayHello(myName); end function sayHello(name String in) SysLib.writeStdOut(GREETING + name + "!"); end end

Record

An EGL Record part defines a set of data elements. In this example, a record with the name CustomerRecord is defined with 6 fields.

Record CustomerRecord type BasicRecord customerNumber INT; customerName STRING; customerAddr1 STRING; customerAddr2 STRING; customerAddr3 STRING; customerBalance MONEY; end

EGL has a specialized type of record called SQLRecord that is used to exchange data with a relational database.

record Employee type sqlRecord { tableNames = ], keyItems =} EMPNUMBER string{ column = "EMPNO", maxLen = 6}; FIRSTNME string{ sqlVariableLen = yes, maxLen = 12}; MIDINIT string{ isSqlNullable = yes, maxLen = 1}; LASTNAME string{ sqlVariableLen = yes, maxLen = 15}; DEPT string{ column = "WORKDEPT", isSqlNullable = yes, maxLen = 3}; PHONENO string{ isSqlNullable = yes, maxLen = 4}; HIREDATE date{ isSqlNullable = yes}; end
  • In this example, the record Employee is bound to a table (or view) named Employee.

Service

An EGL Service part contains public functions meant to be accessed from other applications or systems. In this example, a service with two functions is defined.

package com.mycompany.services; service EmployeeService function getEmployees returns(Employee) records Employee; // define an empty array of records get records; // retrieve records from the database return (records); // return the records end function addEmployee(emp Employee in) returns (boolean) try add remp; return (true); onException (ex AnyException) return (false); end end end
  • In EGL, code is organized in packages (like Java (programming language))
  • The first function, getEmployees, returns an array of records populated from the records in a database.
  • The second function, addEmployee adds a new record to the database and returns a true or false depending on whether the record was added successfully.

RUIHandler

The main component of a Rich UI application is a Rich UI handler part. These parts are generated into JavaScript.

package com.mycompany.ui; import com.mycompany.services.Employee; import com.mycompany.services.EmployeeService; import dojo.widgets.DojoGrid; import dojo.widgets.DojoGridColumn; handler EmployeeView type RUIhandler { initialUI = [ grid ], onConstructionFunction = start, cssFile = "main.css" } grid DojoGrid { behaviors =, headerBehaviors =, columns = [ new DojoGridColumn { displayName = "First Name", name = "FIRSTNAME" }, new DojoGridColumn { displayName = "Last Name", name = "LASTNAME" }, new DojoGridColumn { displayName = "Salary", name = "SALARY" } ] }; function start svc EmployeeService { }; call svc.getEmployees returning to displayEmployees; end function displayEmployees(retResult Employee in) grid.data = retResult as any ; end end

Read more about this topic:  EGL (programming Language)

Famous quotes containing the words code and/or examples:

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)

    It is hardly to be believed how spiritual reflections when mixed with a little physics can hold people’s attention and give them a livelier idea of God than do the often ill-applied examples of his wrath.
    —G.C. (Georg Christoph)