No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / examples / hello-smalltalk / hello.st.in
blob50ccf44ce13eeea6ad32daa742c7ac66ddb42b2d
1 " Example for use of GNU gettext.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3 This file is in the public domain.
5 Source code of the GNU Smalltalk program.
8 "Unfortunately the PackageLoader method fileInPackage: is extra verbose:
9 It outputs 'Loading package I18N'. This will be fixed in smalltalk-2.2.
11 PackageLoader fileInPackage: 'I18N' !
13 In the meantime, we use this workaround."
15 | saved sink |
16 saved := Transcript message.
17 sink := WriteStream with: String new.
18 Transcript message: sink -> #nextPutAll:.
19 PackageLoader fileInPackage: 'I18N'.
20 Transcript message: saved.
23 Object subclass: #Main
24 instanceVariableNames: ''
25 classVariableNames: 'NLS'
26 poolDictionaries: ''
27 category: 'Program'
29 !Main methodsFor: 'running'!
30 run
31 NLS := I18N Locale default messages domain: 'hello-smalltalk' localeDirectory: '@localedir@'.
32 Transcript showCr: (NLS ? 'Hello, world!').
33 Transcript showCr: ((NLS ? 'This program is running as process number %1.') bindWith: self getpid).
37 "Unfortunately I cannot define getpid like this - it gives
38 'C function getpid not defined'.
40 SystemDictionary defineCFunc: 'getpid'
41 withSelectorArgs: 'getpid'
42 returning: #int
43 args: #()
46 So let's define it through an external process."
48 !Main methodsFor: 'auxiliary stuff'!
49 getpid
50 | stream pid |
51 stream := FileDescriptor popen: 'echo $PPID' dir: #read.
52 pid := stream contents asNumber.
53 stream close.
54 ^ pid
59 Main new run!