• helpfile.js

    From MCMLXXIX@VERT/MDJ to Digital Man on Thursday, September 17, 2009 13:19:11
    I've had that stupid blank script in CVS for months now, and decided to try to do something with it today.

    The purpose of it will be to make some standardized help files for my scripts that can be broken into sections and browsed by section name.

    I was playing around with something today but it didn't work, so my question to you is:

    what does File.iniGetValue() or File.iniSetValue() do within the file when it's done performing its operation? does it leave the file position where it finished? or does it reset to position 0? or EOF?

    I was hoping to use the ini methods as delimiters for help file sections for quick and easy navigation within a file by reading or setting a value within a section to change file position.... but I don't know if it will work.

    thx


    ---
    þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)
  • From MCMLXXIX@VERT/MDJ to Digital Man on Thursday, September 17, 2009 13:35:49
    Re: helpfile.js
    By: MCMLXXIX to Digital Man on Thu Sep 17 2009 13:19:11

    I was hoping to use the ini methods as delimiters for help file sections
    for quick and easy navigation within a file by reading or setting a value within a section to change file position.... but I don't know if it will work.

    the only way I can think of right now is to append an "=" to the end of every line of text in a section and read everything in as a key, but I'd rather not have to.


    ---
    þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)
  • From MCMLXXIX@VERT/MDJ to Digital Man on Thursday, September 17, 2009 14:42:53
    Re: helpfile.js
    By: MCMLXXIX to Digital Man on Thu Sep 17 2009 13:35:49

    I was hoping to use the ini methods as delimiters for help file sections for quick and easy navigation within a file by reading or setting a
    value within a section to change file position.... but I don't know if
    it will work.

    the only way I can think of right now is to append an "=" to the end of every line of text in a section and read everything in as a key, but I'd rather not have to.


    after bouncing this issue off of myself for a while I got something to work, and it seems pretty solid.

    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


    ---
    þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)
  • From Tracker1@VERT/TRN to MCMLXXIX on Sunday, September 20, 2009 15:41:22
    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 &lt; and &gt; .. 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
  • From MCMLXXIX@VERT/MDJ to Tracker1 on Monday, September 21, 2009 14:00:41
    Re: Re: helpfile.js
    By: Tracker1 to MCMLXXIX on Sun Sep 20 2009 15:41:22

    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... :)

    Thanks for the ideas. I honestly had no idea JS had support for XML.

    My synchronet build is ancient, relative to everything else going on here. Guess it's time to update.


    ---
    þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)
  • From Tracker1@VERT/TRN to MCMLXXIX on Wednesday, September 23, 2009 00:52:33
    On 9/21/2009 11:00 AM, MCMLXXIX wrote:
    var sectionContent = helpXml.section.(@id == "yourIdentifier");

    This will give you the content within a given section... :)

    Thanks for the ideas. I honestly had no idea JS had support for XML.

    My synchronet build is ancient, relative to everything else going on here. Guess it's time to update.

    Yeah, E4X is pretty cool, I requested the update the the JS engine early this year for some stuff I've been trying to work on... Honestly been busy and lazy. Hoping to get some more time next weekend. Got the flash policy service written and working, also trying to get a few more things in place.

    --
    Michael J. Ryan - http://tracker1.info/

    ... FRA #111: Treat people in your debt like family ... exploit them.

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com
  • From MCMLXXIX@VERT/MDJ to Tracker1 on Wednesday, September 23, 2009 16:21:19
    Re: Re: helpfile.js
    By: Tracker1 to MCMLXXIX on Wed Sep 23 2009 00:52:33

    Yeah, E4X is pretty cool, I requested the update the the JS engine early this year for some stuff I've been trying to work on... Honestly been busy and lazy. Hoping to get some more time next weekend. Got the flash policy service written and working, also trying to get a few more things in place.


    flash policy service, you say??

    could I acquire a copy of that?


    ---
    þ Synchronet þ The BRoKEN BuBBLE (MDJ.ATH.CX)
  • From Tracker1@VERT/TRN to MCMLXXIX on Thursday, September 24, 2009 18:37:29
    On 9/23/2009 1:21 PM, MCMLXXIX wrote:
    Yeah, E4X is pretty cool, I requested the update the the JS engine early
    this year for some stuff I've been trying to work on... Honestly been busy >> and lazy. Hoping to get some more time next weekend. Got the flash policy >> service written and working, also trying to get a few more things in place.

    flash policy service, you say??

    could I acquire a copy of that?

    http://bbsing.info/downloads/socket-policy-service.zip

    I sent a copy to DM so it could be included with sync...

    --
    Michael J. Ryan - http://tracker1.info/

    ... FRA #034: Peace is good for business.

    ---
    þ Synchronet þ Roughneck BBS - telnet://roughneckbbs.com - www.roughneckbbs.com