Add two values ​​inside variables TASKER

34 views
Skip to first unread message

Genios Marketing

unread,
Sep 14, 2022, 1:02:45 PMSep 14
to Tasker
Hello. I have a problem that I cannot add two numbers, can someone help me? The data to sumer comes from WhatsApp. The client writes that he wants a Cake for 309.00 and wants to add a photo of 100.00 I have the data stored in %Price %Photo 
 I want to sum those 2 values, in JavascriptLet. 
var price = parseFloat("%Price"); 
var photo = parseFloat("%Photo"); 
var total = price + photo;
Then I visualize the result in a Flash "hello, price of the cake is %total" 

and the result it shows me is: "hello, price of the cake is nan
I would like someone to guide me and be able to generate the correct result.


best regards


Jay M

unread,
Sep 14, 2022, 6:15:28 PMSep 14
to tas...@googlegroups.com
Im assuming %Price and %Photo were created in Tasker and not somewhere in the JS? if so they need to be accessed with global()

Untested

var price = parseFloat(global("%Price")); 
var photo = parseFloat(global("%Photo")); 
var total = price + photo;
--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tasker/d4a5c2c4-633d-42f5-a035-c02f7e400b3an%40googlegroups.com.
Message has been deleted

Genios Marketing

unread,
Sep 15, 2022, 5:14:49 PMSep 15
to Tasker
It saves all the information but it does not calculate the total.
Run the JavaScript Let function as you indicate and it does not generate the result.

1.png2.png3.png4.png

Jay M

unread,
Sep 15, 2022, 6:24:20 PMSep 15
to tas...@googlegroups.com
I cant read the language so im not sure what im looking at. I cant see %Photo in use anywhere, i do see %Foto though so maybe it was just a typo and you were supposed to use %Foto in the JS? 

Anyways i just tested the code i wrote by creating the 2 variables in Tasker and adding them together in the JS  and it works for me see screenshot.



On Thu, 15 Sept 2022, 22:09 Genios Marketing, <geniosma...@gmail.com> wrote:
It doesn't work for me yet... I send you a screenshot where I save the data, and a field of the tasker function


El miércoles, 14 de septiembre de 2022 a las 16:15:28 UTC-6, Jay M escribió:
Screenshot_20220915-231611_Tasker.png

Genios Marketing

unread,
Sep 16, 2022, 5:18:33 PMSep 16
to Tasker
works when a numeric value is assigned to the variable. But in my case I receive the data from WhatsApp in the variable %message
  •  I receive all the data from WhatsApp, then process and mutresta them in the Variables assigned in Tasker
    • 1. Set the Variable %posicion to position the WhatsApp number that writes to me and not generate conflicts when 2 clients write at the same time
    • 2.   I make use of Si (if) to condition the data that comes from WhatsApp and assign them the variables

    • grafico.png
Reply all
Reply to author
Forward
0 new messages