intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 25, 2013 9:38 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Mar 16, 2012 7:47 pm 
Offline
User avatar

Joined: Tue Nov 17, 2009 5:25 pm
Posts: 628
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.


Top
 Profile Send private message  
 
PostPosted: Fri Mar 16, 2012 9:05 pm 
Offline

Joined: Wed Oct 27, 2010 6:15 pm
Posts: 239
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:
Code:
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
Code:
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.)


Top
 Profile Send private message  
 
PostPosted: Sat Mar 17, 2012 4:02 am 
Offline
User avatar

Joined: Tue Nov 17, 2009 5:25 pm
Posts: 628
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 :)

Aaaaaaaand: it works!
Thanks a lot!


Top
 Profile Send private message  
 
PostPosted: Sat Mar 17, 2012 10:20 am 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 2086
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


Top
 Profile Send private message  
 
PostPosted: Sat Mar 17, 2012 6:53 pm 
Offline
User avatar

Joined: Tue Nov 17, 2009 5:25 pm
Posts: 628
Thx Zarf. Will try this too.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group