What's all this nonsense about the tab character{t}? - page 5

 

I tried to make a table with labels in a monospace font as suggested here - it's not a pleasant sight for the eye. Especially fractional numbers are smeared horizontally in such a way that it's very hard to see. So we are left with the option of labels in a regular font, with a separate label for each cell. That would involve quite a few objects, as I've written before.

Jartmailru, do you know if it's realistic to create an output window directly in the EA code, without using a DLL? All WinApi functions are available. The only snag may be only when passing a structure containing both variables and pointers at the same time.

 

labels in the mono-wide

 
don't be fooled - use an off-the-shelf component : https://www.mql5.com/ru/code/8724
 
xrust:

the labels in the mono-chine.


In a mono-chine, you mean?

It's nice, but you don't have tables with a lot of long numbers in a row, so it's pretty easy to read.

 
Meat:


In a mono-wide you mean?

It's nice, but you don't have tables with a lot of long numbers in a row, so it's pretty easy to read.

Maybe, I don't know, I've never set myself such a task. Having the terminal as a fairly good tool for displaying various kinds of graphical information in the form of graphs and charts, to build and analyse a large amount of textual information in it? - Why when you have Excel for that ... Although of course this is my humble opinion :)
 
jartmailru:
On the other hand, I wonder if you haven't already encountered
that the first 30% of entries are usually missing from the log, and that entries are selectively lost afterwards.
The logs have all the lines, it is the terminal that selectively displays them. If you open the files themselves, they are all there.
 
MetaDriver:

// Can you make a DLL for Unicode? I will be sincerely grateful.

Here you go. Added functions LogW, SelectW, but did not test - any problems please contact.
If you will make binder for 5th, please send it to me :-).
.
Meat:

Jartmailru, do you know if it's realistic to create an output window directly in the EA code without using a DLL? All WinApi functions are available. The only hitch may be only when passing a structure containing both variables and pointers.

If you have done something twisted, maybe it's possible. I do not twist :-).
A window next to an MT in C++ requires a separate interface thread.
If it's a single window, it's trivial.
.
By the way... it's not a fact that tabs... ...you'll be able to align
the contents of the columns to the right degree.
.
PapaYozh:
The logs have all the lines, it's the terminal that shows them selectively. If you open the files themselves, they are all there.
I don't mind :-). But: I have everything displayed + I have done a graph-
log (the point from the graph is searched in the log - the right place is shown).
.
Files:
out.zip  123 kb
 

Well, I've made a tab for multi-spaced fonts! :) Yay! :) Of course, I had to make a lot of trouble with WinAPI functions, but it was worth it. It's useful not only for Comment, but for Label too. The idea is that we get the size of any string in any font in pixels. And then you can tabulate them as you like, either left, right, or centre. For Comment, tabulation is naturally done with spaces, so the result is not perfect, the error is within 1-2 pixels, but it's nothing in principle. For labels, everything is much simpler.

Here's an example showing tabs in Comment. Tahoma,8 is specified here, as comments are output in that font.

#import "Gdi32.dll"
  int CreateFontA(int nHeight,int nWidth,int nEscapement,int nOrientation,int fnWeight,int fdwItalic,int fdwUnderline,
                  int fdwStrikeOut,int fdwCharSet,int fdwOutputPrecision,int fdwClipPrecision,int fdwQuality,
                  int fdwPitchAndFamily,string lpszFace);
  int SelectObject(int hdc,int hgdiobj);
  bool DeleteObject(int hObject);
  int GetDeviceCaps(int hdc,int nIndex);
  bool GetTextExtentPoint32A(int hdc,string lpString,int cbString,int lpSize[]);
  
#import "user32.dll"
  int GetDC(int hWnd); 
  int ReleaseDC(int hWnd,int hDC);
  
//+------------------------------------------------------------------+
int start()
{
  #define DEFAULT_CHARSET 1
  #define OUT_DEFAULT_PRECIS 0
  #define CLIP_DEFAULT_PRECIS 0
  #define DEFAULT_QUALITY 0
  #define DEFAULT_PITCH 0
  #define FF_MODERN 48
  int hWnd=WindowHandle(Symbol(),Period());
  int DC=GetDC(hWnd);
  int dpi=GetDeviceCaps(DC,88);  //88=LOGPIXELSX
  string Font="Tahoma";
  int fontsize=8;
  int fontheight=MathRound(fontsize*dpi/72.0);
  int hFont=CreateFontA(fontheight,0,0,0,0,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,Font); 
  SelectObject(DC,hFont);
  
  string StringArray[]={"Один","Два","Три","Четыре","Пять","Шесть","Семь","Восемь","Девять","Десять","Одиннадцать","Двенадцать"};
  int arraysize=ArraySize(StringArray);
  int tabpixels=100;  // размер табуляции в пикселях
  int size[2];
  GetTextExtentPoint32A(DC," ",1,size); // получаем размер пробела
  int spacesize=size[0];
  if (spacesize==0) { Alert("spacesize=0"); return(0); }
  string text="\n";
  int rowsize=0;
  int alignmode=0; // 0- по левому краю, 1- по правому краю
  
  for (int i=0; i<arraysize; i++)
  { 
    int column=i%4;
    string str=StringArray[i];
    GetTextExtentPoint32A(DC,str,StringLen(str),size);  // получаем размер строки
    int spacecount=MathRound((tabpixels*(column+1)-size[0]-rowsize)*1.0/spacesize);
    for (int s=0; s<spacecount; s++)
      if (alignmode==0)
        str=str+" ";
       else
        str=" "+str;
    rowsize+=size[0]+spacesize*spacecount;
    text=text+str;
    if (column==3 || i==arraysize-1)
    { 
      text=text+"\n";
      rowsize=0;
      if (i<arraysize-1) continue;
      if (alignmode==1) break;
      alignmode++;
      text=text+"\n\n";
      i=-1;
    }
  }   
  Comment(text);
  ReleaseDC(hWnd,DC);
  DeleteObject(hFont);
  return(0);
}

 
You're lazy as hell :-)
 
Meat:

Here's an example showing tabbing in Comment. The font set here is Tahoma,8, as comments are output in this font.


+ remade output of any text, not just an array of lines

+ made it as a separate function CommentTab

+ added an array of TabStop values and a default Tab size (as in the GDI function)

Example of text and result

//------------------------------------------------------------------    start
int start()
{
  string txt="\n";
  txt=txt+"Ticket\tOpen Time\tType\tSize\tItem\tPrice\tS / L\tT / P\tClose Time\tPrice\tCommission\tTaxes\tSwap\tProfit"+"\n";
  txt=txt+"524567\t28.06.2011 15:02\tbuy\t0.35\teurusd.vpe\t1.43380\t1.43390\t0.00000\t29.06.2011 2:39\t1.43383\t-3.50\t0.00\t0.56\t0.73"+"\n";
  txt=txt+"523492\t28.06.2011 15:02\tbuy\t0.70\teurusd.vpe\t1.43397\t1.43407\t1.47115\t28.06.2011 18:17\t1.43407\t-7.00\t0.00\t0.00\t4.88"+"\n";
  txt=txt+"523494\t28.06.2011 15:02\tbuy\t0.70\teurusd.vpe\t1.43397\t1.43407\t0.00000\t28.06.2011 18:17\t1.43407\t-7.00\t0.00\t0.00\t4.88"+"\n";
  txt=txt+"523498\t28.06.2011 15:02\tbuy\t0.35\teurusd.vpe\t1.43380\t1.43390\t0.00000\t28.06.2011 17:00\t1.43675\t-3.50\t0.00\t0.00\t71.86"+"\n";
  txt=txt+"522650\t27.06.2011 14:50\tbuy\t0.80\teurusd.vpe\t1.42240\t1.42371\t1.43687\t28.06.2011 15:19\t1.43693\t-8.00\t0.00\t1.28\t808.95"+"\n";
  
  int tab[]={10, 22, 10, 10, 15, 12, 12, 12, 22, 12, 20, 10, 10}; // размеры в пробелах
       
  CommentTab(txt, tab, 30); // вызвали преобразование и вывод по табуляции
}