-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
digital state read to test for If or While loop #2753
Comments
I think we should remove the check on if/else and while blocks or at least let numbers and strings be dragged in. My only concern is that it might be weird with Scratch blocks, where different types are different shapes. |
@riknoll, so will the digital read pin return to a string and not an int or bool? If so, that should probably be what changes. The only possible outcomes from a digital read will be 1 or 0 and that should resolve as True or False in the test. If the currant test looks for an int, making digital read pin return as an int should fix it unless there is a reason digital read pin needs to return another data type. |
@richard1 I'm not suggesting that we change the digital read API, it will still return a number. I'm just suggesting that we change the if/else and while blocks so that you can drag numbers and strings into them without them bouncing out (the current behavior only let's you drag in variables and booleans) |
Ah, so if we first assigned the digital read pin to a variable, then added that variable to the test, would that work? Is there a reason why digital read pin it not returning a boolean? |
Mostly historical and backward compat reasons. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This issue has been tested using the target Micro:bit in Make Code
https://makecode.microbit.org/
Currently, in Blocks, a user cannot add a digital state read to the test for if or while loop. You can find a picture of the attempt to place Digital State Read for If. Here is example code in JavaScript below:
Using Blocks, it appears a user can add a digital state read to test for if or while loop. So you can find a logic fix that was tried using Digital Read Pin. However, this attempt was not successful on the physical device. You can find the JavaScript below:
It appears that the only way to resolve this logic issue (Digital State Read to test for If or While loop) is with a more complicated implementation using Blocks. You can find the fix below:
Can you implement digital state read to test for If or While loop?
Issue discovered by Richard Albritton
The text was updated successfully, but these errors were encountered: