This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-03 08:30:43

SeptimusHeap
Scratcher
Registered: 2010-02-01
Posts: 1000+

Smalltalk String Length Code?

What's the smalltalk code for finding a string's length?


http://i46.tinypic.com/dw7zft.png

Offline

 

#2 2010-05-03 08:34:42

meew0
Scratcher
Registered: 2010-02-22
Posts: 1000+

Re: Smalltalk String Length Code?

Find out.

*starts Lion*
*opens the browser*
*goes to Scratch-Objects > ScriptableScratchMorph > class > blockSpecs*
*finds the length block*
*goes to Scratch-Objects > ScriptableScratchMorph > string ops > stringLength:*
*finds this code:*

stringLength: t1
    t1 isUnicode ifTrue: [^ t1 asUTF32 size].
    ^ t1 asString asUTF32 size


http://i.imgur.com/mJV3j.pnghttp://i.imgur.com/HwWAX.pnghttp://i.imgur.com/sZ7Ui.pnghttp://i.imgur.com/0y6yh.pnghttp://i.imgur.com/nOC4l.png

Offline

 

#3 2010-05-03 13:21:57

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Smalltalk String Length Code?

The length command is size.

Code:

'hello world' size

This code returns 11.


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

Board footer