Looking for a function to return integer value of a symbol. Any help?

 

I am aware of the function

SymbolName(i, true);

used to return a symbol name given an integer.

I am looking for a function to return the integer value of an instrument given a symbol name. Something that looks like:

IntegerValue (SymbolName, true):

Any help. Thanks in advance.

 
  for(int i=0;i<SymbolsTotal(1);i++)
     {
      Print("SYMBOL: ",SymbolName(i,1)," Found At: ",i);
     }
 
Marco vd Heijden:
Thank you anyway, but that one I already know as you can see in my question. I am actually asking of the reverse function that should return integer and not to return symbol names.
 
macpee: Thank you anyway, but that one I already know as you can see in my question. I am actually asking of the reverse function that should return integer and not to return symbol names.

Marco vd Heijden just gave you your answer. He showed you how the two relate.

All you had to do was think and code it.

int IntegerValue (string symbolName, bool isSelected=true){
   for(int i=SymbolsTotal(isSelected)-1; i>=0; --i)
     {
      if( SymbolName(i,isSelected) == symbolName) return i;
     }
   return -1;
}

Was that so hard that you couldn't even try to code it?

 
macpee: Thank you anyway, but that one I already know as you can see in my question. I am actually asking of the reverse function that should return integer and not to return symbol names.

It does not exist and even if it did, it would be implemented very similarly to the way @Marco vd Heijden has demonstrated. In other words, you can build your own reverse function by simply going through the entire list until a match is found.

EDIT: Looks like @whroeder1 hit the button before me!

 
Fernando Carreiro:

It does not exist and even if it did, it would be implemented very similarly to the way @Marco vd Heijden has demonstrated. In other words, you can build your own reverse function by simply going through the entire list until a match is found.

EDIT: Looks like @whroeder1 hit the button before me!

Wow thanks both of you. You two couldn't have been mutually mistaken. I think the solution required the inverse function of
SymbolName()
which is what I failed to come up with. But I got the jerk now.
Reason: