Printing numbers to the transcript window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Printing numbers to the transcript window

Jerome Chan
How come I can't do this in Dolphin Smalltalk 4.0?

1 to: 100 do: [
   :index |
   Transcript show: index ; cr.
]

I get a SmallInteger(Object)>>DoesNotUnderstand response.


Reply | Threaded
Open this post in threaded view
|

Re: Printing numbers to the transcript window

Daryl Richter
Look up the method, the full signature is Transcript>>show: aString.

Therefore, try the following:

1 to: 100 do: [ :index | Transcript show: index displayString ; cr. ]

--
Regards,
Daryl

<< Sun, Zoom, Spark! >>


"Jerome Chan" <[hidden email]> wrote in message
news:[hidden email]...

> How come I can't do this in Dolphin Smalltalk 4.0?
>
> 1 to: 100 do: [
>    :index |
>    Transcript show: index ; cr.
> ]
>
> I get a SmallInteger(Object)>>DoesNotUnderstand response.


Reply | Threaded
Open this post in threaded view
|

Re: Printing numbers to the transcript window

Louis Sumberg
In reply to this post by Jerome Chan
#show: expects a String argument, which you can see if you bring up the
debugger (the 8th line) when you get the walkback.  Change the expression to
Transcript show: index printString and it works fine.

Jerome Chan <[hidden email]> wrote in message
news:[hidden email]...
> How come I can't do this in Dolphin Smalltalk 4.0?
>
> 1 to: 100 do:

>    :index |
>    Transcript show: index ; cr.
> ]
>
> I get a SmallInteger(Object)>>DoesNotUnderstand response.


Reply | Threaded
Open this post in threaded view
|

Re: Printing numbers to the transcript window

Don Rylander
Take a look at the #print: and #display: methods for Transcript, too.  They
provide a nice shorthand way to get an object to #printOn: or to #displayOn the
Transcript's buffer.

Don


Reply | Threaded
Open this post in threaded view
|

Re: Printing numbers to the transcript window

Jerome Chan
In reply to this post by Daryl Richter
In article <oyCf6.15203$[hidden email]>, "Daryl
Richter" <[hidden email]> wrote:

> Look up the method, the full signature is Transcript>>show: aString.
>
> Therefore, try the following:
>
> 1 to: 100 do: [ :index | Transcript show: index displayString ; cr. ]
>

Hrm. Is there a standard for Transcript? The code worked under Squeak,
and Smalltalk/X.