THE BASICS
Ok so first off when u open up scar you should see something like this
Program New;
begin
end.
This is the default scar page Now let me explain some things here
Program is the name of the script i usually just ignore this but dont delete or you may get some weird errors later on
Begin is pretty simple to understand it begins a procedure or function
End now this is a little more tricky there are two types of ends in scar
end.
and
end;
look at those
Do u see the diffrence?
Well if u dont then the top one has a . and the bottom one has ;
Now let me go into detail about them
The . will end the script there should only be one of those in your script
The ; is for all the begins in between
Now you have to actually have your script do something
Procedures and Function are the two most important parts of scripting
there is a diffrence however
With a procedure It can only do the task it cant return anything
but with a Function It can return either a
Now
A boolean is a true/false statement
for example run this script a couple times an notice iun the debug box at the bottom that that it writes true or false
Function Boolthing : boolean;
begin
if (random(2) = 1 ) then
result := false else
result := true;
end;
begin
writeln(booltostr(Boolthing));
end.
There are somethings in there that wont make any sence to u but we will go over those later
A boolean must always have a result or else its a waste of a function
A integer will return a number
for example run this script and look in the debug box again
Function Integerthing : Integer;
begin
result := random(99);
end;
begin
writeln(inttostr(Integerthing));
end.
did u notice in the debug box it wrote a number? Thats what an integer functin does it returns a integer
and integer needs a result to or else its waste
A String will return a Sequence of letters
For example run this in the scar window and look at the debug box
Function Stringthing : string;
begin
result := 'JP rules';
end;
begin
writeln(Stringthing);
end.
look in the debug box and youll see
Jp Rules (which he does)
Ok so if u have any more questions on those shoot me a PM
Now im gonna come back to the things i said i would
ok so random will take a random number with the number after it being the highest it can go so
begin
writeln(random(345);
end.
will return a number anywhere in between 0 and 344 cause scar count 0 as a number
now you can do random ranges
begin
writeln(randomrange(50, 100))
end.
it will return a number anywhere in between 50 and 100
now ill describe writeln to you
ok so writeln will write whatever you want in the debug box
run this
begin
writeln('your text here');
end.
play around with what the text says till your comfortorable with it
ok so now we have some things called repeats
repeats do what they say they do they repeat something
begin
repeat
writeln('Jps is the bassist for Mid-Flight Crisis');
until(false);
end.
this script will technically run forever
but to stop a repeat u need to have it repeat until something is acomplised
it could be a boolean returns true or false
or a integer is at a certain number
ill do an example of each of these
Boolean
Function Boolthing : boolean;
begin
if (random(2) = 1 ) then
result := false else
result := true;
end;
begin
repeat
writeln('itll go until the boolean returns true');
until(boolthing);
end.
Integer
Function Integerthing : Integer;
begin
result := random(99);
end;
begin
repeat
writeln('itll go until the Integer returns 57');
until(integerthing = 57);
end.
now we have got if then statements
if then statements are the cause and effect of scar you could say
the if will only move on to the then if the terms are complete
then is what scar should do if the terms are complete
the tricky thing is that it will only look 1 line under the then
soo
Function Boolthing : boolean;
begin
if (random(2) = 1 ) then
result := false else
result := true;
end;
this function will make the boolean return false if and only if the random number it chooses between 0 and 1 is 1
the same can be donw with booleans
Function Boolthing : boolean;
begin
if (random(2) = 1 ) then
result := false else
result := true;
end;
begin
if boolthing then
writeln('Done it');
end.
play around with those for a while see what works and what doesn't
there are things called while do loops these are "similar to repeat until loops except it will check first before looping. So if the condition is false initially, the loop will not be executed" (thank u zeph)
such as
Function Boolthing : boolean;
begin
if (random(2) = 1 ) then
result := false else
result := true;
end;
begin
while boolthing do
writeln('Look up Mid-Flight crisis on FB');
end.
there are things called for to do loops
wich will do a task for a certain amout of numbers
var
i : integer;
begin
for I := 0 to 3 do
begin
writeln('your awesome');
end;
end.
*side note that var is used to declare all the variables
now im going to go over the final thing in the basics
EXIT;
exits are used to exit a procedure or function
to use and exit simple put it anywhere in the function and it will exit it
begin
writeln('u see me');
exit;
writeln('but not me');
end.
Theres the end of the worst basics functions ever
ps its my first so shut up about how bad it is