# Programming techniquesEdit

## Getting startedEdit

Create file (f.e. MY_PROGRAM.TXT) with following text inside:

```a = 2 * 2
marker1:
print("HELLO PIXEL! \$a",-20,10,#FFFFFF)
frame
a = a + 1
goto marker1
```

And now you must execute this file with the pixilang enterpreter. After starting you will get simple animation with a text string "HELLO PIXEL" and incrementing number.

## Math operationsEdit

In Pixilang all numbers are signed 32-bit integers.

It's possible to use operations without the "=" symbol. Examples:

a+1 //increment variable a

a+1*2 //add (1*2) to a

## Conditional operationsEdit

Conditional operations have the following format: if SOME CONDITION { PIECE OF PROGRAM, THAT WILL BE EXECUTED IF CONDITION IS TRUE }

Examples:

```//If a > 4, then save 2 to variable b
if a > 4  { b = 2 }
```
```//If a equal to 4, then save 1 to variable b
if a = 1  { b = 1 }
```
```//If b not equal to 1, then put "HELLO" string to the screen
if b != 1  { print("HELLO",1,1) }
```
```//If b not equal to 1, then put "HELLO" string to the screen, else draw a dot
if b != 1  { print("HELLO",1,1) } else { dot(10,10) }
```

## Including external filesEdit

You can include external TXT files (user libraries for example). Example:

```INCLUDE "external filename"
```

External files will be included during compilation.

## Program optimizationEdit

Pixilang has great methods for optimization. Lets see an example.

This is the program:

```pixi( t, 44, 44 )
pixi( a, 44, 44 )
pixi( b, 44, 44 )
```

As you can see, there is a recurring command name (pixi) and recurring parameters (44,44). In this case you can use following optimization:

```pixi( t, 44, 44 )
.( a )
.( b )
```

WTF? :) It's simple. If the command name is ".", then the last executed command will be executed. If some parameters are missing, then they will be taken from the last executed command too.

Last modified on 16 October 2010, at 12:57