Errors, bugs, questions - page 2434

 

How do I know the file name from the handle?

FileGetString is missing.

 
fxsaber:

How do I know the file name from the handle?

FileGetString is missing.

I don't think you can, usually handles, descriptors and other descriptors are virtual tables of integers, which are bound by OS or program environment to specific physical events/drivers/windows...

I've recently started to work with halves using SB, it's pretty handy and here's a ready-made solution for your casehttps://www.mql5.com/ru/docs/standardlibrary/fileoperations/cfile

Документация по MQL5: Стандартная библиотека / Файлы / CFile
Документация по MQL5: Стандартная библиотека / Файлы / CFile
  • www.mql5.com
Стандартная библиотека / Файлы / CFile - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
fxsaber:

How do I know the file name from the handle?

FileGetString is missing.

No way
 
Igor Makanu:

I don't think you can, usually handles, descriptors and other descriptors are virtual tables of integers, which are bound by OS or program environment to specific physical events/drivers/windows...

I've been using file management with SB for a while now, it's pretty handy and here's a ready-made solution for your casehttps://www.mql5.com/ru/docs/standardlibrary/fileoperations/cfile

It's clear that you can save the file name. But still it looks strange that you can't do the basic things.

Slava:
No way

It would be good if you could.

 
fxsaber:

It is clear that it is possible to save the file name. But it still seems strange that you can't do the elementary thing.

I think you need to force yourself to use ready-made solutions, at least I am on this path, here in 5 minutes I have written OHLC to the file

#property copyright "Copyright 2019, IgorM"
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict
#property  show_inputs
input string FName="tst";
#include <Files\FileTxt.mqh>

CFileTxt *FOut;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   FOut=new CFileTxt();
   string sname=FName+"_"+_Symbol+"_"+EnumToString((ENUM_TIMEFRAMES)_Period)+".csv";
   FOut.Open(sname,FILE_WRITE|FILE_TXT);
   Print("Open file");
   Print("File name = ",FOut.FileName());
   int count=0;
   for(int i=Bars-1;i>=0;i--)
     {
      string s=TimeToStr(Time[i])+";"+DoubleToStr(Open[i],_Digits)+";"+DoubleToStr(High[i],_Digits)+";"+DoubleToStr(Low[i],_Digits)+";"+DoubleToStr(Close[i],_Digits)+"\n";
      FOut.WriteString(s);
      count++;
     }
   Print("Write ",count," bars");
   FOut.Flush();
   FOut.Close();
   delete FOut;
  }

when usingCFileTxt class,you don't need to think where to get the file properties - everything is available throughout the program execution

 
Igor Makanu:

I think you need to force yourself to use ready-made solutions, at least I'm on this path, here's how I made an OHLC entry to a file in 5 minutes

You have done it.

Forum about trading, automated trading systems & strategies testing

Bugs, bugs, questions

fxsaber, 2019.04.17 14:00

Clearly you can save the file name. But it still looks strange that you can't do the elementary thing.

 
fxsaber:

You have done it.

Yes I know, but you just have to try to understand the developers' ideology here - they have quite a few ready-made solutions in SB,

 
fxsaber:

It is clear that it is possible to save the file name. But it still seems strange that you can't do the elementary thing.

And it would be good.

What for?

 
Igor Makanu:

Yes I know, but here you just have to try to understand the developers' ideology - they have quite a lot of ready-made solutions in SB,

It's certainly understandable. But that's not what I was talking about.

 
Slava:

Why?

I'm debugging someone else's code, which is transferring handles from some methods to other functions.

I want to unset a specific handle, which is now used in the stop line - what is the file? And it's really hard to do that.