Discuss Scratch
- ipushpeople
-
Scratcher
100+ posts
Replace letter () of () with ()
well i don't understand it so i must be very stupid and am now very discouraged to use scratch.on a scale of “simple workaround” to “not simple workaround” i would rate that “very not simple workaround”define replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
-D
All they have to do is copy the script and use the custom block to do what they need…
(And this is very simple programming anyway…)
and in my opinion telling someone to copy a block of code line by line is not a way to teach them how to program.
-D
- A-KouZ1
-
Scratcher
100+ posts
Replace letter () of () with ()
…define replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
you know when you replace a thing on list…
list reporter will be spacing
- alexphan
-
Scratcher
1000+ posts
Replace letter () of () with ()
/bump
If you don't understand it, then try to understand and learn it instead of putting yourself down.
well i don't understand it so i must be very stupid and am now very discouraged to use scratch.on a scale of “simple workaround” to “not simple workaround” i would rate that “very not simple workaround”define replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
-D
All they have to do is copy the script and use the custom block to do what they need…
(And this is very simple programming anyway…)
If you don't understand it, then try to understand and learn it instead of putting yourself down.
- A-KouZ1
-
Scratcher
100+ posts
Replace letter () of () with ()
More logic blocks
set [mytext v] to [there's is manyyyyyyyyyyyyy typos here]
replace letter between (16) to (27) with [] of (mytext)//if u want remove a letter lol
set [mytext v] to (output::list)
define replace letter between (least) to (most) with (new) of (string)
delete [all v] of [output v]
set [i v] to [0]
repeat ((least)-(1))
change [i v] by (1)
add (letter (i) of (string)) to [output v]
end
set [i v] to [0]
repeat ((most)-(least))
change [i v] by (1)
add (letter (i) of (new)) to [output v]
end
set [i v] to ((most)+(1))
repeat ((length of (string))-(most))
change [i v] by (1)
add (letter (i) of (string)) to [output v]
end
- StrangeMagic32
-
Scratcher
1000+ posts
Replace letter () of () with ()
Support! This would help edit cloud variables without overwriting others writing, would especially be helpful for online games, this way you don't have to use 1 variable per player, meaning more than 10 players can be on at once.
Last edited by StrangeMagic32 (Aug. 21, 2019 21:22:17)
- itchdog
-
Scratcher
100+ posts
Replace letter () of () with ()
No support, this was added in 3.0, reportig to be closed
- Botcho_Otkho
-
Scratcher
1000+ posts
Replace letter () of () with ()
this was added in 3.0No.
Maybe you got confused with the
<[] contains []?::operators>
Last edited by Botcho_Otkho (Aug. 7, 2019 17:28:05)
- 15-MinuteGaming
-
Scratcher
100+ posts
Replace letter () of () with ()
Support. Although there is a very simple workaround, it is an extremely commonly encountered problem in programs
- chrdagos
-
Scratcher
500+ posts
Replace letter () of () with ()
This is a interesting idea. Such block will allow for things like spell checking in projects.
(I like this idea)
- CodeMasterExpert
-
Scratcher
3 posts
Replace letter () of () with ()
What Breck- wrote doesn't work:
Breck- wrote:define replace letter (letter) of (text) with(string)
set (i v) to[1]
repeat(length of (text)
add (letter (i) of (text)) to [tmp v]
change (i) by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp)
- redgreenandblue
-
Scratcher
100+ posts
Replace letter () of () with ()
For the record, I still think this block would be really helpful.
- sillyman987
-
Scratcher
26 posts
Replace letter () of () with ()
I think there should be aHi! So I gave this some thought, and I have two solutions decoding it into a list then encoding back, or using this:(replace letter () of [] with []::operators)This would be extremely helpful for variables!
It would show in the block library as(replace letter (1) of [jello world!] with [h]::operators)If somebody knows a simple workaround that would also work.
when green flag clicked
<(Variable) = [35]>
set [ Variable] to (join (letter (1) of (Variable)) (join [6] (letter (2) of (Variable))))
<(Variable) = [365]>
- NxNmultiply
-
Scratcher
100+ posts
Replace letter () of () with ()
Support because it is a fundamental array write operation, which Scratcch doesn't currently have.
- littleBitsman1
-
Scratcher
2 posts
Replace letter () of () with ()
I think there should be athey should add that(replace letter () of [] with []::operators)This would be extremely helpful for variables!
It would show in the block library as(replace letter (1) of [jello world!] with [h]::operators)If somebody knows a simple workaround that would also work.
smh they havent done that yet ;-;
Last edited by littleBitsman1 (March 22, 2021 14:08:40)
- ScratchCat8464
-
Scratcher
16 posts
Replace letter () of () with ()
Simplified way
Run without screen refreshdefine Replace letter (a) of (b) with (c)
set [count v] to [0]
set [result v] to []
repeat (length of (b))
change [count v] by (1)
if <(count) = (a)> then
set [result v] to (join (result) (c))
else
set [result v] to (join (result) (letter (count) of (b))
end
end
Replace letter (6) of [hello?] with [!]
say <(result) = [hello!]>
Last edited by ScratchCat8464 (June 26, 2021 04:39:19)
- elip100
-
Scratcher
100+ posts
Replace letter () of () with ()
thank you!!! this was very usefull!define replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
Last edited by elip100 (July 7, 2021 14:30:46)
- ScratchCat8464
-
Scratcher
16 posts
Replace letter () of () with ()
in my method you don't need to create a listthank you!!! this was very usefull!define replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
- PenguinLover1123
-
Scratcher
1000+ posts
Replace letter () of () with ()
I think there should be aOMEGA SUPPORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! because it's useful(replace letter () of [] with []::operators)This would be extremely helpful for variables!
It would show in the block library as(replace letter (1) of [jello world!] with [h]::operators)If somebody knows a simple workaround that would also work.
it's a stack, not a reporterdefine replace letter (letter) of [text] with [string]
set [i v] to [1]
repeat (length of (text))
add (letter (i) of (text)) to [tmp v]
change [i v] by (1)
end
replace item (letter) of [tmp v] with (string)
set [result v] to (tmp :: list)
- ScratchCat8464
-
Scratcher
16 posts
Replace letter () of () with ()
More logic blockseasiest method:set [mytext v] to [there's is manyyyyyyyyyyyyy typos here]
replace letter between (16) to (27) with [] of (mytext)//if u want remove a letter lol
set [mytext v] to (output::list)
define replace letter between (least) to (most) with (new) of (string)
delete [all v] of [output v]
set [i v] to [0]
repeat ((least)-(1))
change [i v] by (1)
add (letter (i) of (string)) to [output v]
end
set [i v] to [0]
repeat ((most)-(least))
change [i v] by (1)
add (letter (i) of (new)) to [output v]
end
set [i v] to ((most)+(1))
repeat ((length of (string))-(most))
change [i v] by (1)
add (letter (i) of (string)) to [output v]
end
define replace letter between (least) to (most) with (new) of (string)
set [output v] to []
set [count v] to [0]
repeat (length of (string))
change [count v] by (1)
if <(count) = (least)> then
set [output v] to (join (output) (new))
else
if <not <<((least) - (1)) < (count)> and <((most) + (1)) > (count)>>> then
set [output v] to (join (output) (letter (count) of (string))
end
end
end
replace letter between (4) to (6) with [] of [easiwyy!]
say (output)
//output = easy!














