Hi
I want to read a newsFile, it exists and can be opened, but it is read only about 20%??
Why the hell does it read less than 20% of that file - information is missing.
BUT this happen only if I install that indi fresh on the chart, if I open the Edit the paramter window everything was perfect.
My special problem is if I call this indi via iCustom(..) I can't 'edit' its parameters..
What can I do?
Now I have inserted
and the indiread only 4k again and again..
Any hint?
Gooly
It seems to me you are trying to read the entire file into a single string variable . . .
Functions working with strings try to increase internal buffer for string processing. Initial buffer size is 4K. Maximal buffer size depends on free memory.
hmm, it could be that especially after it works perfectly after a re-start..
Thanks anyway!
Gooly
Well, the problem is pretty annoying, because at least something is read but of course in many cases (NOT every time!) something is wrong and there you start looking.
Especially after editing the parameters (that have nothing to to with the problem you see!) everything is fine - but an EA can't 'edit the parameters' and restart its EA!!
But here is my code that solves so far the problem:
fHdl = FileOpen(sFileName, FILE_BIN|FILE_READ); szFile = FileSize(fHdl); GetLastError(); // elim prev Errors sData = ""; // re-ini this var. string strAdd=""; // sData = FileReadString(fHdl,szFile); Print("File ",szFile," opened, should be okay sizeData: ",StringLen(sData)); if ( StringLen(sData) < szFile ) { if (!FileSeek( fHdl, 0, SEEK_SET)) Print("FileSeekError: ",GetLastError()); strAdd = sData; int m,mm = szFile/StringLen(sData) + 1;m=mm; while(m>0) { strAdd = strAdd + sData; m--; } strAdd = FileReadString(fHdl,szFile); sData = strAdd; Print("File rep:",mm," szF:",szFile," szData:",StringLen(sData), " szCompare: ",(StringLen(sData) < szFile)," ",GetLastError(), " szAdd: ",StringLen(strAdd)); } if (fHdl > 0) FileClose(fHdl);
this prints:
2013.11.06 14:27:08 FFCalv4 NZDUSD,M1: File 26770 opened, should be okay sizeData: 4095
2013.11.06 14:27:08 FFCalv4 NZDUSD,M1: File rep:7 szF:26770 szData:26770 szCompare: 0 0 szAdd: 26770
initial size (and read) 4095 so use the size increase loop.
But it is still very annoying,
Gooly
Well, the problem is pretty annoying, because at least something is read but of course in many cases (NOT every time!) something is wrong and there you start looking.
Don't ask me!
If you read my code you can see that after the first FileRead:
sData = FileReadString(fHdl,szFile);
only 4k were read while 26k should have been read: 2013.11.06 14:27:08 FFCalv4 NZDUSD,M1: File 26770 opened, should be okay sizeData: 4095
So I blow up the size of sData (with the help of strAdd) to more that the FileSize and now I can read the file totaly.
This way is NOT my choice!
Of course it can be done with less code, but I want to see the the various values.
Gooly
Don't ask me!
1) This is the least time and code-line consuming way,
2) I did not expect to have such problems,
3) clear structure that separates parsing and file reading.
Gooly
PS: if you have nice code to read and parse I'll have a look at it.
Sorry, I have done some work with string parsing and manipulation but nothing along the lines of what you are looking at . . . don't you have a carriage return or linefeed you can use and have one string per line ?
Well,
if you use the mt4-file-finctions you ONLY can read x-bytes.
The carriage-return is just one char among the others - your editor simply does s.th different.
So if you read a bit of the file you don't know where is the and of you bit. May be it ends right in the middle of a token you are searching for.
To manage all this ... I think you can imagine..
Or you have to use the file-stuff of Windows as well a big portion of extra code.
Well,
if you use the mt4-file-finctions you ONLY can read x-bytes.
The carriage-return is just one char among the others - your editor simply does s.th different.
So if you read a bit of the file you don't know where is the and of you bit. May be it ends right in the middle of a token you are searching for.
To manage all this ... I think you can imagine..
Or you have to use the file-stuff of Windows as well a big portion of extra code.
- 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
I want to read a newsFile, it exists and can be opened, but it is read only about 20%??
Why the hell does it read less than 20% of that file - information is missing.
BUT this happen only if I install that indi fresh on the chart, if I open the Edit the paramter window everything was perfect.
My special problem is if I call this indi via iCustom(..) I can't 'edit' its parameters..
What can I do?
Now I have inserted
and the indiread only 4k again and again..
Any hint?
Gooly