Archive

Archive for November, 2010

String-pasting Adventure in Squeak Smalltalk

November 29th, 2010 2 comments

Pasting a string into Squeak is just like pasting a string anywhere else… unless it has quotes in it… or is really long. Then, you’re screwed… but only in a this-is-Smalltalk-and-I’ll-be-able-to-wiggle-my-way-out-in-a-few-moments sort of way.

UPDATE: check the comments after this post for two quicker methods.

In the case of quotation marks in the string, Squeak thinks that the string ends at the first one, because they are not doubled:

In this trivial example, we could just put in the extra two quotes, but if the string was longer, a simple solution is to paste the text into a TextMorph and get its contents:

You can see that the quotes around template.NamlServlet have been doubled.

Long strings

However, if you try to do this with a very long string (like an HTML page source), when you ask for the contents, it will be prematurely cut off (note ‘…etc…’ below):

What’s going on here?  Well, if we browse Object’s ‘printing’ protocol (our hint to look in Object is that all objects can be printed in the tools), we find that printString actually calls printStringLimitedTo:

But fear not, the the method comment refers us to the perfectly named Object>>fullPrintString, which does just the right thing.  You can even copy the correctly-escaped string right onto the clipboard:

n.b. if you ‘PrintIt’ the above statement, you will still get a truncated string, because the system will call regular printString on the result of fullPrintString.

Categories: Smalltalk, Squeak Tags:

Squeak Smalltalk: Error recovery in a live open system

November 24th, 2010 3 comments

Vestigial Panic

Photo by star5112@flickr

I accidentally changed the subclass of a morph that was open in the world – oops.  My screen began filling with dozens of error windows.  Right around this time, I started thinking about quitting and rebooting.  And then I remembered… this isn’t Windows!  I can recover from this – and probably quickly.  So I brought up halos on the hosed morph, clicked the delete halo, pressed the user-interrupt shortcut (Cmd-. on Mac) and went for a glass of water – okay, it was wine – stop judging.

Room to Breath

When I got back, I had a debugger open on the event loop, so I knew that the pain had stopped getting worse.  Now I just had to figure out what to do about all those error windows.

Photo by mliu92@flickr

Like a trained seal, my first move was to press the close button on each one.  This got old after the first two, and I remembered I was using Smalltalk.

Brief Digression

After years of being institutionalized by Windows… and Mac (yes fanboys, it’s only slightly better than Windows, and can’t begin to touch what Engelbart and Kay were doing in the 1960′s and 1970′s), I constantly forget that I’m working in a live, open system, and do idiotic, inefficient things like hitting the close button on 50 error windows.  Like the movie Momento, where he wakes up every day and doesn’t remember who he is or what he’s supposed to be doing…

Smalltalk Nirvana

Back to my senses, I took 10 seconds to write a snippet that closed all the windows:

errorWindows := (World submorphs select: [ :m |
  (m respondsTo: #label) and:
    [ m label beginsWith: 'NonBooleanReceiver' ] ]).
errorWindows do: [ :e | e delete ]

And I was back in action.  Of course, this particular example probably only saved me 10 minutes, but multiply that by X times a day for a year and you get a glimpse of the power of Squeak Smalltalk – a live, open, beautiful system.

Categories: Mac, Smalltalk, Squeak Tags:

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip
\n