Try to use this code for your needs.
int start() { string str="qwerty,123345,ytrewq,54321"; int char[],pos; string stri[]; for(int i=0;i<StringLen(str);i++) { if(StringGetChar(str,i)==44)//code "," { pos++; ArrayResize(char,pos); char[pos-1]=i; //Print (i); } } ArrayResize(stri,pos+1); for(i=0;i<=pos;i++) { if(i==0)stri[0]=StringSubstr(str,0,char[i]); else if(i==pos)stri[i]=StringSubstr(str,char[i-1]+1); else stri[i]=StringSubstr(str,char[i-1]+1,char[i]-char[i-1]-1); Print("i - ",i," str - ",stri[i]); } return(0); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm using FileWriteArray/FileReadArray to store some data that I need. But I'm stoing the data as a comma-delimited string because I need to be able to store multiple values.
When I get the string back from my file, how can I parse it? I started this project assuming that there would be a "split" type of function found in other languages but I cannot find the equivalent in MQL. I know I could do this with a combination of substrings and what-not but there has to be an easier way.
How can I parse a comme-delimited string in MQL?