To understand this tutorial, you need a basic knowledge of scar. What Is A Variable? a variable is something that changes in the program variables can be used to store numbers or letters and even more. There are three main types of variables, Integers, Booleans, and Strings. With integers, the variable can store any whole number (a number without a decimal). Booleans have two modes and only two modes , those modes are true and false. Strings store letters and words and even sometimes numbers. How Do I Make A Variable? you can make all three types of variables in similar ways. Here are the ways Integers: Code (Text): program New; var FirstVariable: Integer; begin end. var tells the program that you are going to make a variable. after that, you put your variable's name. Variables must have a one-worded name. Then after the colon, you put the type of variable you want it to be. In this case, we want to make an integer, so i put integer after the colon. Booleans: Code (Text): program New; var Boolean1: Boolean; begin end. everything else is the same as in the integer, except after the colon it tells the program that we want this variable to be a boolean. Strings: Code (Text): program New; var string1: String; begin end. The same as the last two, except now i am telling scar that i want the variable to be a string. How Do I Use Variables? To use variables, you need to store something to it. here are a few examples. Integers: Code (Text): program New; var integer1: Integer; begin integer1 :=(random(15)); writeln(inttostr(integer1)) end. that script will get a random number between 1 and 15 and store it to 'integer1' then it will display the value of the integer. Boolean: Code (Text): program New; var boolean1: Boolean; begin case random(2) of 1: boolean1 :=true; 2: boolean1 :=false; end; if boolean1=false then writeln('no'); if boolean1=true then writeln('yes') end. this script will generate either 1 or 2 if its one, then the script will store true to boolean1, if its 2 it stores false to boolean1. String: Code (Text): program New; var string1 :string; begin; string1 :='Hi people.'; writeln(string1); end. This stores " Hi people" to a string1 and then displays string1. How Do I Store Something To A Variable? To store something to a variable, just tell it what the variable "=" if "variable1" was an integer i might do something like this Code (Text): variable1 :=13455 If it were a string, i might do Code (Text): variable1 :="Hello World" Finally, if it were a boolean, Code (Text): variable1 :=true How Can I Check A Variables Value? To check a strings value, all you have to do is put the string to a 'writeln' command like this Code (Text): writeln(string1); For integers, you do the same thin, just you need to convert it into a string like this Code (Text): writeln(inttostr(integer1)); For booleans, you need to do something a little more complex Code (Text): if boolean1 :=true then writeln('true'); if boolean1 :=false then writeln('false') I hope you liked my tutorial, my next one will be on procedures(i didnt have enough room in this one)
ok but i think you need to put at the top that you need to have basic scar knowledge to use also, i think it would be better if you had better code examples i say this without looking, but i suspect that you would get a better grasp of variables if you just read the standard tutorials (general ones) or better still downloaded the scar tut in vb saying that though,for a first tutorial that isn't bad although if i were to redo it i would talk about things like bitmaps needing variables and how you can use variables in clickmouse commands (after bitmaps or findcolors)
it is supposed to be a basic scar variables tutorial. i thought that if you knew how to use bitmaps and how to do codes more advanced than the examples i included, you would be beyond this tutorial.
i only understood about half of that. :? i know wat var means. its the function ure gonna use basiclly. then u put the name of the fuction & there r 3 but im still not sure wat they all do? can u give more examples?
it tells what they do, but i will explain it more. a integer stores only numbers so you use integers if you want to store anything that is a number for later use. a string holds sentences and words they can be used to hold bitmaps and basicaly anything else ans long as you put it in apostrophes 'like this'. booleans are very simple, they are either true or false, a lot like binary, where everything is either on or off, or like answering a yes or no question, no flexibility, either true or false. they are just used to store a value to a later place and are designed to change when necessary. i hope i answered all of your quenstions.