# Scripting

1. If
2. Variables
3. Functions
4. Loops

## 1 If

<if test="1+1==2">one plus one is two</if>


becomes

one plus one is two

## 2 Variables

<def name="answer" value="4*10+2"/>


becomes

### 2.1 Predefined variables

• page_name: Scripting
• page_path: Scripting
• page_title: Scripting
• page_version: dbca1c32c8de9f1b6b0fe52554d9e606852e94aa
• page_next_version:
• page_previous_version:
• page_mime: text/x-creole
• page_modified: false

## 3 Functions

Functions can be defined with "def".

<def name="fac" args="n">
<if test="n>1">
<call name="fac" n="n-1" result="m"/>
<value of="n*int(m)"/>
</if>
<if test="n==1">1</if>
</def>

<call name="fac" n="20"/>


results in

2432902008176640000

<def name="fac2" args="n m">
<if test="n==1"><value of="m"/></if>
<if test="n>1"><call name="fac2" n="n-1" m="n*m"/></if>
</def>

<call name="fac2" n="20" m="1"/>


results in

2432902008176640000

## 4 Loops

Multiplication table:

1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100

Multiplication table #2:

1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100

Counter:

• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• 10