i want to code 4 potential triggers on one 4-digit numbers containing only 0s and 1s, so 0000 would spit no trigger, 1000 would spit A, 1100 would spit A B, 1110 ABC, 1111 ABCD, 1001 AD, etc…
how would you do that ?
Thanks !!
i want to code 4 potential triggers on one 4-digit numbers containing only 0s and 1s, so 0000 would spit no trigger, 1000 would spit A, 1100 would spit A B, 1110 ABC, 1111 ABCD, 1001 AD, etc…
how would you do that ?
Thanks !!
assuming your number is stored in A
:
IF % >> A 0 2: TR.P 1
IF % >> A 1 2: TR.P 2
IF % >> A 2 2: TR.P 3
IF % >> A 3 2: TR.P 4
you could optimize it with a loop. also, upcoming bitwise ops should make it easier: (Teletype) Bitwise Operators (Done!) as you could simply do IF BGET A 0
etc.
This is exactly the answer i was hoping, since i just installed the new beta but don’t really know the bitwise ops. THANKS !
so BGET x gets the value at ‘rank’ x ?
i’m using this technique to store 4 trig states in one pattern value. That would be nice if the pattern grid could display 0s at the left of a number, for more clarity.
Well, something doesn’t work :
here is the script :
P.NEXT
IF BGET P.HERE 0:TR.P D
IF BGET P.HERE 1:TR.P C
IF BGET P.HERE 2:TR.P B
IF BGET P.HERE 3:TR.P A
1010 gives me only C pulsing
10 gives A and C
i would expect the contrary.
ah sorry i misread your question. for what you want it should be:
IF % / A 1 2: TR.P 1
IF % / A 10 2: TR.P 2
IF % / A 100 2: TR.P 3
IF % / A 1000 2: TR.P 4
BGET X n
gives you the value of n
th bit in number X
Ah that’s it !
Many thanks (and i get why my previous script doesn’t work)