? bin$(button()) is great! (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

bin$(button()) is great!

  • #1 ✎ 34 KHypno I just found an amazing way to do multi-button input. Try this: ACLS WHILE 1 PRINT BIN$(BUTTON()) VSYNC CLS WEND Posted Edited by KHypno
  • #2 ✎ 404 hakke RNG Hidden Easter Eggs QSP Contest 2 Contest Participant I participated in the second SmileBASIC Source QSP Contest! Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength You can also do multi-button input using the AND operator: 'Check L and R WHILE 1 IF BUTTON(1) AND (#L OR #R) THEN PRINT "L and R!" VSYNC WEND This works because the return value of BUTTON is a bitmask, that means every button has a single bit in the return value. The AND operator will return all the shared bits in both operands (&b1001 AND &b1011 == &b1001), and OR will return all the bits in both (&b1001 OR &b0110 == &b1111) Posted
  • #3 ✎ 1357 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements Tbh, you don't need to do exactly ?BIN$(BUTTON()) you can do just ?BUTTON() or ?BUTTON(0) BIN$ just makes it binary. It's what you put in () after BUTTON that effects that. Look at the help page for button. Posted
  • #4 ✎ 34 KHypno Mid$()!!! Posted
  • #5 ✎ 1357 rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements
    Mid$()!!!
    what does that have to do with this?
    Posted