Hey321
2007-03-20 18:38:00
How To Use Variables, and Constants - By Hey321:
How To Use A Variable:
A Variable is something you could use as a failsafe, or for a progress report. You declare one by saying What it's called, (I'll use Example) and What the variable type is. Types i know of are String; Boolean; Integer; LongInt;( i believe), post if you know anymore. This is how you declare one:
Integer Variable:
That tells Scar the it's a Variable, and that it's called Example, and that Example is an integer (Positive or Negative number).
That tells Scar the Example is now Example + 1, or 0 + 1, 1 + 1 and so on. Then it tells Scar to Write In that as a String into the debug box. It's an Integer so that's why IntToStr (Integer To String) is there, to turn it into a string.
Boolean Variable:
A Boolean is something that returns True or False. It is used used like this:
If(InvFull)Then
Because InvFull is a Boolean.
You can do this to says it's true or false:
InvFull:=True or InvFull:=False.
To use it if it's NOT true then do this:
If(Not(InvFull))Then
Declare it like an integer variable but use Boolean; instead of Integer;
String Variable:
A String variable is something that you use to make a piece of writing visible, such as WriteLn('Hi!'); is using a string. To declare a string:
The same as Integer only use String; not Integer;. To use a String:
That outputs the text into the DebugBox, the reason it has ' around it is because that's what shows it that it's a string.
How To Use A Constant:
A Constant is a number THAT WILL NOT CHANGE! You are NOT able to change it without restarting the script. You declare on by saying what it's called, and what it's equal to.
First, we make a const:
Const tells Scar it's a Constant, and EndAt is our constant. Now, to put it to use:
Now, i just told Scar to Repeat the Example:Example+1 and WriteLn stuff until Example is equal to EndAt, or 10 because that's what EndAt is.
That's all for now!
How To Use A Variable:
A Variable is something you could use as a failsafe, or for a progress report. You declare one by saying What it's called, (I'll use Example) and What the variable type is. Types i know of are String; Boolean; Integer; LongInt;( i believe), post if you know anymore. This is how you declare one:
Integer Variable:
Program New;
Var// Tells Scar it's a Variable
Example: Integer; // Colon MUST be there, or you get errors, also, the semicolon must be to
Begin
End.
That tells Scar the it's a Variable, and that it's called Example, and that Example is an integer (Positive or Negative number).
Program New;
Var// Tells Scar it's a Variable
Example: Integer; // Colon MUST be there, or you get errors, also, the semicolon must be to
Begin
Example:=Example+1 //Tells Scar that Example has just gone up one
WriteIn(IntToStr(Example)) // Tells Scar to Write In Example as a String, and it was an Integer, which is why IntToStr is there
End.That tells Scar the Example is now Example + 1, or 0 + 1, 1 + 1 and so on. Then it tells Scar to Write In that as a String into the debug box. It's an Integer so that's why IntToStr (Integer To String) is there, to turn it into a string.
Boolean Variable:
A Boolean is something that returns True or False. It is used used like this:
If(InvFull)Then
Because InvFull is a Boolean.
You can do this to says it's true or false:
InvFull:=True or InvFull:=False.
To use it if it's NOT true then do this:
If(Not(InvFull))Then
Declare it like an integer variable but use Boolean; instead of Integer;
String Variable:
A String variable is something that you use to make a piece of writing visible, such as WriteLn('Hi!'); is using a string. To declare a string:
The same as Integer only use String; not Integer;. To use a String:
Program New;
Procedure HeyTutWrite(Text: String);
Begin
WriteLn(Text)
End;
Begin
HeyTutWrite('This is where i put the text! I made my own text writing procedure, cuz i was bored :P.')
End.That outputs the text into the DebugBox, the reason it has ' around it is because that's what shows it that it's a string.
How To Use A Constant:
A Constant is a number THAT WILL NOT CHANGE! You are NOT able to change it without restarting the script. You declare on by saying what it's called, and what it's equal to.
First, we make a const:
Program New;
Var// Tells Scar it's a Variable
Example: Integer; // Colon MUST be there, or you get errors, also, the semicolon must be to
Const // Tells Scar it's a Constant
EndAt=10;
Begin
Example:=Example+1 //Tells Scar that Example has just gone up one
WriteIn(IntToStr(Example)) // Tells Scar to Write In Example as a String, and it was an Integer, which is why IntToStr is there
End.Const tells Scar it's a Constant, and EndAt is our constant. Now, to put it to use:
Program New;
Var// Tells Scar it's a Variable
Example: Integer; // Colon MUST be there, or you get errors, also, the semicolon must be to
Const // Tells Scar it's a Constant
EndAt=10;
Begin
Repeat// Tells Scar to repeat it (Duh?)
Example:=Example+1 //Tells Scar that Example has just gone up one
WriteIn(IntToStr(Example)) // Tells Scar to Write In Example as a String, and it was an Integer, which is why IntToStr is there
Until(Example=EndAt)// Repeats the before code until Example is equal to EndAt
EndNow, i just told Scar to Repeat the Example:Example+1 and WriteLn stuff until Example is equal to EndAt, or 10 because that's what EndAt is.
That's all for now!