Download MetaTrader 5
To add comments, please log in or register
You can test an application before buying it. Find out how to do that!
sgude0
12
sgude0 2014.06.09 16:15 

Hi! I'd like test whether the OrderComment is a convertible from string to a number or not, but I can't find anything like an IsNumber() function. Is it possible to get around this?

Basically I need the code to test wehter OrderComment() is of type "1.3650" or "BALANCER" in order for the code to make better choices on what to do with that specific order.

Would appriciate any help!.


Re

Dennis

Bambang Sugianto
10049
Bambang Sugianto 2014.06.09 17:24  
StrToInteger( text ) or  StrToDouble( text )
whroeder1
13982
whroeder1 2014.06.09 18:54  
sgude0:I can't find anything like an IsNumber() function.
So make one.
Just typed, not compiled, not tested.
bool IsNumber(string s){
  for(int iPos = StringLen(s) - 1; iPos >= 0; iPos--){
     int c = StringGetCharacter(s, iPos);
     if( (c < '0' || c > '9') && c != '.') return false;
  }
  return true;
}
Just typed, not compiled, not tested.
/
To add comments, please log in or register