ArrayResize doesn't work!

 

result 


can someone help?

   double tab[];
   Print(ArrayResize(tab,30));
   Print(ArraySize(tab));
   for(int i=1;i<=30;i++)
      tab[30-i]=i....;
 
Issam Kadhi:

 


can someone help?

Please, insert code correctly: when editing a post, click   Code and paste your code in the popup window (the first time I edited your post and inserted the code correctly)
MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 
Vladimir Karputov #:
Please, insert code correctly: when editing a post, click    and paste your code in the popup window (the first time I edited your post and inserted the code correctly)

these are pics not codes, i didn't write codes manually, i did pics for its.

 
Shouldn't this be (i < 30) ??

for(int i=1;i<30;i++)
 
Dominik Christian Egert #: Shouldn't this be (i < 30) ??

I saw that too, but then noticed he is correcting for it ...

tab[30-i]
 
Issam Kadhi: can someone help?

ArrayResize is failing, so check for the error code to see why.

double tab[];
ResetLastError();
int nResult = ArrayResize( tab, 30 );
if( nResult <= 0 )
   PrintFormat( "Error %d, Result %d — Unable to resize array", _LastError, nResult );
int nSize = ArraySize( tab );
for( int i = nSize - 1; i >= 0; i-- )
   tab[i] = i ...;
 
Fernando Carreiro #:

ArrayResize is failing, so check for the error code to see why.

done

done.

 
Wasn't sure about the order in for(), mostly I use while() which has a different approach.

So I was guessing, it might turn out to be 30-31.

But error 4029 shows a totally different problem.
 
Dominik Christian Egert #:
Wasn't sure about the order in for(), mostly I use while() which has a different approach.

So I was guessing, it might turn out to be 30-31.

But error 4029 shows a totally different problem.

bro, 

ArrayResize returning -1, we didn't reach the loop.

 
Issam Kadhi #: bro, ArrayResize returning -1, we didn't reach the loop.

Then the example code you have shown is not the true problem. The problem will be with your real code which you have not shown.

Something else is causing an issue. Only by showing your real code will we be able to see what the actual problem is.

PS! Please don't call people "bro" if you are not actually friends. For most native or well-versed English speakers, it is actually a bit off-putting.

 
Fernando Carreiro #:

Then the example code you have shown is not the true problem. The problem will be with your real code which you have not shown.

Something else is causing an issue. Only by showing your real code will we be able to see what the actual problem is.

PS! Please don't call people "bro" if you are not actually friends. For most native or well-versed English speakers, it is actually a bit off-putting.

in the code, you can see that the array is defined there, i didn't use it in other parts in the code.

the array is new, but it is giving the error.

nothing to do with the other parts of the code.

i even modified the name of the array but same error.

i am even not using any library or include.

i wish that mt4 didn't become fake like mt5, i think you know the stupid mt5 compilator and even platform, but if same developers doing both, this is the reason.

i hope i'm wrong.

Reason: