Keyboard input - programming course

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

Keyboard input - programming course

Stephen-71
Hi all,

We wish to use Squeak/Smalltalk for a beginner programming course and
require the simplest way to get keyboard input.

First of all:-
  - is there a way in Squeak to get console input (analogous to
system.in, in Java)? Line input would be ideal, rather than character by
character.
  - how would one display a text label and a text field and obtain input
from the text field (am thinking of Morphic)

Thank you for your assistance.

Stephen
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Bert Freudenberg

On 04.07.2011, at 09:45, Stephen Woolerton wrote:

> Hi all,
>
> We wish to use Squeak/Smalltalk for a beginner programming course and require the simplest way to get keyboard input.
>
> First of all:-
> - is there a way in Squeak to get console input (analogous to system.in, in Java)? Line input would be ideal, rather than character by character.

There is a way, but it is complicated, platform-dependent, and very rarely used. Squeak provides its own user interface, the command line interface is only used for e.g. server apps.

> - how would one display a text label and a text field and obtain input from the text field (am thinking of Morphic)

        name := UIManager default request: 'Enter your name'.
        Transcript show: name; cr.

However, IMHO this is *not* the best way to introduce Squeak programming to beginners. It mimics procedural programming in a console.

Instead, just open a Workspace and begin evaluating expressions. There doesn't have to be a "program". In fact, there is no "main". Just send messages to objects.

        3 + 4
        1234 / 56
        100 factorial
        'foo bar' asUppercase

Then, make a Morph and send it messages. Evaluate each line individually to see its effect.

        joe := Morph new.
        joe openInWorld.
        joe position: 100@100.
        joe color: Color red.

From there I'd continue with inspectors and explorers. Squeak by Example is an excellent source for further exploration:

        http://squeakbyexample.org/

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Stephen-71


>> - how would one display a text label and a text field and obtain input from the text field (am thinking of Morphic)
>
> name := UIManager default request: 'Enter your name'.
> Transcript show: name; cr.
>
Thank you - this is exactly what I was looking for - the simplest way of
getting input.

> However, IMHO this is *not* the best way to introduce Squeak programming to beginners. It mimics procedural programming in a console.
>
I fully agree with you. The reason is that there are external criteria
which we have to meet. The criteria requires keyboard input, and
personally have only used Squeak for Seaside projects so didn't know how
to do this simple thing :-)

> Instead, just open a Workspace and begin evaluating expressions. There doesn't have to be a "program". In fact, there is no "main". Just send messages to objects.
>
> 3 + 4
> 1234 / 56
> 100 factorial
> 'foo bar' asUppercase
>
> Then, make a Morph and send it messages. Evaluate each line individually to see its effect.
>
> joe := Morph new.
> joe openInWorld.
> joe position: 100@100.
> joe color: Color red.
>

Thanks again.

Stephen
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Karl Ramberg
Allso this
https://gforge.inria.fr/frs/download.php/10764/BotsInc-OriginalEnglish.pdf

Karl

On Mon, Jul 4, 2011 at 10:47 PM, Stephen Woolerton <[hidden email]> wrote:


- how would one display a text label and a text field and obtain input from the text field (am thinking of Morphic)

       name := UIManager default request: 'Enter your name'.
       Transcript show: name; cr.

Thank you - this is exactly what I was looking for - the simplest way of getting input.


However, IMHO this is *not* the best way to introduce Squeak programming to beginners. It mimics procedural programming in a console.

I fully agree with you. The reason is that there are external criteria which we have to meet. The criteria requires keyboard input, and personally have only used Squeak for Seaside projects so didn't know how to do this simple thing :-)


Instead, just open a Workspace and begin evaluating expressions. There doesn't have to be a "program". In fact, there is no "main". Just send messages to objects.

       3 + 4
       1234 / 56
       100 factorial
       'foo bar' asUppercase

Then, make a Morph and send it messages. Evaluate each line individually to see its effect.

       joe := Morph new.
       joe openInWorld.
       joe position: 100@100.
       joe color: Color red.


Thanks again.

Stephen

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Stephen-71
On 5/07/11 9:03 AM, karl ramberg wrote:
> Allso this
> https://gforge.inria.fr/frs/download.php/10764/BotsInc-OriginalEnglish.pdf
>
Thanks Karl,

Great link, and the school has been using this Robots book for a couple
of years. The result has been an amazing uptake from the students - they
"get" what is going on very quickly and have a lot of fun doing it.

The success there led the teacher to using Squeak for another course,
and hence my question.

We do have a problem with the Robots environment though - when using it
on latest versions of Mac OS X there are two issues. One with debugging,
and one with asking for keyboard input. The computer lab  machines are
all Mac OS X. I'll find out the exact details and post the issue as it
needs to be sorted for that course.

Cheers
Stephen

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Stephen-71
In reply to this post by Bert Freudenberg

> Then, make a Morph and send it messages. Evaluate each line individually to see its effect.
>
> joe := Morph new.
> joe openInWorld.
> joe position: 100@100.
> joe color: Color red.
>
I'm running Pharo 1.2.1 and hope you can help in this list. Am running
Mac OS X 10.6.7.

I can't see how to get halos so that I can remove morphic objects I've
created. Also, if I click Ctrl-Click on an object, I get a context menu,
however choosing delete doesn't delete the Morph. I can inspect the
object via Morph/ImageMorph/PasteUpMorph.

Also System/Settings/Appearance/Morphic/Halo doesn't have anything that
helps either.

Should I be running Squeak if I want to use Morphic?

Thanks
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Levente Uzonyi-2
In reply to this post by Bert Freudenberg
On Mon, 4 Jul 2011, Bert Freudenberg wrote:

>
> On 04.07.2011, at 09:45, Stephen Woolerton wrote:
>
>> Hi all,
>>
>> We wish to use Squeak/Smalltalk for a beginner programming course and require the simplest way to get keyboard input.
>>
>> First of all:-
>> - is there a way in Squeak to get console input (analogous to system.in, in Java)? Line input would be ideal, rather than character by character.
>
> There is a way, but it is complicated, platform-dependent, and very rarely used. Squeak provides its own user interface, the command line interface is only used for e.g. server apps.

Since Squeak 4.2 there's support for standard input/output via
FileStreams. There was a bug with stdout (MultiByteFileStream's line
ending conversion), but it's already fixed in the Trunk. All recently
released VMs (except for the interpreter VM on Windows) support this.
Reading the next line from stdin is as simple as:

FileStream stdin nextLine


Levente

>
>> - how would one display a text label and a text field and obtain input from the text field (am thinking of Morphic)
>
> name := UIManager default request: 'Enter your name'.
> Transcript show: name; cr.
>
> However, IMHO this is *not* the best way to introduce Squeak programming to beginners. It mimics procedural programming in a console.
>
> Instead, just open a Workspace and begin evaluating expressions. There doesn't have to be a "program". In fact, there is no "main". Just send messages to objects.
>
> 3 + 4
> 1234 / 56
> 100 factorial
> 'foo bar' asUppercase
>
> Then, make a Morph and send it messages. Evaluate each line individually to see its effect.
>
> joe := Morph new.
> joe openInWorld.
> joe position: 100@100.
> joe color: Color red.
>
> From there I'd continue with inspectors and explorers. Squeak by Example is an excellent source for further exploration:
>
> http://squeakbyexample.org/
>
> - Bert -
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

K K Subbu
In reply to this post by Stephen-71
On Tuesday 05 Jul 2011 2:17:52 AM Stephen Woolerton wrote:
> > However, IMHO this is not the best way to introduce Squeak programming to
> > beginners. It mimics procedural programming in a console.
>
> I fully agree with you. The reason is that there are external criteria
> which we have to meet. The criteria requires keyboard input, and
> personally have only used Squeak for Seaside projects so didn't know how
> to do this simple thing :-)
You may find the Terse Guide to Squeak at http://wiki.squeak.org/squeak/5699 
helpful for your course. UIManager tip appears near the end.

If you notice any course requirement missing in this guide, please post a
request for update here. Thanks.

HTH .. Subbu
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Bert Freudenberg
In reply to this post by Stephen-71
On 05.07.2011, at 01:44, Stephen Woolerton wrote:

>> Then, make a Morph and send it messages. Evaluate each line individually to see its effect.
>>
>> joe := Morph new.
>> joe openInWorld.
>> joe position: 100@100.
>> joe color: Color red.
>>
> I'm running Pharo 1.2.1 and hope you can help in this list. Am running Mac OS X 10.6.7.
>
> I can't see how to get halos so that I can remove morphic objects I've created. Also, if I click Ctrl-Click on an object, I get a context menu, however choosing delete doesn't delete the Morph. I can inspect the object via Morph/ImageMorph/PasteUpMorph.
>
> Also System/Settings/Appearance/Morphic/Halo doesn't have anything that helps either.
>
> Should I be running Squeak if I want to use Morphic?

Yes.

- Bert -

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Sean P. DeNigris
Administrator
In reply to this post by Stephen-71
Stephen-71 wrote
I'm running Pharo 1.2.1 and hope you can help in this list.
There is a pharo list, but...

Stephen-71 wrote
I can't see how to get halos so that I can remove morphic objects I've
created.
In Pharo, hold down shift in addition to whatever keys you would normally hold down to get the halos.

HTH,
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard input - programming course

Mateusz Grotek
In reply to this post by Stephen-71
Stephen Woolerton pisze:

> Hi all,
>
> We wish to use Squeak/Smalltalk for a beginner programming course and
> require the simplest way to get keyboard input.
>
> First of all:-
>  - is there a way in Squeak to get console input (analogous to
> system.in, in Java)? Line input would be ideal, rather than character by
> character.
>  - how would one display a text label and a text field and obtain input
> from the text field (am thinking of Morphic)
>
> Thank you for your assistance.
>
> Stephen
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>

Hi. Sorry for answering so late. I have created a console only
application in Squeak, and can give you some hints if you still need
them. Just answer this e-mail.

Mateusz
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners