MQL4 - automated forex trading   /  

Forum

Help please. Simple question that has cost me a lot of sleep!

Back to topics list  | 1 2 3 To post a new topic, please log in or register

avatar
26
Marty 2006.10.17 10:45 
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:\)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty
Filtering by History

Filtering by History

The article describes the usage of virtual trading as an integral part of trade opening filter.


avatar
155
richplank 2006.10.17 10:55 
Marty wrote:
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty

According to the documentation http://docs.mql4.com/files, you can't. All files reside in the expertsfiles sub directory (or the testerfiles sub directory at backtesting) of the installation directory, or a sub directory thereof.


avatar
26
Marty 2006.10.17 11:01 
richplank wrote:
Marty wrote:
I'm new to this forum and hello everyone :)

My question is:
How do I specify a path in mq4 to save a file to the root directory (c:)?
Sounds simple but I can't seem to get around it. Somehow it keeps saying that there are too many symbols (doesn't like the ":" I think).

Thanks in advance
Marty

According to the documentation http://docs.mql4.com/files, you can't. All files reside in the expertsfiles sub directory (or the testerfiles sub directory at backtesting) of the installation directory, or a sub directory thereof.

richplank,

Thanks for checking. Not what I wanted to hear (at all! LOL) but at least I know now it's not just me failing to see something obvious :)



avatar
Moderator
5198
stringo 2006.10.17 11:08 
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }


avatar
26
Marty 2006.10.17 13:05 

Thanks for that :)

By the way, have you worked with ftp in mq4? I can't seem to get it to work from within an EA. Just returns nil. Apparently it can't be done from a custom indicator (and why not?) but should work from an EA. I've followed the code:

if(!SendFTP("report.txt"))
{ lasterror=GetLastError();

and it didn't work. Any idea?

stringo wrote:
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }



avatar
26
Marty 2006.10.17 13:25 
stringo wrote:
You can use WinAPI functions. For example
#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import
 
int start()
  {
   if(CopyFileA("G:\\tst\\111.txt", "C:\\222.txt", 0)==false)
      Print("Copying error");
  }
stringo:

Didn't work. Didn't report an error message either. I've put an Alert(filecopied) ---- where filecopied was a boolean that got its value from that function----- and it didn't even give me an alert. Don't know what I'm doing wrong.



avatar
Moderator
5198
stringo 2006.10.17 14:03 
Did You allow dll-calls for your experts?

What errors output to experts' log?

avatar
26
Marty 2006.10.17 14:09 
Yup, I've allowed DLL calling and disabled manual confirmation (not that that matters). But when it was enabled it asked for confirmation so at least we know it's trying to call it.

Error log:
20:08:07 FTP sender GBPUSD,H1: cannot call function 'CopyFileA' from dll 'Kernel32. dll'

avatar
Moderator
5198
stringo 2006.10.17 14:28 
What the value returns GetLastError function after dll-call

What the operating system do You use? 

avatar
26
Marty 2006.10.17 14:34 
stringo wrote:
What the value returns GetLastError function after dll-call

What the operating system do You use?

I've used the following code:
if (!CopyFileA("\test.txt", "\test2.txt", 0))Alert(GetLastError());

There's no alert at all.

My OS is windows XP

avatar
26
Marty 2006.10.17 14:41 
20:37:44 FTP sender GBPUSD,H1: deinitialized
20:37:44 FTP sender GBPUSD,H1: loaded successfully
20:37:44 FTP sender GBPUSD,H1: initialized
20:37:45 FTP sender GBPUSD,H1: cannot call function 'CopyFileA' from dll 'Kernel32. dll'
20:37:45 FTP sender GBPUSD,H1: expert stopped


start (){

if (!CopyFileA("\test.txt", "\test2.txt", 0)){Alert(GetLastError());}



And that's all the code, except for the definition of the function (before init())

#import "Kernel32.dll"
bool CopyFileA (string source_file, string destination_file, bool if_exist);
#import





Back to topics list   | 1 2 3  

To add comments, please log in or register