Tutorial topicsTutorial home
ELC language reference
Commenting your code
ELC app structure
An empty ELC program
Hello world
Functions
Defining variables
Function parameters
Using variables
Function return values
IF decisions
WHILE loops
FOR loops
Arrays of variables
Library functions
Game Tech - Depth & 3D
Game Tech - Shooting bullets
Dev Tech - How to debug
|
Empty ELC program
An empty ELC program does nothing. "So what's the point of that?" you may ask. Well it allows us to get some
of the basics out of the way and give us a foundation to build an app that actually does something without
introducing too much at once.
The empty program shown below is perfectly correct ELC in that you can run it using the tools here on the YOUSRC website,
but it won't do anything when it runs. It's still a good place to start though, so why don't you select the text below,
and copy it to a new app in your workspace? You can copy it using your left mouse button and dragging the mouse pointer
over the text, then use right mouse button and the "Copy" option to remember the text, then go to a new app in your
workspace and use the right mouse button and "Paste" to make this code appear there.
// ===================================================
// This is the most simple ELC program possible,
// although it does nothing
FUNCTION START()
{
}
|
|
Here you can see some comment lines starting with // which say a little about the ELC code and what
it does.
All functions are defined by using the FUNCTION keyword, followed by the function name, followed by a list of
parameters passed to the function when it is run.
The case (capital letters or lower case letters) of keywords, function names and variable names is important.
Note that the FUNCTION keyword, like all ELC keywords, is in capital letters. Function names and variable names
can be whatever case you like, but you need to remember the case you use. This function is called START, which
is different from start, or StArT!
Every ELC program must call its first function 'START'. This is the place where running your program starts. The
START function is passed no parameters so the parameter brackets are empty like this '()'. Parameters are things
that a function is given to use by the code that starts the function - don't worry we'll cover these later.
Just like other languages like Java or C, the ELC language uses curley brackets to show the start and end of chunks
of code. The code for the function is always contained between a '{' curley bracket and a '}' curley bracket. As this is
the simplest possible ELC program that does nothing, there are no ELC instructions between the opening '{' and
closing '}' of the function.
When you run this app the computer looks for the function called START, and then looks for the first instruction after
the open curley bracket '{'. As there are no instructions, just a close curley bracket '{', the app ends.
Okay, so now let's do something a little more interesting...

|