Help - Environment - Workspaces - 3

Previous - Workspaces - Next

3. Transcripts

A Transcript is an editable Textwindow that also can be saved to which Squeak writes information if it has any that's relevant, e.g. about saving. It is also available to port information to. You can also use it as a calculating window in cooperation with a Transcript window.

This is done as follows from a Workspace. Open a Transcript window from the Tools flap and place this Workspace and the Transcript Window so that both are visible.

Now select the following line and do Cmd-d with "d" for "doit" it

Transcript show: 'Hello ... this is Squeak '

The Transcript shows "'Hello ... this is Squeak ".

Next, there is the mighty

Transcript clear

Incidentally, if you do Select-Cmd-p on the above Transcipt instructions what results is not an updated Transcript window but instead " a TranscriptStream".

And since I remarked upon it and it IS very useful to SAVE A WORKING IMAGE OFTEN one may as well at this point do (World Menu - save) and see something like

----SNAPSHOT----#(7 December 2001 2:55:48 am)

appear in the Transcript window.

You can also do a sequence of such commands in one go. Select all of the following three lines and Cmd-doit

Transcript clear. "Explanation below"
Transcript clear; show: 'Hello, today it is: '; cr.
Transcript show: Date today.

The last three kines are made up of lines of code in SqL together with Comments, that in this case tell the human reader the line number for convenient reference. Squeak when valueing the three lines ignores and in fact skips all comments i.e. all the bits between double quotation marks.

Now line 1 above we have used before and can also select independently and select to meanwhile known effect.

Line 2 is called a Cascade. This is a series of Expressions of SL separated by ; . In the present case, there are three:

show: 'Hello, today it is: ';

which when Selected+Cmd-d result in error-notifications (which you can read and remove with Backspace or Cmd-z). Since each line in fact is a fragment of a valid Message and not a Message this is intuitively correct.

What the colons ; do in the original  is to assure that the resulting values of each of these lines are sent successively to the Transcript window as a Transcriptstream where it is displayed.

Here are some simple examples to try. You can rewrite the numbers inside Scamper. (Indeed, you can write any code in Scamper as in a Workspace.)

| with in |
with := 2.
in := 5*with.
Transcript clear; show: in

Another simple example:

| a b c |
a := 3 squared.
b := 4 squared.
c := (a+b) sqrt.
Transcript clear; show: c.

This shows something about permutations

| count choice |
count := 0.
[ count < 101 ] whileTrue:
[choice := 100 take: count.
"Here the calculation gets done. Try Cmd-m on take:"
Transcript show: count; tab; tab; show: choice ; cr. count := count+5.]

What time is it? Do Cmd-p on:

Date dateAndTimeNow.

The date 18025 days after 1.1.1901. Works also with negative numbers.

Date fromDays: 18025. "The date 18025 days after 1.1.1901. Find your own birthdate in these terms."
Date fromDays: -694326
"A historical date, it is rumored: Works also with negative numbers."

Here is a lesson of history. Randolph J. Rummel decided to try to find out who were the great mass-murderers of the 20th Century. This is derived from one of his tables (p.8) in his book 'Death by Government'. Note we are talking of civilian victims, not military victims. We are talking of people who got arrested and 'disappeared', not of people who volunteered for or were forced to military battle. I list the dictators and assign the number of his civilian victims, according to Mr Rummel. So here are some historical variables for you to play with in various simple - truly cliometric - ways!

How to do this? For example, like so

Select the following Cmd-d all assignments (line by line). This gives you a DictionaryInspector, which has an editwindow as its lowest pane. It starts with being empty.

| dictators |
dictators := Dictionary new.
dictators add: 'stalin' -> 42672000.
"Russia. 1929-1953"
dictators add: 'mao' -> 37828000. "China. 1923-1976"
dictators add: 'hitler' -> 20946000.
"Germany. 1933-1945"
dictators add: 'chiang' -> 10214000. "China. 1921-1948"
dictators add: 'lenin' -> 4017000.
"Russia. 1917-1924"
dictators add: 'tojo' -> 3990000.
"Japan. 1941-1945"
dictators add: 'pot' -> 2397000.
"Cambodia. 1968-1987"
dictators add: 'khan' -> 1500000.
"Pakistan. 1971."
dictators add: 'tito' -> 1172000.
"Yugoslavia. 1941-1987"
dictators inspect

Enlarge the editwindow to about a third of the screen, and put a Transcript (Cmd-t) next to it.

Now, select the following text and copy it to the editwindow of the DictionaryInspector on dictators, and try it out there. The editwindow works much like a workspace and you can cross-copy from and to workspaces. With the editwindow you can send messages to the inspected object (addressed by 'self'). You can open a Browser on key words, and search with Cmd-m and Cmd-n on methods if you want to find out more.

== begin code for copying to edit window in Dictators dictionary

Recasting the Dictionary as an OrderedCollection
and summing the values with Cmd-d

| oc count end victims |
oc := self asOrderedCollection.
count := 1.
end := (oc size)+1.
victims := 0.
[count < end] whileTrue: [ | item | item := oc at: count. victims := victims + item. count := count + 1.].
Transcript cr; show: 'victims total: '; show: victims

Simple questioning with Cmd-p

self at: 'mao'.
self at: 'stalin'.
self keys.
self values.

The blessings of marxist socialism illustrated with Cmd-d

| mao stalin lenin pot tito victims |
mao := self at: 'mao'.
stalin:= self at: 'stalin'.
lenin := self at: 'lenin'.
pot := self at: 'pot'.
tito := self at: 'tito'.
victims := mao+stalin+lenin+pot+tito.
Transcript cr; cr; show: 'marxist victims total: '; show: victims

And some simple comparisons with Cmd-d

| mao stalin lenin |
mao := self at: 'mao'.
stalin:= self at: 'stalin'.
lenin := self at: 'lenin'.
Transcript cr; show: 'lenin/(stalin + lenin) = '; show: lenin/(stalin + lenin) asFloat.
Transcript cr; show: 'stalin/(stalin + mao) = '; show: stalin/(stalin + mao) asFloat.

You now know how you can design your own lessons from history! To measure is to know, as the saying goes (Dutch: meten is weten), and cliometrics is a - would be - serious part of history, that would be much helped by a tool like Squeak. Its name incorporates that of Clio, the Greek muse of history.

=== end code for copying to edit window in Dictators dictionary

Previous - Workspaces - Next