On 9/17/2009 11:42 AM, MCMLXXIX wrote:
calling File.iniGetValue("section",null); sets the file position to the character immediately after the NEXT section heading. so with an empty section
at the beginning and end of the file I can get the file position for the start
of each section of text (and consequently the end of each section by readln()-ing up until the position is greater than that of the next section and
dumping the last line)
sexy.. unless you know of a better way
Use XML, I know some won't like it.. but here goes...
https://developer.mozilla.org/En/E4X/Processing_XML_with_E4X
help.xml
<help>
<section id="yourIdentifier">
..content here...
</sectionName>
<section ...>
...
</section>
...
</help>
read the file in with a...
var f = new File(...);
if (!f.open("r", true))
throw "Unable to open help file '" + filename + "'.";
var helpXml = new XML(f.readAll().join(""));
you now have an E4X based XML object you can read in your information from...
var sectionContent = helpXml.section.(@id == "yourIdentifier");
This will give you the content within a given section... :)
Note: you'll want to escape your < and > characters to < and > .. the CDATA blocks can sometimes wonk up e4x parsing ymmv.
Also, this will require synchronet 3.15 built around January of this year or newer. It works pretty well...
=====
I'm working on using e4x as a templating system for the web side of things... it's a work in progress, but seems to be going okay...
pagename.ssp
create class "Page"
establish optional "Page.Master" static value
master.ssp <-- this is based on Page.Master
create class "Master"
pagename.ssp.html
xml e4x template markup for page
master.ssp.html <-- only if Page.Master is defined
xml e4x template markup for master page.
handler creates a response object...
Load pagename.ssp
Load master.ssp
creates new instance of Page
handler calls page.preInit
creates new instance of Master
inject Page and Master
handler calls page.init
handler calls master.init
Load pagename.ssp.html as e4x "response.page"
Load master.ssp.html as e4x "response.master"
evaluate response object
handler calls page.onLoad
evaluate response object
handler calls master.onLoad
evaluate response object
handler calls page.preRender
evaluate response object
handler calls master.preRender
evaluate response object
handler calls page.render
evaluate response object
handler calls master.render
evaluate response object
transmit output from the response object
When evaluating the response object.. an end/exit state will jump to the output... an exception/error thrown will result in an output based on that exception.
Works better than how I had originally planned on it... still have some kinks to work out. :) Finally got some more work done on it over the weekend.
--
Michael J. Ryan -
http://tracker1.info/
... B5: Doesn't anyone listen to one damn word I say?
---
þ Synchronet þ Roughneck BBS -
telnet://roughneckbbs.com - www.roughneckbbs.com