RSS | Roulette Scripter Studio | Lesson 2 | Variables and Variable types
     
This tutorial was made by Silver
http://www.money-maker-machine.com/forum/profile/Silver/
 
2. Variables and Variable types. Printing text. (declaration of variables, assigning values to a variables, print the values of variables.)
 
I.
What are variables?

Variables are names given to blocks of the computer's memory. The names are used to store values in these blocks of memory.

Variables can hold values which are either numbers, strings or Boolean. We already know what numbers are. Strings are made up of letters. Boolean variables can have one of two values, either True or False.

Variables are names that allow you to reference stored values.

Rules for variables:

  • Must begin with a letter from the English alphabet.
  • Can be followed by alphanumeric characters (alphabetic characters and numerals) and possibly the underscore (_).
  • May not contain certain special characters, many of which have special meanings in RSS.
          ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / |


Several names are reserved in RSS as syntactical elements. You are not allowed to use these for your variables. These include but are not limited to:
and array begin case const div do downto else end file for forward function goto if in label mod nil not of or packed procedure program record repeat set then to type until var while with

II.
Using variables


Variables store values and information. They allow scripts to perform calculations and store data for later retrieval. Variables store numbers, names, text messages, etc.
RSS supports FOUR standard variable types, which are

Integer - store whole numbers
Real or Float - numbers which include decimal places
String - store characters
Boolean - also called logical variables, can only have one of two possible states - true or false


You must always declare a variable before you use it.
As we seen in Lesson 1 , that we have var section there. That's where we suppose to declare our variables.

Here is an example of how to declare a variable named start_balance :
var start_balance;
begin
end;


To assign a value to a variable we use := .
var start_balance;
begin
    start_balance:=120;
end;


You can create 2 or more variables if you separate their names with commas.
You can also create variables using another var statement.
When you assign a value to a string variable, you must put it between single quotes.
Boolean variables can only be assigned the values True and False.

var start_balance, stop_loss;
var str1, b, chip1;
begin
    start_balance:=120;
    str1:='Hello';
    b:=True;
    chip1:=0.10;
end;


Here we have start_balance - integer; str1 - string; b - boolean; chip1 - float.

III.
Printing variables or text
on the console is just as easy. If you want to print variables and text - use the command print .

var str1;
begin
    print('------');
    str1:='Hello';
    print(str1);
    str1:='World !';
    print(str1);
end;


var start_balance;
begin
    start_balance:=120;
    print('Start balance is');
    print(start_balance);
end;


or the same, using variable str1 :

var start_balance, str1;
begin
    start_balance:=120;
    str1:='Start balance is';
    print(str1);
    print(start_balance);
end;
 
Copyright © 2007-2011, All rights reserved to Money Maker Machine