SRL Archive - OSR Help

I don't understand 'the basic types'


Austintheman

2012-01-31 22:36:49

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)
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:
// 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 :redface:

NickMystre

2012-01-31 23:07:13

From: Austintheman
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)
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.

From: Austintheman
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)

From: Austintheman
I also don't understand this piece of code on booleans:
// 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.

From: Austintheman
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 :redface:


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.

Austintheman

2012-02-01 21:04:34

From: NickMystre
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 :duh: