Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
yellowlion
75
yellowlion 2014.03.03 20:04 

Hi All,

Have a full day today to try and get this now unworkable script re-written in MQL5. Grrrrr.

A simple FileOpen() procedure that has worked for years now returns a value of -1

The SourceFile and Executable are way down there in the hole AppData/.../Scripts and the .csv's are in AppData/.../Files

void OnStart()
{

MessageBox(FileIsExist("MEURmd.csv"));

}

Returns "true"

void OnStart()
{

int handle;
  
handle = FileOpen("MEURmd.csv",FILE_WRITE|FILE_CSV,',');
if(handle > 1)
{
  FileWrite(handle,"DATE","OPEN","HIGH","LOW","CLOSE","VOLUME");   // heading
  FileClose(handle);
  MessageBox("File Created");
}
if(handle < 1)
{
 MessageBox(handle);
}

}


returns "-1" Allll righty then.

If the file does not exist, FileOpen() does create it, but FileWrite() does not write the heading.

Any Ideas?

Alain Verleyen
Moderator
28550
Alain Verleyen 2014.03.03 20:12  
yellowlion:

Hi All,

Have a full day today to try and get this now unworkable script re-written in MQL5. Grrrrr.

A simple FileOpen() procedure that has worked for years now returns a value of -1

The SourceFile and Executable are way down there in the hole AppData/.../Scripts and the .csv's are in AppData/.../Files

Returns "true"


returns "-1" Allll righty then.

If the file does not exist, FileOpen() does create it, but FileWrite() does not write the heading.

Any Ideas?

Which build are you using ?

About your code, what if the handle is =1 ?

Alain Verleyen
Moderator
28550
Alain Verleyen 2014.03.03 20:14  
yellowlion:
Build 600

Current build is 610 (official), beta build is 614.

Can you try with it ?

Alain Verleyen
Moderator
28550
Alain Verleyen 2014.03.03 20:24  
yellowlion:

Hi angevoyageur,

My broker has only upgraded me to 600. Where can I get 610? I'm guessing the download on the MQL4 homepage is 610.

thanks,

YL

Probably, I didn't check though.
yellowlion
75
yellowlion 2014.03.03 20:51  

Hi angevoyageur,

I downloaded build 610 with MetaEditor build 887, and copied - metaeditor.exe, the two mql compiler files, and terminal.exe into my existing 600 build and put the corresponding 600 build files into a folder named 600.

I then opened the terminal and compiled the little script.

void OnStart()
{

MessageBox(FileIsExist("MEURmd.csv"));

}

returns "true" as before

void OnStart()
{

int handle;
  
handle = FileOpen("MEURmd.csv",FILE_WRITE|FILE_CSV,',');

if(handle > 1)
{
  FileWrite(handle,"DATE","OPEN","HIGH","LOW","CLOSE","VOLUME");   // heading
  FileClose(handle);
  MessageBox("File Created");
}
if(handle < 1)
{
 MessageBox(handle);
}

}

Now returns no message and still creates the file with no heading.

OK one step back...now forward...?

YL

yellowlion
75
yellowlion 2014.03.03 20:58  

Got it...

handle now == 1. Changed comparison to (handle>0) and the file is created and written to.

I changed the comparison in the original full script to (handle>0) and that was the only change needed :D :D :D

YL

Alain Verleyen
Moderator
28550
Alain Verleyen 2014.03.03 21:49  
yellowlion:

Got it...

handle now == 1. Changed comparison to (handle>0) and the file is created and written to.

I changed the comparison in the original full script to (handle>0) and that was the only change needed :D :D :D

YL

Yes this is why I asked you :

About your code, what if the handle is =1 ?


yellowlion
75
yellowlion 2014.03.03 21:56  
angevoyageur:

Yes this is why I asked you :




I missed that. Thanks for your help :)

YL

/
To add comments, please log in or register