- Read the next two.
-
Perhaps you should read the manual. StringFormat
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
William Roeder....i will say ....lets wait may be ...some one will give a solution to the code
any note could be useful ....
your code is bit of a mess, you probably need to nail some of the basics before starting with files etc.
that said I have modified the file part of your code so that it works, not how I would write it myself but this way you understand your starting point.
Look carefully at the changes,
some further pointers:
You do not need a multi-dimensional array to store the items in, you could just use two pointers or pointer and pointer+1 but however you decide you should only read 1 item from the file in each loop otherwise you may run into the end of the file, (unless you are going to do a further file check inside the loop before reading a second item)
You don't need to specify the length of the item to be read in a CSV file the separator defines that
You need to maintain the size of the destination array to make sure it does not overflow.
If you are only reading in integers/numbers then you could use a more efficient file format.
extern string FileName = "two.csv"; void start() { int handle=-1; int count = 0; string data[99]; handle=FileOpen(FileName,FILE_CSV|FILE_ANSI|FILE_READ,",",CP_ACP); if ( handle<0) { Print("File "+FileName+" not found."); } else Print("File "+FileName+" successfully open."); while(!FileIsEnding(handle)) { data[count] = FileReadString(handle); Print(count + " = " + data[count]); count++; } FileClose(handle); return; }
- www.mql5.com
your code is bit of a mess, you probably need to nail some of the basics before starting with files etc.
that said I have modified the file part of your code so that it works, not how I would write it myself but this way you understand your starting point.
Look carefully at the changes,
some further pointers:
You do not need a multi-dimensional array to store the items in, you could just use two pointers or pointer and pointer+1 but however you decide you should only read 1 item from the file in each loop otherwise you may run into the end of the file, (unless you are going to do a further file check inside the loop before reading a second item)
You don't need to specify the length of the item to be read in a CSV file the separator defines that
You need to maintain the size of the destination array to make sure it does not overflow.
If you are only reading in integers/numbers then you could use a more efficient file format.
Hi it.s me abd- ....am using smart phone now and forget my old password and the orignal registration info(even my email pass) ...am at hospital now but i dicide to make a new user and MUST reply to Paul Anscombe and say THANKS very much....recently i cannot test the code using smart phone but later i will do....thanks very much and modarater sorry for using a new user ...
your welcome
FileReadString from csv reads only to the first delimiter: https://www.mql5.com/en/docs/files/filereadstring
You should have 8 data[count][x] lines with x from 0 to 7.
- www.mql5.com
FileReadString from csv reads only to the first delimiter: https://www.mql5.com/en/docs/files/filereadstring
You should have 8 data[count][x] lines with x from 0 to 7.
that's not necessary the code I provided works perfectly fine and read string reads the next string from the current file pointer.
FileReadString from csv reads only to the first delimiter: https://www.mql5.com/en/docs/files/filereadstring
You should have 8 data[count][x] lines with x from 0 to 7.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi....am trying to read some values from a CSV file into mt4 using a simple code
my CSV file is at \MQL4\Files directory
and containe one line of data
my code only read the first tow value 298 305 and show them on print or comment (either i want to use).
how to make the code show the other values from the Csv file?
one more thing....how could i assign the print value or comment value to
ObjectCreate
Function if i want to show any of the values on the screen
thanks in advance
code