I need the if because if the element to be removed is the final element, it's just a matter of resizing the array to remove it. If I didn't do that, the loop would give an array out of range error for [x+1]
Unfortunately I have been simply unable to get my head around classes, so have to stick to basic mql4.
I need the if because if the element to be removed is the final element, it's just a matter of resizing the array to remove it. If I didn't do that, the loop would give an array out of range error for [x+1]
Unfortunately I have been simply unable to get my head around classes, so have to stick to basic mql4.
GumRai: I should have said that when x==as-1, it has to be dealt with individually as [x+1] doesn't exist
It doesn't have to be "dealt with individually". The for loop moves elements down. The end condition is such that is doesn't move beyond the last element. If it did, the for loop is wrong and the code breaks.
GumRai: I should have said that when x==as-1, it has to be dealt with individually as [x+1] doesn't exist
It doesn't have to be "dealt with individually". The for loop moves elements down. The end condition is such that is doesn't move beyond the last element. If it did, the for loop is wrong and the code breaks.
I'm not following you. The last element cannot be removed by the loop. How else can I remove it if it is not dealt with individually?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Array[x] = array[x+1] will work if the struct does not have any strings or dynamic arrays.
Thank you for the info WHRoeder
I need the if because if the element to be removed is the final element, it's just a matter of resizing the array to remove it. If I didn't do that, the loop would give an array out of range error for [x+1]
Unfortunately I have been simply unable to get my head around classes, so have to stick to basic mql4.
Thank you for the info WHRoeder
I need the if because if the element to be removed is the final element, it's just a matter of resizing the array to remove it. If I didn't do that, the loop would give an array out of range error for [x+1]
Unfortunately I have been simply unable to get my head around classes, so have to stick to basic mql4.
Yes, you are correct, I confuse myself sometimes.
I should have said that when x==as-1, it has to be dealt with individually as [x+1] doesn't exist
The for loop moves elements down. The end condition is such that is doesn't move beyond the last element. If it did, the for loop is wrong and the code breaks.
The for loop moves elements down. The end condition is such that is doesn't move beyond the last element. If it did, the for loop is wrong and the code breaks.
The last element cannot be removed by the loop. How else can I remove it if it is not dealt with individually?
The loop moves elements down. Period.
The resize removes that last element. What more is necessary?
Ah, I get you now.
Sorry, sometimes my brain dies :)