Read-eval loop with prompt + user input
Hannes Hirzel
hirzel at spw.unizh.ch
Thu Mar 14 19:18:31 UTC 2002
On 14 Mar 2002, Martin Drautzburg wrote:
> Bert Freudenberg <bert at isg.cs.uni-magdeburg.de> writes:
>
> > That's called a Workspace in Squeak. Open it from the world menu or the
> > right flap.
>
> Thanks, I wasn't aware of the fact that you don't have to highlight
> before pressing Alt-D. But how could I read user Input from the
> Workspace, other than commands. I mean something like
> login:
> password:
>
You can write your own commands that take parameters:
Create a class DrautzburgUtilities with some class methods.
Then you can call these methods froma workspace with
DrautzburgUtilities myFirstMethodForUser: 'Martin' password: 'Rhein'.
In Smalltalk terminology a message send consists of a selector and
arguments.
In the example
#myFirstMethodForUser:password:
is the selector, while
'Martin' and 'Rhein'
are the parameters.
Within the method you can do your things. Using class side methods
results in having a singleton.
With this approach you can build a up a text based user interface
in no time:
Just have a workspace open with some command in it - click at the line you
are interested in and hit ALT-D. This works similar to Oberon. (Well
actually Wirth copied the concept from Smalltalk).
Various GUI oriented approaches are possible as well, but need more time.
Cheers
Hannes Hirzel
More information about the Squeak-dev
mailing list
|