Home > Smalltalk, Squeak > String-pasting Adventure in Squeak Smalltalk

String-pasting Adventure in Squeak Smalltalk

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:

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