hi
I want to create a flow to calculate digits.
example 2+4=6
2×7=14
9-4=5
6÷6=1
how can I calculate above digits using input Dialog number, single choice menu and script? how can I create ? I am not getting success.
from record4
calculate
Moderator: Martin
Re: calculate
Do you want a single input and directly get result? or you want to do some choice for the operator? (+ - x : etc?)
If you can just simply input the whole correct expression, using single line text. Just input the whole calculation at there (example : 2*7), and eval(value) afterward.
Then put x at the notification on screen to show the result.
You can catch the error from the script, add another notif to tell that the input is not valid.
If you can just simply input the whole correct expression, using single line text. Just input the whole calculation at there (example : 2*7), and eval(value) afterward.
Code: Select all
x = eval(value);
You can catch the error from the script, add another notif to tell that the input is not valid.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: calculate
hi desmanto
when I calculating 7/3 . it was showing result as 2 only. how can I get result as 2.33.
thanks from record4
when I calculating 7/3 . it was showing result as 2 only. how can I get result as 2.33.
thanks from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1
Re: calculate
That is a little complicated. You must know how you to input the calculation. Common division will always result in integer. You must have one of the number involved in division to have decimal. One way is to append '1.0 * ' to the value before calculation.
So the script now become
The x is later eval to 1.0 * 7/3. Which will be 7.0/3 and the result is in floating number. But this will give 2.3333333333333335. You want only the the last 2 decimal. So you will show it up in 2 decimals format.
The result now become 2.33
This maybe doesn't cover all situation, but should be good for most cases.
So the script now become
Code: Select all
x = eval('1.0 * ' + value);
Code: Select all
x = "{eval('1.0 * ' + value),numberformat,0.00}"
This maybe doesn't cover all situation, but should be good for most cases.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.