Hi, everyone!
I have a student that created a keypad in his CoSpace. He would like to create a program so that when the numbers are pressed on the keypad they are then displayed next to the keypad in a text panel.
Here is his space: CoSpaces Edu :: All About Me by Zac
It is set for remixing. I would like to show him an example of how it can be done and then have him recreate the program to his specifications.
Any help would be greatly appreciated!
Here’s a simple starting version:
Thank you so much! I’ll share this example with my student!
How could the program then cause something to happen if a certain set of numbers are pressed?
Well, the string is already in a variable, so just run a conditional check on the variable (after the number is added) to see if it matches the numbers you want, and if it does, make something happen.
1 Like
I was trying this but it doesn’t work:
Type-casting in CoBlocks has some flexibility for string to number, but probably not the other way round.
Because you’re typing in a sequence of characters into a text string (which happen to be numbers, but could be anything), you need to check against a string, not a number.
Does that make sense?
I thought that’s what I was doing. For the if/else block, the space with the “12” in it is a text box correct?
Actually, I just tried the same thing in my remix above (I’ve updated the share) and it worked fine, so it must be something else.
The space with the 12 is a number; however, CoBlocks can now interpret strings as numbers and so do that comparison effectively.
If you want a string/text value, it’s available in the Advanced CoBlocks, under Data > Values:

1 Like
Thank you! That make sense. I’ll share the example with my student.