# Scriptol/Printable version

The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Scriptol

# The Scriptol Programming Language
## The Scriptol Programming Language
### A clean syntax

C++ syntax:
Scriptol syntax:
Scriptol doesn't need for semi-colon et end of statements. The end of line is also the end of statement unless several statements fits on a same line, in this case they are separated by semi-colons. If an instruction fits on two lines, the compiler recognizes the instruction.

### Objective design

Unlike C that was designed with limited hardware in mind, Perl that has added features day after day, and other languages that depends upon the fantasy of the author, Scriptol apply objectives rules, and it near the more used syntax in computer world, the xml one... Xml is tagged and has as C one-line syntax. Scriptol has one-line syntax, (see above) and is tagged:

### Universal operators

Some programming languages use the same operator for unrelated things. For example, The C programming language uses the "*" operator for both "deferencing" and "multiply". The C programming language uses the "&" for both "address-of" and "binary and".
Scriptol tries to avoid such confusion by making each operator mean something very similar in all the different ways it is used.
For example, the range operator " .. " is used:
* as the range in the "for" loop (see above).
* as an interval of an array or a dictionary (see array).
* as a range in an expression:

### Types from the real word

In the 1970s, C and Pascal invented types that were related to hardware: char, long, short, char *, float, etc...
Scriptol uses types related to the real word: text, number, integer, natural, real, array, dict, dir, etc...

### Readability

A complicated and unreadable part of C++ code...
may be replaced by a single and clear Scriptol statement.

# If Control Structure
## If Control Structure
### Common syntax

For a conditional process, the statement is a "if" keyword, followed by a boolean expression, a list of statements to execute or no, depending of the condition, and the "/if" keyword.
Introducing an alternative by the "else" keyword: when the condition is false, another list of statements may be processed.

### One-line structure

When the body of the structure is just one statement, and not another structure, the syntax may be shortened to only a single line.
If the statement is not a command as "print", "break", "continue" etc..., the "let" keyword is required.

### Composite if

The structure may be extended into a more powerful construct that is both an "if" and a "switch case" structure, even more advanced than the C counterpart since you can test any type of variable.

# For In
## For In
### Common syntax

The standard syntax assigns a variable with the elements of a range, and Scriptol writes a range as it is commonly written, with a double dot between two values (or variables).

### One-line syntax

If the body of the structure is only one statement, a simplified syntax is used.

### For in list

The for control structure may scan an interal as above, but also a text or an array.

# While Let
## While Let
### Common syntax

To increment a variable, Scriptol uses x + 1. This could not work in C and other languages.

### Infinite loop in C

The C and C-like languages (C++, Java, C#) leads easily into infinite loop. Here hare two simple examples.
Perhaps you have instantaneously noticed it (and perhaps no), but the construct is bad, due to the semi-colon after the condition!
Another example without the misplaced semi-colon:

# Scan By
## Scan By
### Common syntax

The scan control structure allows to parse one or several arrays, and to apply a process onto each element of the array(s).
scan a
/scan
The current element is denoted by an empty indice.
Example with two arrays:

### Scan with a function

You can apply instead a predefined function. The argument of the function is an element of the array.
If you use several arrays, the number of argument of the function must be the number of array.

# Xml or class
## Xml or class
### Common class

Scriptol is object-oriented and has classes and inheritance. Defining a class is easy. Example of a very simple class.

### Xml

But Scriptol has also xml. Defining a xml document is simple also.

### Using Xml

Classes are used directly or by creating an instance, and making reference to attributes or calls to methods.
Using Xml is not different. You can define how many instances of xml documents you want, and modify the content of each of them. The content of elements or attributes may be assigned, and elements and attributes may be added of removed.

### Importing xml document

Xml is mainly useful for performing processes on documents produced by various tools, word processors, spreadsheets, etc....
To load such documents, Scriptol integrates a sax parser. You have just to declare a xml document, load le xml file, and you can use the document as a class declared in the source.

### Iterator

Iterator on xml document is as iterator on array, plus the down and up methods. Iterator allows to parse an entire xml document or just sub-elements of of an element.