Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to delete a character from a variable
- -PolyCode-
-
Scratcher
77 posts
How to delete a character from a variable
I am making a mobile-friendly keyboard, but long story short, I am not sure how to get the delete function to work when you click on the delete key. Any ideas? Thanks. https://scratch.mit.edu/projects/793729142/
- medians
-
Scratcher
1000+ posts
How to delete a character from a variable
Add all the characters of the variable to a list, delete whatever item of the list you want to remove (if you want to remove the last item, just copy and paste last into the dropdown or use item (length of list) of list), and then add everything from the list to the variable.
Any questions?
Edit: Also make sure the list is cleared at first.
Any questions?
Edit: Also make sure the list is cleared at first.
Last edited by medians (Jan. 27, 2023 02:25:20)
- -PolyCode-
-
Scratcher
77 posts
How to delete a character from a variable
I think that makes sense, thanks!
- TheFelipeGuy
-
Scratcher
3 posts
How to delete a character from a variable
Put this script inside a run without screen refresh block.
define [delete the last (1) characters of (text)]
delete (all v) of [result v]
set [index v] to [0]
repeat (length of(text))Put that inside a run without screen refresh block.
change [index v] by (1)
add (letter (index) of (text)) to [list v]
end
repeat (amount)
delete (length of (result)) of [result v]
end
set [result v] to (result)
Last edited by TheFelipeGuy (March 2, 2023 15:37:03)
- Discussion Forums
- » Help with Scripts
-
» How to delete a character from a variable



