A few basic examples

From Remeis-Wiki
Revision as of 16:31, 21 January 2020 by Grinberg (talk | contribs)
Jump to navigation Jump to search


This page is intended to give a few examples for students (mainly students working with Victoria, but the rest is welcome to use it!), who have little to no coding background.

A good convention is to always use filenames that end in .sl for your scripts. You can then run the script using isis filename.sl from the console. Always end your script with exit; so that it exists once it has finished running.

Let's write a simple scripts that says "hello world"!

print("hello world");
exit;

You can get more information on any command by starting isis (just type isis in the console) and entering help commandname, e.g., help print.

Now that we said hello to the world, we'll address some maths first.

Define a variable x that equals 7.5:

variable x;
x = 7.5;

Above, the first line defines an empty variable that does not yet have a type. The second line assigns this variable a value, 7.5, and automatically assigns it a corresponding type. In this case a double. A variable does not have to be a number:

variable y;
y = "hello";

creates a variable y and assigns it to the string "hello".

You can also define a variable and make it equal something in one go:

variable x = 7.5;
variable y = "hello";

Let's create a double array of length 12 and an integer array of length 12:

variable dd_ex = Double_Type[12];
variable ss_ex = Integer_Type[12];

If you print both arrays, you will see that dd_ex has entries that are all set to 0.0 and ss_ex entries that are all set to empty strings.