This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

string array content checking...?


Back to topics list
avatar
153
CoenWillemse 2004.12.10 04:56 
Just wondering if there is any way of checking whether the contents of a single string variable or string array element has been assigned a value? A statement such as:

anyArray[10];
if (anyArray[6] == johnny) etc.etc

returns a "not initialized string in array" error. A 'Print(anyArray[6]);' command produces a "(NULL)" but I can't find any way of checking to see if a string array element (or string variable) has actually been assigned something. I've tried 'if (anyArray[6] == "")' , 'if (anyArray[6] == "NULL") and 'if (anyArray[6] == "(NULL)") but get the above mentioned error every time. Any ideas?
avatar
153
CoenWillemse 2004.12.10 05:13 
Just found an answer to my own question in the form of "StringLen()" - this returns 0 if the string has not yet been assigned a value.
avatar
4464
Slawa 2004.12.10 12:24 
NULL is just macro for 0. There is useless to compare some string with NULL. There is no way to determine exactly uninitialized string. You can analyze last error. see stdlib.mq4 it should be errors 4008 and 4009
avatar
153
CoenWillemse 2004.12.11 05:58 
Thanks for the info!
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets