Chunk Syntax
Single Chunks
Syntax:
chunk number of expression
In this and the following syntax descriptions, chunk is used to represent any of the chunk types: character
(or its abbreviation, char
), word
, line
, item
, text item
, or list item
. Similarly, chunks represents the plural version of these terms. number is a factor which evaluates to a positive or negative number, and expression is the source or destination value which the chunk refers to. Wherever the word "of" is shown, you may use either “of” or “in”, whichever seems natural to you at the time.
Chunk expressions for all types of chunks can be expressed in several different ways. You can describe a single chunk element:
put item 17 of scores into quiz3
put word 4 of "Mary had a little lamb" --> "little"
Negative numbers can be used to count backwards from the end of the source, with -1 indicating the last chunk element, -2 for the next-to-last, and so forth:
put item -2 of "apple,banana,pear,orange" --> "pear"