Download MetaTrader 5

How do I convert character to ANSI number - page 2

To add comments, please log in or register
whroeder1
14785
whroeder1  
Never to that because they are unreadable.
 if(ArrowProp="ò")ArrowNo=Down;
 if(ArrowProp="ö")ArrowNo=Sideways;
 if(ArrowProp="ñ")ArrowNo=Up;
This you can
if(ArrowProp == "\242")ArrowNo=Down;
if(ArrowProp == "\240")ArrowNo=Sideways;
if(ArrowProp == "\241")ArrowNo=Up;

// or

if(ArrowProp == "\xF2")ArrowNo=Down;
if(ArrowProp == "\xF0")ArrowNo=Sideways;
if(ArrowProp == "\xF1")ArrowNo=Up;
Character Constants - MQL4 Documentation
Or even easer
ArrowNo = StringGetCharacter(ArrowProp, 0);
StringGetCharacter - MQL4 Documentation
MikeT
232
MikeT  

Thanx Roeder

That is what I was looking for....

ArrowNo = StringGetCharacter(ArrowProp, 0);

 I've also taken note of....

if(ArrowProp == "\242")ArrowNo=Down;
if(ArrowProp == "\240")ArrowNo=Sideways;
if(ArrowProp == "\241")ArrowNo=Up;

// or

if(ArrowProp == "\xF2")ArrowNo=Down;
if(ArrowProp == "\xF0")ArrowNo=Sideways;
if(ArrowProp == "\xF1")ArrowNo=Up;

 Thanx...

MikeT
232
MikeT  
Mike.T:

Sorry Demos.... you were right all along with StringGetCharacter... I just wasn't using  it correctly.... I should have paid more attention...heheh

The final solution...

void OnTick()
  {
//---


//---
string ArrowProp = ObjectDescription("TrendArrowHTF"); //Get Object text value
string ArrowNo = StringGetCharacter(ArrowProp, 0);
   
   Comment("Arrow No = ",ArrowNo);
   
  }

 Easy when you know how....

Thanx Guys 

12
To add comments, please log in or register