tol64: Try to study this or that topic as you need it. Once you get to a point in your system where you need certain "levers" (functions), then start experimenting with them. I found that this method of studying (in my case) works quite well))).
Yes, I do so, I can't get out of inite with input parameters :) and without arrays it will be quite hard to go further, tested on 4.
Remove the value from the array when declaring it. It must be like in the help:
string result[];
And you won't have any errors. As I understand it, the entire string specified in to_split variable is placed in the array, and then substring extraction goes on.
Remove the value from the array when declaring it. It must be the way it is written in the help:
And there will be no errors. As far as I understood, the entire string specified in the to_split variable is placed in the array and then substring extraction is performed.
It's clear. Only this is a potential pitfall - I actually encountered this error in my code and it works - with an error.
For example, here is the help text for CopyBuffer
Если необходимо копировать заранее известное количество данных,
то лучше это делать в статически выделенный буфер,
чтобы избежать излишнего перевыделения памяти.
Where is the logic? I mean, what is the difference with StringSplit?
And if you make all arrays dynamic, you will run out of memory.
Upgr ArrayResize with zeroing is a variant, of course, but I don't like it.
In your example, the problem is that the StringSplit() function itself takes care of the required amount of memory in the array passed as a parameter.
So it turns out that a static array works (if there is enough memory) but causes an error because people try to re-partition it.
Try the static and distributed dynamic arrays, and you'll see:
voidOnStart()
{
//---string to_split="мама_мыла_раму"; // строка для разбивки на подстрокиstring sep="_"; // раздедитель в виде символаushort u_sep; // код символа разделителяstring result[3]; // массив для получения строк//ArrayResize(result,3); //--- получим код разделителя
u_sep=StringGetCharacter(sep,0);
//--- разобьем строку на подстрокиint k=StringSplit(to_split,u_sep,result);
Print("GetLastError=",GetLastError()); // это я добавил чтоб видеть есть ли ошибка
//--- выведем комментарий PrintFormat("Получено строк: %d. Использован разделитель '%s' с кодом %d",k,sep,u_sep);
//--- теперь выведем все полученные строкиif(k>0)
{
for(int i=0;i<k;i++)
{
PrintFormat("result[%d]=%s",i,result[i]);
}
}
}
Yes, if you remove up to 3 letters
That's not the point.Try to study this or that topic as you need it. Once you get to a point in your system where you need certain "levers" (functions), then start experimenting with them. I found that this method of studying (in my case) works quite well))).
Then we wait for a response from more competent comrades.))
Wait :)
Better yet, don't wait.) Keep experimenting.))
Remove the value from the array when declaring it. It must be like in the help:
string result[];And you won't have any errors. As I understand it, the entire string specified in to_split variable is placed in the array, and then substring extraction goes on.Better yet, don't wait.) Keep experimenting.))
Remove the value from the array when declaring it. It must be the way it is written in the help:
And there will be no errors. As far as I understood, the entire string specified in the to_split variable is placed in the array and then substring extraction is performed.It's clear. Only this is a potential pitfall - I actually encountered this error in my code and it works - with an error.
For example, here is the help text for CopyBuffer
Where is the logic? I mean, what is the difference with StringSplit?
And if you make all arrays dynamic, you will run out of memory.
Upgr ArrayResize with zeroing is a variant, of course, but I don't like it.
As I understand it, the entire string specified in the to_split variable is placed in the array, and then the substring is extracted.
In your example, the problem is that the StringSplit() function itself takes care of the required amount of memory in the array passed as a parameter.
So it turns out that a static array works (if there is enough memory) but causes an error because people try to re-partition it.
Try the static and distributed dynamic arrays, and you'll see:
Try the variant with static and distributed dynamic arrays and it will become clear:
To try the dynamic array, just uncomment ArrayResize(result,3); ? If so, there will be a warning on compilation:
To try a dynamic array, just uncomment ArrayResize(result,3); ? If so, there's a warning on compilation:
is this an unsolvable problem ? make it dynamic.
In your example, the problem is that the StringSplit() function itself takes care of the required amount of memory in the array passed as a parameter.
This is why a static array works (if there is enough memory), but causes an error because people try to re-partition it.
So, can we use StringSplit() with static arrays or not?
If you can, there shouldn't be an error if there is enough memory. If not, it shouldn't work.