can macrodroid do maths?

420

Active member
i want macrodroid to add multiple stopwatches together troughout the day and then write that to a file every day at midnight.

i really don't know how to do it, i thought maybe i could do it with the text manipulation - substring action and then put the string variable into an integer variable.
but then the action to set an integer variable only has a +1 or -1, there is no option to add or subtract one integer variable to/from another.

anyone can help me?
 

420

Active member
i actually found a way to do it but i have to go outside of macrodroid for it, i use a website that i can make a http request to, to increase or decrease a variable on that website, so i can make a http get request like this: https://sequematic.com/variable-change/(identifier)/hours/+[v=hours] and then i have another trigger in macrodroid to get that variable value and write it to file at midnight, and i had to create a sequence on the website to return the sequematic variables back to 0 after macrodroid has gotten the values.

i know macrodroid also has an option to change variables trough webhooks but i cannot remember how to do it, can someone please tell me how to do it and if i can add one integer variable to another that way??
 

Dm114

Well-known member
i want macrodroid to add multiple stopwatches together troughout the day and then write that to a file every day at midnight.

i really don't know how to do it, i thought maybe i could do it with the text manipulation - substring action and then put the string variable into an integer variable.
but then the action to set an integer variable only has a +1 or -1, there is no option to add or subtract one integer variable to/from another.

anyone can help me?
I'm not sure I fully understood your question. What do you want to add or compute? To add whatever value to a numerical variable (integer or decimal), just use 'set variable' action, then check 'expression' button and type the math formula, such as [v=int] + whatever_value or whatever_numerical_ variable. If the variable is string, use the function 'string value' from the [...] button. You'll get something like [v=int]=[v=int]+whatever_value+[strval=string_variable]

Is that what you needed?
 
Last edited:

420

Active member
I'm not sure I fully understood your question. What do you want to add or compute? To add whatever value to a numerical variable (integer or decimal), just use 'set variable' action, then check 'expression' button and type the math formula, such as [v=int] + whatever_value or whatever_numerical_ variable. If the variable is string, use the function 'string value' from the [...] button. You'll get something like [v=int]=[v=int]+whatever_value+[strval=string_variable]

Is that what you needed?
i did not know we could do this but yes that is exactly what i needed, thank you very much!
 

Sezgin

New member
i did not know we could do this but yes that is exactly what i needed, thank you very much!
I think you should create a second variable typed decimal or integer. So you can add or subtract any string.
 
Last edited:

Dm114

Well-known member
I think you should create a second variable typed decimal. So you can add or subtract any string.
İnteger variables cant do math with strings.
In a string variable you even can input a complex math formula, same as if it had been type in using 'set variable' action > expression! And then you convert the result in a decimal value. It's very simple.
 

Sezgin

New member
In a string variable you even can input a complex math formula, same as if it had been type in using 'set variable' action > expression! And then you convert the result in a decimal value. It's very simple.
I couldn't find location of it. But I remember there was a list of them, you are right.
I'll look again later. Thank you.
 

Dm114

Well-known member
1⁰ Action 'set variable' > choose or create a string variable > check '[user prompt]' button and then input your input prompt text (title and description)

2⁰ Action 'set variable' > choose or create a numerical variable > check 'expession' button and click on the 3-dot box on the right side of the input field
___________ [...]
Then scroll down untill you find 'string value' and you'll be asked for the string variable you want to get the value. This string variable may contain any kind of valid mathematical expression, including some functions (be careful with the syntax). For decimal variables you even can store the content of the string variable directly into the decimal variable.
 
Last edited:

Sezgin

New member
1⁰ Action 'set variable' > choose or create a string variable > check '[user prompt]' button and then input your input prompt text (title and description)

2⁰ Action 'set variable' > choose or create a numerical variable > check 'expession' button and click on the 3-dot box on the right side of the input field
___________ [...]
Then scroll down untill you find 'string value' and you'll be asked for the string variable you want to get the value. This string variable may contain any kind of valid mathematical expression, including some functions (be careful to the syntax). For decimal variables you even can store the content of the string variable directly into the decimal variable.
You are really cool. Thank you very much indeed.
The problem is...
I changed Macrodroid language to English to do it. But I never see "string value" because phone system language was still in my language. So "string value" sentence still in my language. So I couldn't see it.

Thank you very very much 👍🏻
 

Dm114

Well-known member
You are really cool. Thank you very much indeed.
The problem is...
I changed Macrodroid language to English to do it. But I never see "string value" because phone system language was still in my language. So "string value" sentence still in my language. So I couldn't see it.

Thank you very very much 👍🏻
Thank you for your thanks: you're welcome!
We all are on this forum to help each other as much as we can...

According to the 'string value' function, if you can't find it you can type this [strval=your_string_variable_name]
in the 'expression' field of your decimal variable.
 
Top