A stupid newbie question

Karl Ramberg karl.ramberg at chello.se
Sat Oct 6 19:35:08 UTC 2001


Patrick Castle wrote:
> 
> Hi all,
> 
> I'm having a particular problem which is probably laughably stupid and
> although I managed a workaround the whole implementation is looking really
> sloppy.
> 
> I'm trying to implement an example from the book: 'Discovering Smalltalk' -
> the TicTacToeGame if anyone is interested.
> 
> Now I know some of the code won't work as it isn't written for Squeak. I
> have translated it as best I can and have actually managed to implement a
> full solution.
> 
> However.....
> 
> The idea is to prompt the user for a simple point on a 3x3 grid meaning:
> answer isKindOf: Point.
> But when implementing..
> 
> |aPoint|
> 
> aPoint := FillInTheBlank
>         request: 'Next move?'
>         initialAnswer: '1 at 1'.
> 
> ..a String is bound to the aPoint variable.
> 
> As part of the move's validation process a method is used to determine
> firstly whether the user has actually entered a point and secondly whether
> the point is valid. But it won't even pass the    aPoint isKindOf: Point
> test.
> 
> Now feel free to laugh out loud at my workaround, but this is how I turned
> achieved the desired result:
> 
> |aPoint|
> 
> aPoint := FillInTheBlank
>         request: 'Next move?'
>         initialAnswer: '1 at 1'.
> aPoint := Point x: ((aPoint at: 1) asInteger - 48) y: ((aPoint at: 3)
> asInteger - 48).
> 
Not all that pretty but will do what you want in most cases:
aPoint _  (((aPoint splitInteger first max:1)min:3)@(( aPoint
numericSuffix max:1)min:3))
This also checks the max and min to be between 1 and 3.
> 
> Just to try your patience I thought I'd add another question.
> 
> Now that I have the application functioning I would like to make it into an
> .exe file to see how it functions outside of the Squeak development
> environment. The only info I've found so far on doing this is to type:
> 
> CCodeGenerator new initialize addClass: ClassName) codeString.
> 
> Inspecting this gives me some C code with an #include 'sq.h'  line in it. I
> don't have this header file so where would I get it? Is this all I need to
> do to turn a Squeak application into an .exe?
> 
> I'm presuming I would have to do this with all Classes I create to make the
> application plus any other pre-existing Classes I have modified or created
> that happen to be used within the application.
> 
> I have a GNU C/C++ compiler so I'm guessing that should be enough for
> compilation.

Well, actually the program only works within the Squeak image. You can't
easily make a compiled executable to run outside the Squeak environment 
like a C compiler do. It is possible to wrap the image and vm together
and make something work but it is seldom used...

Squeak is the development and the deployment platform and the image is
hardware independent.

Karl




More information about the Squeak-dev mailing list