Download MetaTrader 5

How can i make my own function, that accepts parameters in sequence?

To add comments, please log in or register
Wemerson Guimaraes
631
Wemerson Guimaraes  

Hi all.

 

How can i make my own function, that accepts parameters in sequence?

 

Like this :   int filehandle=FileOpen(filename,FILE_READ|FILE_WRITE|FILE_CSV); 

whroeder1
17074
whroeder1  
  1. Those are simple bit map constants Read=1 Write=2 CSV=8 so the bitwise or operation result is 11.
  2. You make your function accept an int/uint and decompose it using the bitwise and operation:
    type function(... int flags ...){
      bool isRead  = flags & FILE_READ;
      bool isWrite = flags & FILE_WRITE;
      bool isCSV   = flags & FILE_CSV;
    Remember the constants must be powers of 2 (i.e. 1, 2, 4, 8, ...,) so you're limited to 31 of them maximum.
Wemerson Guimaraes
631
Wemerson Guimaraes  
whroeder1:
  1. Those are simple bit map constants Read=1 Write=2 CSV=8 so the bitwise or operation result is 11.
  2. You make your function accept an int/uint and decompose it using the bitwise and operation:
    type function(... int flags ...){
      bool isRead  = flags & FILE_READ;
      bool isWrite = flags & FILE_WRITE;
      bool isCSV   = flags & FILE_CSV;
    Remember the constants must be powers of 2 (i.e. 1, 2, 4, 8, ...,) so you're limited to 31 of them maximum.
Thanks my frined!
To add comments, please log in or register