Kibor Bot Autoclicker » Kibor - Integrated development environment for bots » About Kibor » Version 5.38 New and delete operators for dynamically allocating and clearing memory

Страниц (1): [1]
 

1. Kibor - 23 Июля, 2018 - 06:27:00 - перейти к сообщению
In this version, the operators new and delete
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]);


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


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]);


Re-allocation of memory for a variable with a single name is possible only after its deletion.

Powered by ExBB FM 1.0 Final