1. May be that zero character in the file terminated your string
2. What the error gets GetLastError()?
stringo:
1. May be that zero character in the file terminated your string
2. What the error gets GetLastError()?
Apologies for not looking at the GetLastError() before - see below
int handle = FileOpen("test.txt",FILE_READ|FILE_BIN); // valid handle from a 4MB text file produced using notepad.exe str = FileReadString(handle,100000); Print(GetLastError()); // this prints 4004 - not enough memory Print(StringLen(str)); // this prints 4093 - expect 100000
You can try to read string's remains and concatenate they
stringo:
You can try to read string's remains and concatenate they
Yes, the following works well to read a 4MB string
// assumes handle is FILE_BIN string FileReadLargeString(int handle) { string strLarge=""; do { ResetLastError(); string str=FileReadString(handle,4000); if(GetLastError()!=0) break; StringConcatenate(strLarge,strLarge,str); } while(GetLastError()==0 && !FileIsEnding(handle)); return(strLarge); }
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
Is there any reason for the 4093 character maximum length of a string read by FileReadString from a BIN file?