Results 1 to 3 of 3

Thread: I don't understand 'the basic types'

  1. #1
    Join Date
    Nov 2011
    Posts
    118
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default I don't understand 'the basic types'

    I'm kinda having a hard time understanding how 'the basic types' work. I'm having a hard time understanding booleans and integers.

    For example, what is this supposed to do in this piece of code? How does the script know, for example, that I will equal 3 or if I is another number? (from the simba tutorial)
    Simba Code:
    procedure Example;
    var
      i: Integer;
      tempString: string;
    begin
    end;
    What are strings supposed to do when called in a procedure?

    I also don't understand this piece of code on booleans:
    Simba Code:
    // Good
    var
      DoesBank: Boolean;
    How is it supposed to know if it's true or false? Can booleans only be true, or does it have to have both true and false statements?

    Sorry if this is too much to ask / if I'm not making sense. I'm just not understanding this. If anyone can reword the four basic types in laymen's terms, I would appreciate it.
    Thanks

  2. #2
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Austintheman View Post
    I'm kinda having a hard time understanding how 'the basic types' work. I'm having a hard time understanding booleans and integers.

    For example, what is this supposed to do in this piece of code? How does the script know, for example, that I will equal 3 or if I is another number? (from the simba tutorial)
    Simba Code:
    procedure Example;
    var
      i: Integer;
      tempString: string;
    begin
    end;
    Before you can use variables you need to declare them. This is what the var section in a program, procedure of function is for.

    Quote Originally Posted by Austintheman View Post
    What are strings supposed to do when called in a procedure?
    Strings are also a variable type. They essentially stores a sequence of one or more characters (A character can be number, letter or special character eg % @ etc)

    Quote Originally Posted by Austintheman View Post
    I also don't understand this piece of code on booleans:
    Simba Code:
    // Good
    var
      DoesBank: Boolean;
    How is it supposed to know if it's true or false? Can booleans only be true, or does it have to have both true and false statements?
    Once again, this is about declaring variables. It is used to tell the program that this variable DoesBank will be of a boolean type. Booleans can be either 'true' or 'false'

    Why all the need to declare variables before using them ? This is because the different variables are stored in memory in different ways. And so in a sense you need to 'warn' the computer when you introduce a new variable so it knows how to handle it.

    Quote Originally Posted by Austintheman View Post
    Sorry if this is too much to ask / if I'm not making sense. I'm just not understanding this. If anyone can reword the four basic types in laymen's terms, I would appreciate it.
    Thanks
    A variable / 'place holder' is like a pigeon-hole. And you need differently shaped pigeon-holes to store the different types of variables.

    The basic variable types are:
    integer - whole numbers
    extended - numbers with decimals
    boolean - only 'true' or 'false' (in computers terms it stores '1' or '0'
    string - a sequence of 1 or more characters

    No problems - this stuff can often take a while to understand.
    Last edited by NickMystre; 02-04-2012 at 07:35 AM.
    Ciao
    NM

  3. #3
    Join Date
    Nov 2011
    Posts
    118
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by NickMystre View Post
    Before you can use variables you need to declare them. This is what the var section in a program, procedure of function is for.



    Strings are also a variable type. They essentially stores a sequence of one or more characters (A character can be number, letter or special character eg % @ etc)



    Once again, this is about declaring variables. It is used to tell the program that this variable DoesBank will be of a boolean type. Booleans can be either 'true' or 'false'

    Why all the need to declare variables before using them ? This is because the different variables are stored in memory in different ways. And so in a sense you need to 'warn' the computer when you introduce a new variable so it knows how to handle it.



    This of a variable or 'place holder' as a type of pigeon-hole. And you need differently shaped pigeon-holes to store the different types of variables.

    The basic variable types are:
    integer - whole numbers
    extended - numbers with decimals
    boolean - only 'true' or 'false' (in computers terms it stores '1' or '0'
    string - a sequence of 1 or more characters

    No problems - this stuff can often take a while to understand.
    Thanks for this! I understand it now, haha. I guess I over thought it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •