In order to allow the program to differentiate one file from another the file descriptor is set in accordance to every opened file.įile descriptor – unique number of the file that is opened by the program at the moment. The mode of opening a file is specified in the FileOpen() function.Īn application program can open several working files at a time. In order to allow an applicable program to interact with a file, you should open that file first. The execution of this technology guaranties that a file won't be modified simultaneously by two different programs. Dialog box that appears when a program tries to access to the file that has already been opened by another program. For example, if My_text.doc has already been opened by a text editor, then all the other programs will receive the notification before opening the file:įig.
At the same time, the operational environment provides the full access to the file, namely the right to read the file and write the information in it, only to one program.
In general, a file can be opened by several programs at the same time (within a PC or several PCs connected to the network). The technology of interaction between an application and a working file has several modes. Working with files in other directories is not involved. In case of no available folder at the moment of file saving, the folder will be automatically created by the client terminal. Terminal_folder\Tester\ Files\ - for files the are used for testing.Ī working file can be saved in one of these folders or in their subfolders. Terminal_folder\Experts\Files\ - for common usage Terminal_folder\Experts\History\ current broker\ - for history files There are three folders (with subfolders) that can contain working files: Internet Explorer, Netscape Navigator, etc. htm - file to be viewed in a browser, i.e. txt - text file, for viewing you should use Notepad, Word, FrontPage, etc. The most popular file types (the type is determined by its extension) are the following: Therefore, you should assign the file extension considering the program (if necessary) that will usually be used to view the file. According to the file extension, the operating environment loads one or another program displaying the file content. Most programs are automatically launched on the user's PC, if the file is double-clicked with the mouse button. A file name is usually chosen so that it represents the information the file contains. Technically, a file name has no relation to the file content, so a file name and extension can be set voluntarily by the programmer. The name of any file used in MQL4 consists of two parts: the file name and the file extension separated by a dot, for example, News.txt. The name of a working file must be composed according to the requirements of the operating system.
An executable program (e.g., an Expert Advisor) can read this information from the previously prepared file and consider it during calculating for graphical displaying of the messages on the screen or for making of trade decisions. In other cases, there is a need to deliver some information, for example, the news timetable, to an application. This file can be later opened by another program (e.g., Excel for drawing a balance graph). For example, the trading history of an account can be written to a file at the execution of an application. In this case, the file can be created by an application program and used by it as an information receiver. It may become necessary to write information in a file or to read it from a file for several reasons.Ī file can be used to deliver information to another program.
In MQL4, it is possible to work with files containing a certain set of information.