![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Sometimes, names consist of multiple words,
making it impracticable to rely entirely on nextWord
to do all the
reading that you need to do. Often, names are marked by delimiters on
both ends, as in the following example, so that multiple words cause no
problems:
'Raw Carrots' 1 33 4 'Broccoli' 3 16 9 'Corn on the Cob' 1 23 6 'Cooked Cabbage' 2 14 3
To deal with files containing such information, you need the upTo:
message, which, when sent to a stream, answers with a string containing all
the characters up to the next occurrence of the character provided as the
argument. The argument character is absorbed, but is not included with the
answer string. If the argument character does not exist in the rest of the
stream, upTo:
answers the remaining elements in the stream.
Define nextMarkedWord:
using upTo:
such that
nextMarkedWord:
answers the next sequence of characters delimited by
the character provided as the argument. If there are no such marked
characters, nextMarkedWord:
is to answer nil
.