How to extract character on the right?

 
 

Note, all those integers need to be of type double.

You need to convert the variables to strings, and as decimal places can vary, do a search for any 'padded' zeros added by DoubleToStr.

double var = 12.3456;

string strvar = DoubleToStr(var,8);

int ndx = StringFind(strvar,"0",0);

if (ndx == -1)

ndx = StringLen(strvar);

Print(StringSubStr(strvar,ndx - 2, 2));

At least that's how I'd do it. If anyone knows another way, let me know!

 

Thanks you for your help

But I've got a message :

'StringSubStr' function is not defined

How can I do ?

Best regards

 
natsirte:
Thanks you for your help

But I've got a message :

'StringSubStr' function is not defined

How can I do ?

Best regards

it just a small typing mistake StringSubstr instead of StringSubStr

and just a small thing to take care: in omelette's code the maximum size that is assumed for your number is 8 digits but it may be more.

 

Hi

Thank you very much for your help!!

 
jlpi:
it just a small typing mistake StringSubstr instead of StringSubStr and just a small thing to take care: in omelette's code the maximum size that is assumed for your number is 8 digits but it may be more.

Hi. Don't think it can be - MT limits the number of decimal places to 8 as far I I'm aware. Switch to a different platform, then yes.

Natsirte, while I'm here I should point out (in case you didn't realize it) that the code I posted expects the integer part of 'var' to be non-zero. If this is a possibility, an additional check would be required.

Reason: