strtok()
Andrew C. Greenberg
werdna at gate.net
Tue Sep 21 03:25:33 UTC 1999
>Howdy,
>
>is there a method in Squeak like:
>
>strtok() in C, or better yet "word 7 of line 3 of blah" in hypercard?
Yes, of course.
You can get a collection of tokens using String>>findTokens: You can
also get a line from a string using String>>lineNumber: There are a
gaZillion cool ways to manipulate string in class String, which you
can peruse with the DoIt:
String browse
The following block does the hypercard thing, albeit in a rough and
ready fashion:
hypercard := [:str :line :word |
((str lineNumber: line) findTokens: ' ') at: word].
and
string := 'now is the winter of our discontent
made glorious summer by this
son of York'
so that
get value: string value: 2 value: 3
evaluates to 'summer'
More information about the Squeak-dev
mailing list
|