Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to delete a letter of a word/variable/item of a list etc
- Slimmmmmmmmm
-
Scratcher
20 posts
How to delete a letter of a word/variable/item of a list etc
Ok I will tell you how to make a script that can delete a letter of a word/variable/item of a list etc.
Step1
Create a variable called Output
Create another variable called numbers
Step 2
Create this script
Step 3
Add the repeat script to the script.
This will split up the letters in the input.
Step 4
Add The delete and repeat script to it and your done.
Step1
Create a variable called Output
(Output)This is where the output is going to go to. Also create a list called letters.
(Letters :: list)This is a list where all the letters will get split up.
Create another variable called numbers
(numbers)I can't explain what it does but you have to create this variable.
Step 2
Create this script
define Delete letter (letter) of (input)This will clear out everything when you use this script.
set [number v] to [0 ]
delete [all v] of [Letters v]
set [output v] to [ ]
Step 3
Add the repeat script to the script.
define Delete letter (letter) of (input)
set [number v] to [0 ]
delete [all v] of [Letters v]
set [output v] to [ ]
repeat (length of (input))
change [number v] by (1)
add (letter (number) of (input)) to [Letters v]
end
This will split up the letters in the input.
Step 4
Add The delete and repeat script to it and your done.
define Delete letter (letter) of (input)Thanks for viewing this tutorial! Also what it will return is this
set [number v] to [0 ]
delete [all v] of [Letters v]
set [output v] to [ ]
repeat (length of (input))
change [number v] by (1)
add (letter (number) of (input)) to [Letters v]
end
delete (letter) of [Letters v]
set [number v] to [0]
repeat (length of [Letters v] ::list)
change [number v] by (1)
set [output v] to (join (output) (item (number) of [Letters v])
end
Delete letter (1) of []::custom
Last edited by Slimmmmmmmmm (April 2, 2016 02:11:29)
- deck26
-
Scratcher
1000+ posts
How to delete a letter of a word/variable/item of a list etc
Note that the idea of the forum is for people to ask for help, not for tutorials.
I think this can be done more simply.
Clear a temporary variable. Create a loop that runs from 1 to n (the length of the input). The index value for that loop is compared to the number of the letter to be removed and if it matches you don't add that letter but if it doesn't match you do add it.
I think this can be done more simply.
Clear a temporary variable. Create a loop that runs from 1 to n (the length of the input). The index value for that loop is compared to the number of the letter to be removed and if it matches you don't add that letter but if it doesn't match you do add it.
set [tempword v] to [ ]If you want to do this in a custom block you'd need the output variable as used in your scripts as you can't pass back a change to input.
set [indx v] to [1 ]
repeat (length of [input])
if <[indx v] = [letter v ]> then
set [tempword v] to (join [tempword v] (letter (indx) of [input])
end
change [index v] by (1)
end
set [input v] to (tempword )
- PrizmGames
-
Scratcher
56 posts
How to delete a letter of a word/variable/item of a list etc
delete ((position)) of ((variable))
change [(position) v] by (0)
Last edited by PrizmGames (Jan. 22, 2016 13:47:16)
- BKFighter
-
Scratcher
1000+ posts
How to delete a letter of a word/variable/item of a list etc
Please do not necropost, as this topic was last used over a year ago.delete ((position)) of ((variable))
change [(position) v] by (0)
- redmadd
-
Scratcher
2 posts
How to delete a letter of a word/variable/item of a list etc
.
Last edited by redmadd (Aug. 23, 2023 00:56:20)
- Discussion Forums
- » Help with Scripts
-
» How to delete a letter of a word/variable/item of a list etc