1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Variables in Finer Detail - Tree, Deathader

Discussion in 'Code Snippets and Tutorials' started by Anonymous, Dec 27, 2006.

  1. Anonymous

    Anonymous Guest

    Variables in Finer Deails

    Created by Tree, and Deathader

    Say your computer had 100's and 100's of tiny little box's inside of it.They can be resized to fit ,but in this case data.

    [​IMG]

    Now to put data into these box's they must know where there going.So we name (Declare) a box's name so the data doesnt get lost.So the code we use to declare a variable is:

    Code (Text):
    1.  
    2. var nameofboxgoeshere,anothernameofboxgoeshere :integer;
    3.  
    So var means variable and the 'nameofboxgoeshere' is where you put what name you want to call a box.You can can name multiple box's in one line by using the ','.

    But now your wondering whats up with the:

    Code (Text):
    1.  
    2. :integer;
    3.  
    Well its telling the box what it can hold.I meen when packaging china dolls you must add bubble wrap ect.So it's pretty much allowing that type of data in.

    There are many different types of variables like Strings and booleans.But today we are just working on integers.These can hold most numbers and should do in most scripts to hold numbers.

    So:

    Code (Text):
    1.  
    2. var namehere :integer;
    3.  
    meens this in english:

    Code (Text):
    1.  
    2. The box will be a variable names namehere and will be able to hold numbers.
    3.  
    Now this goes for all types of variables,in any shape or form.

    Code (Text):
    1. var namehere :string;
    Now that type of variable,in that form can hold letters and anything else that isnt a digit.

    Code (Text):
    1. var namehere :Extended;
    This type functions as a extended version of Integer.These hold decimals.

    For example:
    Code (Text):
    1.  
    2. 1.5,2.9,5.9 and 6.7
    3.  
    Now the last one is the most interesting.This one can only have two outcomes.True or False.It is called a Boolean and is very usefull in if statments ect.

    Code (Text):
    1.  
    2. var namehere :Boolean;
    3.  
    Well now we have the basic declaring put down we move on to assigning data to the box's(Variables we shall now call them).The code is simple:

    Code (Text):
    1.  
    2. namehere := 0;
    3.  
    if the variable is a Extended or Integer,and

    Code (Text):
    1.  
    2. namehere := 'String';
    3.  
    if the variable is a string.The Boolean is obvius,ill let you think about that.Variables,unlike constants can change throughout the script while a constant cannot.

    Example script:



    Code (Text):
    1. program AutoTalker;//Sets the program name
    2. {.include si.scar} //Includes si.scar as a header/template(puts code in).
    3.  
    4. Var Done, WaitTime : Integer; //Declare VARIABLES,can be changed anytime
    5.  
    6. Const Say = ''; //Text to say //Declare and input data into a constant(not changable)
    7. Const Times = 10; //Times  //^^
    8.  
    9. procedure sayit;  //Procedure
    10. begin //START!
    11.  wait(1012 + Random(50));//Wait 1 minute and a bit + random set time.
    12.   SendKeys(Say + chr(13)); //Send keys of the text entered in 'say',press enter.
    13.   wait(WaitTime + Random(101)); //WAIT this time plus random
    14.  Done := Done + 1   //add one to done.
    15. end;
    16.  
    17. begin
    18.  Done := 0  //Set done to 0
    19.   repeat;  //start repeat
    20.    sayit; //do this function
    21.   until(Done = Times);  //until done loops is equal to times you want.
    22.  WriteLn( 'Thankyou for using this script' );//Closing message
    23. end.//The end
    Look through the script and other to grasp the idea. Be Always make comments '//'.


    To Hallandale: Your question is answered!

    VARIABLES (In ULTRA Fine Detail)

    Strings:
    Defining them

    Code (Text):
    1. var
    2. abc : string;
    when abc = your string variable name

    and use for this would be

    Code (Text):
    1. abc := 'hi'
    Integer:
    Defining them

    Code (Text):
    1. var
    2. i : integer;
    when i = your integer variable name
    these are all whole numbers positive or negative

    and use for this would be

    Code (Text):
    1. i := 1 + 2
    and you may add other integers into it like this

    Code (Text):
    1. i := i + 1
    or

    Code (Text):
    1. i := num + 23
    Operation Symbols:
    • Multiply = *
      Divide = /
      Add = +
      Subtract = -

    Extended:

    Code (Text):
    1. var
    2. i : Extended;
    when i = your extended variable name
    these are decimals that are positive and negative

    and use is

    Code (Text):
    1.  i := i + 3.57
    Boolean:

    Code (Text):
    1. var
    2. bln : boolean;
    use

    Code (Text):
    1. bln := True
    Constants:

    Defining them

    Code (Text):
    1. Const
    2. abc = 'hi';
    3. i = 1;

    Happy Scripting =)
     
  2. Hally

    Hally Level IV

    Joined:
    Nov 16, 2006
    Messages:
    1,184
    Likes Received:
    34
    Should read

    Code (Text):
    1.  
    2. i := i + 1
    3.  
    Right?
     
  3. Anonymous

    Anonymous Guest

    oh, thanks! I'll change that now :)