" -*- smalltalk -*- " " hello world " " print a simple string on stdout " 'Hello World' displayNl ! " argv " " access command line parameters (no segmentation fault accepted, nor silent exception, so some languages must explicitly check the presence of the argument) " (Smalltalk arguments) at: 1 displayNl ! " env " " access environment variable " (Smalltalk getenv: 'HOME') displayNl ! " test file exists " " return exit code error (non zero) if a file does not exist " (File exists: '/etc/mtab') ifFalse: [ ObjectMemory quit: 1 ] ! " test file readable " " return exit code error (non zero) if a file is not readable " (File isReadable: '/etc/mtab') ifFalse: [ ObjectMemory quit: 1 ] ! " formatting " " print integers in a simple formatted string " | a b | a:=1. b:=2. (a printString, ' + ', b printString, ' = ', (a + b) printString) displayNl ! " system " " call an external program and check the return value " (Smalltalk system: 'false') = 0 ifFalse: [ stderr display: 'false failed' ; nl ]. Smalltalk system: 'echo done' !