What is txt?
it's a file
ayoub: it's a file
| FileDelete |
it not work ,Does not read the new value it read just last value, can you correct this expert, please.
//--- display the window of input parameters when launching the script //--- input parameters input string InpFileName="data.bin"; input string InpDirectoryName="SomeFolder"; //+------------------------------------------------------------------+ //| Structure for storing price data | //+------------------------------------------------------------------+ struct prices { datetime date; // date double bid; // bid price double ask; // ask price }; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnTick() { //--- structure array prices arr[]; //--- file path string path=InpDirectoryName+"//"+InpFileName; //--- open the file ResetLastError(); int file_handle=FileOpen(path,FILE_READ|FILE_BIN); if(file_handle!=INVALID_HANDLE) { //--- read all data from the file to the array FileReadArray(file_handle,arr); //--- receive the array size int size=ArraySize(arr); //--- print data from the array for(int i=0;i<size;i++) Print("Date = ",arr[i].date," Bid = ",arr[i].bid," Ask = ",arr[i].ask); Print("Total data = ",size); //--- close the file FileDelete(InpFileName); FileClose(file_handle); } else Print("File open failed, error ",GetLastError()); }
ayoub: it not work
- It does work. You would have found out why had you bothered to check your return codes.
What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
string path=InpDirectoryName+"//"+InpFileName; int file_handle=FileOpen(path,FILE_READ|FILE_BIN); FileDelete(InpFileName);
Your file name is in path. Why don't you try deleting it?
i use that but when start delete it can't read again
the "file find first" , "next" and "close" it Necessary to define the new value and "file is exist"
ayoub: i use that but when start delete it can't read again
| Make up your mind. If you want to delete the information, you can't read it again. |
From what I can undestand, OP actually wants to empty the contents of the file and not to delete the whole file. So, OP, first FileClose(yourfile); and then FileOpen("filename.bin",FILE_WRITE|FILE_BIN);
To be more clear, I repeat, do not FILE_READ at that time and your file will be emptied
best regards
I think they want to delete specific information from within the file, not the entire file itself. FileDelete would not be the correct solution to the problem in this case.
I want to offload content the txt after reading the information
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 want to delete the information from txt every tick
how can i do this