Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!news.kreonet.re.kr!usenet.kornet.nm.kr!agate!spool.mu.edu!howland.reston.ans.net!torn!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: Adding methods to classes
X-Nntp-Posting-Host: superior.carleton.ca
Message-ID: <DGpusG.83u@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <465pi6$1gus@news-s01.ny.us.ibm.net>
Date: Thu, 19 Oct 1995 22:07:28 GMT
Lines: 44

In article <465pi6$1gus@news-s01.ny.us.ibm.net>,
Peter E. Clark <peterc2@ibm.net> wrote:
>I am trying to create a tool in VA that will create a new class, add
>attributes to it, then build and add some methods to it.
>I was able to build a class by using "Object subClass: #<className>",
>and add addtributes to it by passing them on the subclass message.  I
>am now stuck on trying to add methods to this new classI have created.
>
>
>Can anyone give me some pointers on how to do this??
>
>Thanks in advance,
>
>Peter Clark - DST Systems
>Compuserve: 76225,2343 - Internet: peterc2@ibm.net 
>

I'm not sure about the VisualAge syntax for this but you should be
able to create astream on a string, write the method into the stream
in file-in format, then reset the stream and file it in.

In VisualWorks, it would look something like this:

| stream |
stream := WriteStream on: (String new: 100).
stream
    nextPutAll: '!MyClass methodFor: 'accessing!';cr;
    nextPutAll: 'myMethodName';cr;
    nextPutAll: '   ^myVariable! !';
    reset;   
    fileIn

You may want to make sure it files into the right Envy application.

David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|


