1

Hi I have an ordered collection of strings which I'm trying to display on a list widget. I do the following:

self displayWidget list: coll.

where displayWidget is a List Widget and coll is the OrderedCollection containing the strings. It will display it, but it displays it in a single line.

Instead of getting

line one
line two
line three

I get:

line oneline twoline three 

I'm using visual works.*

nes1983
  • 15,209
  • 4
  • 44
  • 64
user69514
  • 26,935
  • 59
  • 154
  • 188

2 Answers2

1

Inside list: you probably want something similar to

coll do: [:element | Transcript show element; cr]

When you send do: [:e | ...] to a collection it evaluates the block once for each element in the collection, each time passing the element into element.
Each time I'm sending cr to Transcript to add a carriage return after each element.

Greg Leaver
  • 801
  • 6
  • 10
0

You can iterate the collection and send withCRs message to the Strings.

Here is an simple example:

| i |

i:= 0. [i < 5] whileTrue: [ Transcript show: 'Hello world.\' withCRs. i := i +1.

]

withCRs method replace each \ ocurrence for a new line and carry return.

Hope it helps you.

z-index
  • 409
  • 8
  • 14