Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can I capitalize every other letter in a word?
- daynaur
-
New Scratcher
3 posts
How can I capitalize every other letter in a word?
I know there are ways to have every letter of a word capitalized, but I can't figure out how to capitalize every other letter only. How can I do this?
- supernavo
-
Scratcher
1000+ posts
How can I capitalize every other letter in a word?
Make 2 lists. Name them “abc and ”ABC." Then go through the letters like this:
set [new string v] to []Let me know if it works!
set [i v] to [1]
repeat (length of (string))
if <((i) mod (2)) = [1]> then
set [new string v] to (join (new string) (item (item # of (letter (i) of (string)) in [abc v]::list) of [ABC v])
else
set [new string v] to (join (new string) (letter (i) of (string))
end
end
- EggDOG_MyNAME--Jeff
-
Scratcher
100+ posts
How can I capitalize every other letter in a word?
Make 2 lists. Name them “abc and ”ABC." Then go through the letters like this:remember to add aset [new string v] to []Let me know if it works!
set [i v] to [1]
repeat (length of (string))
if <((i) mod (2)) = [1]> then
set [new string v] to (join (new string) (item (item # of (letter (i) of (string)) in [abc v]::list) of [ABC v])
else
set [new string v] to (join (new string) (letter (i) of (string))
end
end
change [i v] by (1)Right below the if else block inside of the repeat loop, or else it won't work.
- deck26
-
Scratcher
1000+ posts
How can I capitalize every other letter in a word?
Or a single list will do.
If you have A-Z and a-z in a list any match will find the capital letter but you can just add 26 to get the lower-case letter.
Note that you need the item # of letter i in each case but my adjustment would be (item # of letter i) + 26 for every second letter.
If you have A-Z and a-z in a list any match will find the capital letter but you can just add 26 to get the lower-case letter.
Note that you need the item # of letter i in each case but my adjustment would be (item # of letter i) + 26 for every second letter.
- supernavo
-
Scratcher
1000+ posts
How can I capitalize every other letter in a word?
I accidentally forgot i..I… oops!Make 2 lists. Name them “abc and ”ABC." Then go through the letters like this:remember to add aset [new string v] to []Let me know if it works!
set [i v] to [1]
repeat (length of (string))
if <((i) mod (2)) = [1]> then
set [new string v] to (join (new string) (item (item # of (letter (i) of (string)) in [abc v]::list) of [ABC v])
else
set [new string v] to (join (new string) (letter (i) of (string))
end
endchange [i v] by (1)Right below the if else block inside of the repeat loop, or else it won't work.
- Discussion Forums
- » Help with Scripts
-
» How can I capitalize every other letter in a word?