Help, how to convert data type

a876595353

New member
Who can teach me?how to convert data type?
For example,I have
a='3',b='2'
They are all strings。
But I want to take the number 3 minus the number 2,What should I do?
Is there a way to convert a string to an integer?
These are translated by software,If you can read it, please help me.
 

dsnz

Well-known member
action set variable (set an integer variable)
with expression [strval=a]-[strval=b]

in order to get strval
in the expression line click on the 3 dots to see all magic text
and select "String variable value"
 
Last edited:

a876595353

New member
action set variable
with expression [strval=a]-[strval=b]
Thank you for reply,But that's not going to work。If I set the string variable c= variable A -variable B,I'm going to get a string a - b。If I set an integer variable c,So I can't use expression subtraction,There's no confirm button for me to click.If so, can you give me a correct picture?Thank you very much
 

dsnz

Well-known member
what I wrote works when setting an integer variable,
I tested it (I always test) try it ! 😊

for more details see my original post which I have updated
 

Dm114

Well-known member
Thank you for reply,But that's not going to work。If I set the string variable c= variable A -variable B,I'm going to get a string a - b。If I set an integer variable c,So I can't use expression subtraction,There's no confirm button for me to click.If so, can you give me a correct picture?Thank you very much
@dsnz is right. Create an integer or decimal variable and write the expression
[strval=string_var_A]-[strval=string_var_B]

You should have a look to https://macrodroidforum.com/wiki/index.php/MacroDroid_Wiki
 
Top