Sum two or more variables

456 views
Skip to first unread message

Mickets

unread,
Aug 11, 2011, 1:19:52 PM8/11/11
to Tasker
Hello,

I searched for this but could not find a sure answer.

First, let me explain what I'm trying to do.

I want to set location state levels, starting at near cell tower, then
local (via network), then near Wi-Fi. If entering one of these states,
then %MYPLACE would increase (1, then 2, then 3).

Originally I had attributed each state level a value, from 1 to 3. But
then I bumped in to problems and loops:

State: Near Cell; %MYPLACE < 1
Enter Task: Set %MYPLACE = 1, turn on APN
Exit Task: Set %MYPLACE = 0, turn off APN

This of course generated a loop.

To make a long story short, I decided to split the place in to
different values:

%MYNEAR = 1
%MYIN = 2
%MYWIFI = 4
%MYCONNECT = 8

%MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT

So, for example, if:

near cell -> 1
Near cell and in location -> 3
Near cell, in location, and near wifi -> 7

The reason why they double is because for some reason the phone is,
for example, still near cell tower (1) and WiFi (4), but loses state
%MYIN, then the sum is 1 + 4 = 5, which is still higher than only near
cell or near cell + in location.

This way I can maintain a location level state, even if one of the
lower level values is lost.

And a profile would now look like:

----------------------
Profile 1

Context: Near Cell, %MYPLACE < 1

Enter Task: set %MYNEAR = 1, MyPlaceCalc (set %MYPLACE = %MYNEAR +
%MYIN + %MYWIFI + %MYCONNECT = 1 + 0 + 0 + 0 = 1

Exit task: clear %MYNEAR (%MYPLACE remains unchanged, so it is still 1
and this profile will no longer be active)
---------------------

-----------------
Profile 2

Context: In Location, %MYPLACE < 2

Enter Task: set %MYIN = 2, MyPlaceCalc (set %MYPLACE = %MYNEAR + %MYIN
+ %MYWIFI + %MYCONNECT = 0 + 2 + 0 + 0 = 2

Exit task: clear %MYIN (%MYPLACE remains unchanged, so it is still 2
and this profile will no longer be active)

-----------------------



What I'm bumping in right now is getting
%MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT to work.

I made a task, MyPlaceCalc, where %MYPLACE is set to
%MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT, and DoMath is
enables.

I can see the phone enters state where %MYNEAR is 1, and turns on APN.
But %MYPLACE still remains zero.

I though of trying to use Variable Add instead and set %MYPLACE +
%MYNEAR, etc.

But before I proceed, I would like some guidance if I'm going in the
right direction, or if the original variable sum I want to make should
work (%MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT)

Thanks for any advice.

Mickets

Pent

unread,
Aug 12, 2011, 5:47:57 AM8/12/11
to Tasker
> What I'm bumping in right now is getting
> %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT to work.
>
> I made a task, MyPlaceCalc, where %MYPLACE is set to
> %MYPLACE = %MYNEAR + %MYIN + %MYWIFI + %MYCONNECT, and DoMath is
> enables.
>
> I can see the phone enters state where %MYNEAR is 1, and turns on APN.
> But %MYPLACE still remains zero.

Turn on Menu / Prefs / More / Popup Errors Warnings. In the task,
before you do the big adding action, flash (or popup, or write to
file) the values of all the variables.

Pent
Reply all
Reply to author
Forward
0 new messages