Extract text from I7 code

Is there a way to extract the “real” text from Inform7 code? I’d like to have my proofreaders and de-ingliscizators read all of it without forcing them through the source.

Any help is valuable.
Thx in advance.

The text is somewhat scattered by the compilation process, but you can extract it easily enough from the source text. For instance, here’s a Perl script:

use Switch; $commentDepth=0; $inString=0; while(($count=read STDIN,$character,1)!=0){ switch($character){ case('['){ ++$commentDepth; } case(']'){ --$commentDepth; } case('"'){ if(!$commentDepth){ if($inString){ print "\"\n"; } $inString=!$inString; } } } if($inString){ print $character; } }

Save it, enter

perl -f "/path/to/script.perl" < "/path/to/project.inform/Source/story.ni" > "/path/to/file/where/strings/should/be/saved.text" on the command line, and you should get a list of texts. You might have to repeat the process for any extensions you’re including. (I am assuming, of course, that you have Perl installed.)

I don’t, but it’s worth a try! Thx for the help.

Edit: It looks like I do, instead. MacOSX has it installed. I just woke up, for the record :slight_smile:

Aaaaaaaand: it works!
Thanks a lot!

A handy trick is to search the generated I6 code for lines beginning “Constant SC_”. This will give you only the text that comes from I7 code, which excludes most of the standard library.

On a Mac/Unix box:

grep ‘Constant SC_’ testcase.inform/Build/auto.inf | cut -b 13-

This gives you a list of strings in alphabetical order. To get them in source-code order, try:

grep ‘Constant SC_’ testcase.inform/Build/auto.inf | cut -b 13- | sort -n

Thx Zarf. Will try this too.