Put into a chunk
Chunks are not only for reading. You can put text into a chunk to replace it, or before or after it to add to it, and xTalk changes just that piece of the variable.
put "I like cats" into tText
put "dogs" into word 3 of tText
put tText
put "really " before word 2 of tText
put "!" after tText
put tText
put "Y" into char 1 of tText
put tText
I like dogs I really like dogs! Y really like dogs!
Lists grow to fit
Put something into an item or line that does not exist yet, and xTalk adds the separators needed to reach it.
put "a,b" into tList
put "e" into item 5 of tList
put tList
put "first" into line 3 of tLines
put the number of lines of tLines
a,b,,,e 3
Delete a chunk
delete removes a chunk, and the separator with it, so a list stays a tidy list.
put "I really like dogs!" into tText
delete word 2 of tText
put tText
put "red,green,blue" into tColours
delete item 2 of tColours
put tColours
put "Hello" into tWord
delete the first char of tWord
put tWord
I like dogs! red,blue ello
Replace every copy
replace changes every copy of one string into another, all through a variable or a field.
put "the cat sat on the mat" into tText
replace "at" with "og" in tText
put tText
put "1,234,567" into tNumber
replace comma with empty in tNumber
put tNumber + 1
the cog sog on the mog 1234568
Capitals
toUpper and toLower give a copy of a string in capitals or in small letters. They know the accented letters of other languages too, though a letter with no single capital, like the German ß, stays as it is.
put toUpper("shout") && toLower("QUIET")
put toUpper("café") && toLower("ÉCOLE") && toUpper("straße")
put "ada" into tName
put toUpper(char 1 of tName) into char 1 of tName
put tName
SHOUT quiet CAFÉ école STRAßE Ada
Try it yourself
Take the quick brown fox and give every word a capital first letter, so it reads The Quick Brown Fox.
Show a solution
put "the quick brown fox" into tText
repeat with i = 1 to the number of words of tText
put toUpper(char 1 of word i of tText) into char 1 of word i of tText
end repeat
put tText
The Quick Brown Fox
Words in this lesson
Each one finds every lesson that uses it. The Dictionary has the whole story of each, with its syntax and more examples.