[Squeakland] getting code from a .txt file into a script
Alan Kay
Alan.Kay at squeakland.org
Tue Mar 23 09:14:00 PST 2004
But what does this have to do with children and the UI they need?
Cheers,
Alan
------
At 8:50 AM -0800 3/23/04, Ned Konz wrote:
>On Tuesday 23 March 2004 4:13 am, Gary Frederick wrote:
>> box
>> self forward: 100.
>> self turn: 90.
>> self forward: 100.
>> self turn: 90.
>> self forward: 100.
>> self turn: 90.
>> self forward: 100.
>> self turn: 90
>>
>> I want to be able to read it into a script in a project like the script
>> project in the Worlds of Squeak.
>>
>> This is a class of kids that are playing with robots. They have been
>> working with programming LEGO robots and with a simulator. I am
>> interested in taking their programs and translating them into a script
>> they can use in Squeak... if I can get the .txt files into scripts.
>
>Are you using the eToy environment? I assume that's what you want.
>
>You can use text scripting instead of tiles. The check box at the left top of
>the editor changes between the two modes.
>
>However, if you edit the text in text mode you can't see it or edit it in
>(classic) tiles any more.
>
>Here's a quick way to see the text format:
>
>* turn on the "debugHaloHandle" preference
>* go to the "drive a car" project in the Worlds of Squeak.
>* bring up the halos on the car.
>* click on the grey (debug) halo.
>* click on "browse player class".
>
>You will see a browser with the Player157 class in it.
>Get the context menu on the name of the class (Player157) and choose
>"fileOut".
>
>Now you will have a Player157.st file on disk.
>
>Here's what it looks like (NOTE that you MUST use bare CR characters (Mac text
>format) if you are editing or building such scripts, though CR/LF may also
>work in a pinch):
>
>--------------- 8< --------------
>'From Squeak3.7alpha of 11 September 2003 [latest update: #5816] on 23 March
>2004 at 7:44:49 am'!
>Player subclass: #Player157
> instanceVariableNames: 'isTrue'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Morphic-UserObjects'!
>
>!Player157 methodsFor: 'access'!
>getIsTrue
> ^ isTrue! !
>
>!Player157 methodsFor: 'access'!
>setIsTrue: t1
> isTrue := t1! !
>
>
>!Player157 methodsFor: 'scripts'!
>drive
> self forward: 7.
> self turn: Wheel getHeading // 5! !
>
>"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
>
>Player157 class
> instanceVariableNames: 'cardPlayer111 unscriptedPlayer1
>unscriptedPlayer2'!
>
>!Player157 class methodsFor: 'reference'!
>refCardPlayer111
> ^ cardPlayer111! !
>
>!Player157 class methodsFor: 'reference'!
>refUnscriptedPlayer1
> ^ unscriptedPlayer1! !
>
>!Player157 class methodsFor: 'reference'!
>refUnscriptedPlayer2
> ^ unscriptedPlayer2! !
>--------------- 8< --------------
>
>
>So if you could translate your text files into this format you may be able to
>use them directly (depending on the vocabulary).
>
>What's the format of your text files? Can you send me one?
>
>You could do this:
>
>* make a blank project with a Sketch in it that represents the robot.
>
>* Make a new script in that Sketch that will prompt for a file and read your
>text format into methods (it would be best, probably, to put the reader
>method in another class (perhaps Player) so that you can make multiple Sketch
>classes that can read such files).
>
>Let's say that your scripts have the method names in column 1.
>
>The enclosed change set (which you would file into your new project) will let
>you make a script that will read such files.
>
>> I'll put some scripts into an image and let them each have a copy of the
>> image if I don't find out how to go from a .txt file to a script. That
>> solution is better than nothing and I can do it by tomorrow :-)
>
>You should distribute projects instead of images.
>
>--
>Ned Konz
>http://bike-nomad.com/squeak/
>
>
>Attachment converted: Macintosh HD:ScriptEditorText.png (PNGf/ogle) (000CAB12)
>Attachment converted: Macintosh HD:ScriptEditor.png (PNGf/ogle) (000CAB13)
>Attachment converted: Macintosh HD:ReadTextFilesIntoPlayer-nk.1.cs
>(TEXT/ttxt) (000CAB14)
>Attachment converted: Macintosh HD:getMethodsScriptor.png
>(PNGf/ogle) (000CAB15)
>_______________________________________________
>Squeakland mailing list
>Squeakland at squeakland.org
>http://squeakland.org/mailman/listinfo/squeakland
--
More information about the Squeakland
mailing list