Code generator - Getting started

From Laja
Jump to: navigation, search

Getting started

Laja is used to generate files with varied content. To make this work you need to do three things:

  1. Installa Laja
  2. Create a template file (text file) in your favourite text editor
  3. Execute Laja

The Hello World example will show how it works.

Hello World

This example will produce the file hello.txt with the row Hello World!:

generate.laja hello.txt
#write "hello.txt"
Hello World!
Hello World!

  • Make sure Laja is installed.
  • Create the directory helloworld, e.g. C:\helloworld (Windows) or /usr/local/helloworld (Unix/Linux/Mac).
  • Create the file generate.laja in the newly created directory helloworld.
  • Edit generate.laja in a text editor to look like this:
#write "hello.txt"
Hello World!
  • In a shell or DOS prompt:
    • Go to directory helloworld
    • Type (followed by enter): laja

If everything works as expected, the following is printed out:

Reading file "generate.laja"
  Writing to file "C:/helloworld/hello.txt" - OK