Discuss Scratch

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 []
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
Let me know if it works!
EggDOG_MyNAME--Jeff
Scratcher
100+ posts

How can I capitalize every other letter in a word?

supernavo wrote:

Make 2 lists. Name them “abc and ”ABC." Then go through the letters like this:
set [new string v] to []
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
Let me know if it works!
remember to add a
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.
supernavo
Scratcher
1000+ posts

How can I capitalize every other letter in a word?

EggDOG_MyNAME--Jeff wrote:

supernavo wrote:

Make 2 lists. Name them “abc and ”ABC." Then go through the letters like this:
set [new string v] to []
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
Let me know if it works!
remember to add a
change [i v] by (1)
Right below the if else block inside of the repeat loop, or else it won't work.
I accidentally forgot i..I… oops!

Powered by DjangoBB