Problem
You want to access portions of a string. For example, you have read a comma delimited record and you want to extract the fields.
Solution
Use the built in String method subStrings: This method breaks up a string at the given character. Evaluate the following in Dolphin Smalltalk for an example:-
Imagine you have a comma delimited customer record containing the fields firstName, lastName, emailAddress, phoneNumber and faxNumber; you can extract the first name like so:-
('Gary,Short,gary@here.com,02745 555 888, 02745 555 777' subStrings: $,) at: 1
You can access all the fields thusly:-
('Gary,Short,gary@here.com,02745 555 888, 02745 555 777' subStrings: $,)
do: [:each | Transcript show: each; cr ]