![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Generally, doing formatted display and formatted writing means writing information into fields of prescribed width.
Suppose, for example, that you want to define a method,
formatWithWidth:
, for strings, such that formatWithWidth:
produces a string whose length is equal to a prescribed field width. Your
method is to add padding spaces on the left. In the following
example, formatWithWidth:
produces a string of length 10; the string
is concatenated with vertical bars so as to make the presence of the spaces
clear:
Workspace Transcript show: '|' , ('Broccoli' formatWithWidth: 10) , '|' Transcript | Broccoli|