Wednesday, December 30, 2009

How to write a novel that doesn't fall apart

When I originally began working on the idea for an interactive novel, I always envisioned that, at some point, I'd have to do a bunch of gruntwork to take my novel and mark it up with a bunch of code, to do a painstaking page-by-page find/replace

It occurred to me that the program could do this for me, on the fly, whenever anyone requests [that's programmer speak, I think] a page of the novel. All I'd ever see would be my original novel. All the reader would see? The custom-built canary. Here's how it works (using PHP):

$plaintext = array("Ana", "Brendan", "Charlie", "Daniel", "Elle");
$markup = array("$anahere", "$brendanhere", "$charliehere", "$danielhere", "$ellehere");
$story = str_replace($plaintext, $markup, $story);

Getting the SQL to communicate with the PHP and the FBML makes it a bit more complex, but that's the basic idea.

No comments:

Post a Comment