In this lesson, you will learn how to create and run a simple EGL program.
program helloMain type BasicProgram
Moving down the elemental structure of the EGL application, a program falls below a package, representing, in most cases, the solution to a single business problem. EGL has different types of programs, of which BasicProgram is the simplest.
Note also that the name of your program must match the name of the EGL file, minus the .egl extension. If you named your file helloMain.egl, your program must be named helloMain. In most cases, EGL is not case sensitive, but for programs (and other major types of EGL part called generatable parts), the case of the program name must match the case of the file name.
function main()
A
program consists of one or more functions, which are comparable to
atoms—they are the fundamental building blocks of EGL logic.
All function declarations are followed by parentheses, which in some
cases hold data passed in or out of the function. Every program must
have one and only one main() function.writeStdOut("Hello, Cleveland!");
Here
the function performs its actual work. In this case, it is calling
another function, one named writeStdOut(). This function
exists in a library named sysLib, a system library
of functions that you get free with EGL. You can call its functions
from any other EGL function, and most of the time (you will learn
about the rare exceptions later) you will not need to explicitly point
to the library for EGL to be able to find the function. The writeStdOut() function takes a single argument (the piece of data in the parentheses). In this case the argument is a literal string of characters, and writeStdOut() has the job of displaying this string, on a line by itself, wherever EGL thinks the standard output should go. By default, that would be in the workbench's console window. That window is associated with one of the tabs in the lower right of the default workbench screen.
The line of code, which represents a complete thought, ends with a semicolon.
end
EGL is smart enough to figure out
that this end statement refers to the main() function
declaration, so it should match the indentation of that declaration.
Other languages use braces or other contrivances to mark blocks of
code; EGL, being closer to natural language, simply matches the word end with
the beginning of a block.end
Again, EGL knows this end refers
back to the program declaration, so it matches the
indentation of that opening declaration.In the Project Explorer view, you can now see the file Hello\Java Resources\hello\helloMain.java. Double-click the file name if you want to display the contents in the editor and see the considerable quantity of Java code that resulted from your one-line EGL function.