It is very important to understand the principle why you have to set the length of an array. It will teach you a bit about memory and how to use it. This is important because in Lape there isn't any check for array length and you will just get a value random from you memory, or even worse you set the value of a random piece of your memory.
Image your memory as a cupboard without drawers. When you create a variable you will create a drawer with the exact size of what you want to put in the drawer and if there is still space in the cupboard you will place it there. The variable you use in your script is a reference to that drawer. For a integer this drawer is exactly 32 bits big. Or a Byte which is 8 bits. And a Boolean which is 1 bit.
When you create your own type you will go full hardcore engineer mode. You will design your own custom drawer. You will only create the building plans of the drawer, not the drawer itself. So if you want to use it you will still have to create it.
type Dog =
record //Creating the building plan
size, smell, gender: Integer;
end;
var a: Dog;
//Creating the drawer and placing it in the cupboard
a.size := 5;
//Putting stuff in the drawer
a.smell := 99999;
a.gender := -1;
An array is harder, how big is that drawer? Well that depends of course, how much you want to put into it. So a few tricks were created. Now I will only discuss one. You start with creating an array drawer. This drawer basically contains; "The following x drawers have the size of typeX".
var b: Array of Dog;
Note that there still isn't any drawer to store your dogs in. That variable doesn't contain any dogs. So to make use of it we have to create dog drawers like we did before. Let's say we got four dogs.
setLength(b, 4); // Creating four dog drawers
b[0].size = 3; //Putting stuff in the drawers
b[0].smell := 9999;
etc...
Now when you call b[0] you will look into drawer b, which tells where to find the correct drawer. If you didn't set the Length it will give an error in pascalscript, in Lape it will give you a random drawer out of your memory, that can contain anything. This is dangerous if you put random stuff in it, simba could crash.