Smarter Child
2009-09-02 04:01:43
Variables!
Hi welcome to my really small tutorial on variables
What are variables?? Variables are like containers, you can put things in variables (containers).
Lets start by learning how to declare a variable:
Code:
[LEFT]program Variables;
var //this is a global call of variables, which means its not in a procedure or function
//and can be used anywhere in the entire script
Procedure Blah;
begin
end;
begin
end.
[/LEFT]
So thats the word, you use to start declaring the variables,
Most common Types*(thx richie :)):
Integers - These are whole numbers, negative or positive: -1 or 637387
Strings - These are words or letters: HALLELUJAH
Booleans - These are like results, true or false [yes or no]
Extended - These are numbers extended pass the decimal point: 456.33 or 0.222256
So that's what variables can be declared as, the name of the variable can be anything for example"
Code:
[LEFT]Var
smarterchild: integer;
[/LEFT]
When to use variables?
Well variables is an aspect of scripting that will come up a lot, you cannot avoid them totally :p.
Examples of variables:
- Coordinates: x/y are very common as integers to hold coordinates
- Colors: These are integers
Some basic usage of variables:
Code:
[LEFT]program New;
var
s: string; //declares s as a string
begin
s := 'HELLO WORLD'; //assigns 'HELLO WORLD' to the s variable
cleardebug; //clears debug box
Writeln(s); //writes s aka 'HELLO WORLD' into the debug box
end.
[/LEFT]
Code:
[LEFT]program New;
var
x, y: integer;
begin
if FindColor(x, y, 436737, 1, 2360, 80, 2337)then //if it finds the color it does below
MoveMouse(x, y); //moves the mouse to the x/y position
end.
[/LEFT]
Ce:
[LEFT]program New;
var
deci: extended; //deci is an extended value
RoundedNumber: integer; //roundednumber is an integer value
begin
deci := 0.2222; //assigns deci to 0.2222
RoundedNumber := Round(deci); //assigns RoundedNumber to Round(deci) which results as an int
Writeln('Rounded Number: ' + IntToStr(RoundedNumber)); //Writes in rounded number by //converting the RoundedNumb integer value to a string
//THIS EXAMPLE IS A LITTLE HARD, SO IF U DONT UNDERSTAND ITS ALRIGHT
end.
[/LEFT]
Thanks for reading, i hope you now know how to use variables ;).
:).
~~ END ~~
Hi welcome to my really small tutorial on variables
What are variables?? Variables are like containers, you can put things in variables (containers).
Lets start by learning how to declare a variable:
Code:
[LEFT]program Variables;
var //this is a global call of variables, which means its not in a procedure or function
//and can be used anywhere in the entire script
Procedure Blah;
begin
end;
begin
end.
[/LEFT]
So thats the word, you use to start declaring the variables,
Most common Types*(thx richie :)):
Integers - These are whole numbers, negative or positive: -1 or 637387
Strings - These are words or letters: HALLELUJAH
Booleans - These are like results, true or false [yes or no]
Extended - These are numbers extended pass the decimal point: 456.33 or 0.222256
So that's what variables can be declared as, the name of the variable can be anything for example"
Code:
[LEFT]Var
smarterchild: integer;
[/LEFT]
When to use variables?
Well variables is an aspect of scripting that will come up a lot, you cannot avoid them totally :p.
Examples of variables:
- Coordinates: x/y are very common as integers to hold coordinates
- Colors: These are integers
Some basic usage of variables:
Code:
[LEFT]program New;
var
s: string; //declares s as a string
begin
s := 'HELLO WORLD'; //assigns 'HELLO WORLD' to the s variable
cleardebug; //clears debug box
Writeln(s); //writes s aka 'HELLO WORLD' into the debug box
end.
[/LEFT]
Code:
[LEFT]program New;
var
x, y: integer;
begin
if FindColor(x, y, 436737, 1, 2360, 80, 2337)then //if it finds the color it does below
MoveMouse(x, y); //moves the mouse to the x/y position
end.
[/LEFT]
Ce:
[LEFT]program New;
var
deci: extended; //deci is an extended value
RoundedNumber: integer; //roundednumber is an integer value
begin
deci := 0.2222; //assigns deci to 0.2222
RoundedNumber := Round(deci); //assigns RoundedNumber to Round(deci) which results as an int
Writeln('Rounded Number: ' + IntToStr(RoundedNumber)); //Writes in rounded number by //converting the RoundedNumb integer value to a string
//THIS EXAMPLE IS A LITTLE HARD, SO IF U DONT UNDERSTAND ITS ALRIGHT
end.
[/LEFT]
Thanks for reading, i hope you now know how to use variables ;).
:).
~~ END ~~