Their purpose is dynamic memory management.
With new, you can select the required amount of memory during the script operation, and delete it with delete.
Example of a static selection
Цитата:
int var[25][50];
Example of a dynamic selection
CODE:
new int var[25][50];
Unlike static allocation, in dynamic it is possible to influence the size of arrays during script operation.
Example
CODE:
// To ensure that the script worked correctly, you must specify at least 26 to 51
new int var[formatsn (input ("Enter the row size"))][formatsn (input ("Enter the size of the column"))];
var[25][50]=12345;
messagebox (var[25][50]);
new int var[formatsn (input ("Enter the row size"))][formatsn (input ("Enter the size of the column"))];
var[25][50]=12345;
messagebox (var[25][50]);
Example of removing unnecessary memory
CODE:
new int var[100][200];
var[25][50]=12345;
messagebox (var[25][50]);
delete var;
messagebox (var[25][50]); // It will output a token because the var variable is removed
var[25][50]=12345;
messagebox (var[25][50]);
delete var;
messagebox (var[25][50]); // It will output a token because the var variable is removed
After the deletion, you can allocate a dynamic memory for the variable with the same name. For example, to increase the dimension of the array. But after deleting all the information in that array will be deleted.
CODE:
new int var[32][55];
var[25][50]=12345;
messagebox (var[25][50]);
delete var;
new int var[300][500];
var[125][250]=67890;
messagebox (var[125][250]);
var[25][50]=12345;
messagebox (var[25][50]);
delete var;
new int var[300][500];
var[125][250]=67890;
messagebox (var[125][250]);
Re-allocation of memory for a variable with a single name is possible only after its deletion.