• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Bitwise operation support

Hi,

I want to know if bitwise operation is supported in tasker an how to use it?

I got away with ORing a bit in a variable by adding it instead. I want to check for the sit bit in the if block.

How do I do that?

Regards
Aman
 
I'm not sure I understand your question.

You can convert to a sting, manipulate, and the convert back as in the following.

Dev1
A1: Variable Set [ Name:%decimal To:22 Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Search Replace [ Variable:%decimal Search:. Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%numbers Replace Matches:Off Replace With: ]
A3: Variable Convert [ Name:%decimal Function:Decimal to Binary Store Result In:%numbers ]
A4: Variable Search Replace [ Variable:%numbers Search:. Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%numbers Replace Matches:Off Replace With: ]
A5: Flash [ Text:%decimal
%numbers Long:On ]
A6: Variable Set [ Name:%numbers(4) To:0 Recurse Variables:Off Do Maths:Off Append:Off ]
A7: Variable Join [ Name:%numbers Joiner: Delete Parts:Off ]
A8: Variable Convert [ Name:%numbers Function:Binary to Decimal Store Result In:%decimal ]
A9: Flash [ Text:%decimal
%numbers Long:On ]

You can also enter Java and JavaScript (see the Code section).

… Thom
 
Hi,

Thanks for your reply. I have not progressed enough to understand the code you’ve written. I copied it from “Dev1 till Long:On ]” into a tsk.xml file and tried to import into Tasker (in tasks) but it gave error.

Could you point me to a guide that teaches how to understand this?

And sorry, my post had too many typos and it was not articulated correctly. So I’ll explain below:

Myvar = 8 // I set this myself

If (Myvar & 8) // this is what I need help on
{
do this
}

If your example can achieve this, then all good. Otherwise please guide me how to do this as well.

Regards
AK
 
I added some Ifs and some Flashes to the sample to show how it is done …


Dev1 (268)
A1: Variable Set [ Name:%decimal To:22 Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Search Replace [ Variable:%decimal Search:. Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%numbers Replace Matches:Off Replace With: ]
A3: Variable Convert [ Name:%decimal Function:Decimal to Binary Store Result In:%numbers ]
A4: Variable Search Replace [ Variable:%numbers Search:. Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%numbers Replace Matches:Off Replace With: ]
A5: If [ %numbers(4) ~ 0 ]
A6: Flash [ Text:Zero Long:On ]
A7: End If
A8: If [ %numbers(4) ~ 1 ]
A9: Flash [ Text:One Long:On ]
A10: End If

A11: Flash [ Text:%decimal
%numbers Long:On ]
A12: Variable Set [ Name:%numbers(4) To:0 Recurse Variables:Off Do Maths:Off Append:Off ]
A13: Variable Join [ Name:%numbers Joiner: Delete Parts:Off ]
A14: Variable Convert [ Name:%numbers Function:Binary to Decimal Store Result In:%decimal ]
A15: If [ %numbers(4) ~ 0 ]
A16: Flash [ Text:Zero Long:On ]
A17: End If
A18: If [ %numbers(4) ~ 1 ]
A19: Flash [ Text:One Long:On ]
A20: End If

A21: Flash [ Text:%decimal
%numbers Long:On ]

… Thom
 
Back
Top Bottom