A basic structure, array

The simplest at start, but we'll see it can be used to store complex data representation.

array a = [ 1, 2, 3 ]
This is an array to which we assign a literal array.
You can assign a constructor:

array a = array( 1, 2, 3 )

Les tableaux sont des classes virtuelles en Scriptol et ont des méthodes, comme les autres types: text, dict, file, dir, etc...

Arrays are virtual classes in Scriptol with methods, like other types: text, dict, file, dir, etc... Elements can be stacked, shifted, inserted, removed.

var x = a.pop()
print x

To parse array, you can use iterators or for ... in control structure.

for var x in a
   print x         // prints the currently pointed out element.

Portions of tables can be replaced, inserted, deleted, by defining a range.

print a[x .. y]       // displays a sub-array.
a[.. y] = b[1 .. 3] // replaces range 0 to y in array a, from 1 to 3 in b.

nil is assigned to an interval to remove it from the table.

a[2 .. 8] = nil        // removes items in the range 1..8.

Class and object

We can define a class as an array of properties and method, and use it like a model to objects that are instances. The link between array and classes is especially clear in C++, we can define static structures having methods, while in JavaScript, objects are arrays in which you assign a function to a property, which is similar to a method. In JavaScript, instance is replaced by a copy of the object made through an assignment.

Example of a very simple class in Scriptol:

class Car
  int speed
  void getSpeed()
     ... some statements ...
  return speed   

A class allowsd to describe a real world object and represent its behavior with methods. But they are static objects, predefined once and for all. To get a better representation of the world such as objects are dynamic, we must add properties and methods in real time, because objects may change.

XML, the most dynamic representation

Scriptol uses XML as the integrated representation of objects, and that goes beyond what is offered by object orientation.

An XML object is infinitely expandable. It can be changed dynamically. It is also extremely simple to describe.

<car speed= 10 wheels = 4>	
   <passengers num = 5>
       "Clara, Charly, Corinna, Cyril, Cecilia"

XML object are translated into associative arrays in the target language.

The document above becomes in JavaScript:

var car = {
"speed": 10,
"wheels: 4,
"passengers: {  
    "number": 5
    "data": "Clara, Charly, Corinna, Cyril, Cecilia"

The XML structure has an equivalent form in JavaScript as embedded objects, that can be saved as a file in JSON format. JavaScript has all the possibilities of advanced and dynamic representation of data, but in a rudimentary and difficult to read syntax. Other languages ​​do not even have those opportunities.

JSON does the same in JavaScript. Everything is done with an XML declaration as above, we can do it with a JSON document. Only change the syntax and conventions of writing.
JSON is a way to serialize (copy to a file) a JavaScript array.

Programs often use more complex structures such as graphs, but they are described from simpler structures or elementary objects.