How does one fileout a class. Also is there a shell command call

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How does one fileout a class. Also is there a shell command call

Stephen-71
Hi all,

I'm getting into smalltalk and have a some newbie questions I'm hoping
someone can answer:

Here are the questions.. see below for more detail on each question :-
   1. How does one fileout code in a human readable form?
   2. How do I print a list of all the classes in the system?
   3. How does one call an operating system shell command and get the
output?

Background: I'd like to use GNU Smalltalk for some Linux operating
system scripting and so am running GST headless.

1. Fileout code
I've tried the following...

st> Account class fileOutOn: stdout !

-------------------------------------------
"Filed out from GNU Smalltalk version 2.3.3 on 28-Aug-2007  14:45:32"!

Object subclass: #Account
       instanceVariableNames: 'balance naming '
       classVariableNames: ''
       poolDictionaries: ''
       category: nil!

Account comment:
'I represent a place to deposit and withdraw money'!

!Account class methodsFor: 'instance creation'!

  ! !
! !

!Account methodsFor: 'instance initialization'!

  ! !
! !

!Account methodsFor: 'moving money'!

  ! !
!

  !
! !

Code is in fact there, for instance...
st> a deposit: 20!
Account new "<-0x4c65dc70>"
st> a printOn: stdout !
an Account with balance: 175Account new "<-0x4c65dc70>"
---------------------------------------------

As you can see, the code isn't being printed. What would be the command
to print the method code in the Account class?


Secondly, I'm thinking that if I have some scripting classes in an
image, I'll prefix all my classes with a standard prefix and then I can
easily see which are my classes. But how does one print out the list of
all the classes in an image... or for instance, print out all the
classes in an image starting with say SO?

Thirdly, is there a way to make an operating system shell call and
retrieve the output of the call. For instance is it possible to submit
"ls -l /etc" to the operating system and to get the output of this command?

Many thanks
Stephen


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: How does one fileout a class. Also is there a shell command call

Stephen Woolerton

>
>> As you can see, the code isn't being printed. What would be the
>> command to print the method code in the Account class?
>
> That's a bug. :-)
>
> Are you using readline or not (i.e., can you edit the lines you enter
> into gst using left/right arrow, and recall the history using up/down
> arrow)?
OK. Am using standard 2.3.3 package in Gentoo Linux. Readline works in
the st environment on this machine. I can contact the package maintainer
- at least I know now I had the right instruction.

>
>     Smalltalk addSubspace: #Scripting.
>     Namespace current: Scripting.
>
> However, all classes can be obtained with "Object withAllSubclasses" if
> you prefer a prefix.  (I just added "nil allSubclasses" to GNU Smalltalk
> trunk, which will also give other classes that, like "Autoload", derive
> directly from nil).
Thank you

>
> Also, GNU Smalltalk does not use the image that much.  You just build
> the image on the fly, starting from a basic one, by loading one or more
> files.
I see. That is a better way of doing it and easier to maintain scripts.

>
>> Thirdly, is there a way to make an operating system shell call and
>> retrieve the output of the call. For instance is it possible to submit
>> "ls -l /etc" to the operating system and to get the output of this
>> command?
>
> Yes:
>
>     pipe := FileStream popen: 'ls -l /etc' dir: FileStream read.
>     pipe contents
>
This is gold so far as bash scripting goes! I was hoping there was a
way. Thank you.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk