Previous | Next

ESPranto basic file layout

Every ESPranto file adheres to a basic layout. For example, let’s have a look at the text in the program from the previous exercise.
//Right-click to download this code

import "tagtiles.esp"

main = (
  drawShape (Cell (3, 4)) yellow;
  drawShape (Rect (1, 11) (2, 2)) green;
  drawShape (Line (1, 1) (12, 1)) red
)

Comments

A first thing to note, is that the compiler ignores all text following //. This is useful for writing comment texts that you intend for human readers, and not for the compiler. In our case, we write the download link as comments, so that if you would pase the download link in the text file as well, it would still compile.

Importing libraries

Notice the line reading
import "tagtiles.esp"
The file tagtiles.esp is a file that came with your ESPranto installation. It contains a collection of macros for you to use. Such a file is called an ESPranto library. The macros that we used thusfar, such as drawShape, Cell, Rect, Line are all defined in tagtiles.esp. When you import tagtiles.esp, you can use all those macros in your own applications.

In your applications, you can also import other libraries than only tagtiles.esp. However, for creating basic applications, you only need tagtiles.esp: it provides all the macros that you need to write basic applications.

The main macro

You may have noticed that all applications have a line that reads main = (...). When you run an ESPranto application, it starts by executing the commands that you wrote between the brackets after main =.

Previous | Next
Serious Toys logo -  tangible inspiration without limitation