Smalltalk fileout conversion to simple text (fileout2txt)

Victor A. Rodriguez
The Causality Nerd
Published in
2 min readOct 13, 2014

--

Working on some Smalltalk piece of code, the Pharo flavor, needed to put it into some report. Tried a code Fileout but on report insertion all sort o marks and signals show an ugly result. Because the code was several kilobytes long doing a HAND crafted reformat was not a choice then a file inspection gave me some clues.

The most annoying part was that between classes a new page was inserted then inspecting the file with hexdump show me that a simple 0x0c character was the cause of this behaviour

# hd Fileout.st

. . .

00004f10 6d 65 6e 74 53 74 61 6d 70 3a 20 27 3c 68 69 73 |mentStamp: ‘<his|

00004f20 74 6f 72 69 63 61 6c 3e 27 20 70 72 69 6f 72 3a |torical>’ prior:|

00004f30 20 30 21 0d 21 0d 0d 0c 0d 46 6f 74 6f 59 6f 70 | 0!.!….FotoYop|

00004f40 45 78 63 65 70 74 69 6f 6e 20 73 75 62 63 6c 61 |Exception subcla|

. . .

To get rid of it a simple cat Fileout.st | tr -d \\014 was enough.

We also get some exclamation marks that are annoying too but they were discarded by using sed

sed -i ‘s/!//gm’ Fileout.st

Now is the comments turn. They are internal comments and timestamps to wipe them out. grep and sed came to the rescue

cat Fileout.st | grep -v commentStamp: | sed ‘s/stamp: .*//’

Finally some dashed lines that seems to be used as separators arre also deleted

grep -v “\-\- \\ — “ Fileout.st

The basic bits were exposed here but there’s a fully functional script you can use for conversion automation.

Enjoy !

--

--