• setTimeout and data storage

    From Xeanalyth@OGLAROON to DOVE-Net.Synchronet_JavaScript on Thursday, July 19, 2012 19:25:04
    Hi All,

    Just a couple of questions about the JS implementation in SBBS..

    Firstly, a question about timed events:


    Reading script from /home/bbs/mods/stock/main.js
    /home/bbs/mods/stock/main.js compiled in 0.00 seconds
    Hello World
    !JavaScript /home/bbs/mods/stock/main.js line 13: ReferenceError:
    setTimeout is not defined
    /home/bbs/mods/stock/main.js executed in 0.02 seconds


    setTimeout is not defined? How does one go about executing
    timed events?


    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    If there isn't... what are other people using for their persistent
    data stores for extensions to and doors for SBBS?


    Jared
    --
    Jared Quinn
    Oglaroon BBS - oglaroon.servebeer.com

    ---
    ■ Synchronet ■ Currently Private BBS - Testing
  • From Digital Man to Xeanalyth on Thursday, July 19, 2012 02:33:51
    Re: setTimeout and data storage
    By: Xeanalyth to DOVE-Net.Synchronet_JavaScript on Thu Jul 19 2012 07:25 pm

    Hi All,

    Just a couple of questions about the JS implementation in SBBS..

    Firstly, a question about timed events:


    Reading script from /home/bbs/mods/stock/main.js /home/bbs/mods/stock/main.js compiled in 0.00 seconds
    Hello World
    !JavaScript /home/bbs/mods/stock/main.js line 13: ReferenceError: setTimeout is not defined
    /home/bbs/mods/stock/main.js executed in 0.02 seconds


    setTimeout is not defined? How does one go about executing
    timed events?

    In Synchronet, the term "timed events" means programs/modules/scripts that the sysops has configured in SCFG->External Programs->Timed Events. I assum you mean something else. Perhaps you want a background thread which executes a JS function at a predefined interval? One way to do that would be to use a background load() of another JS file which contain's that function which sleeps() between intervals.

    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    If there isn't... what are other people using for their persistent
    data stores for extensions to and doors for SBBS?

    ini files (using the Synchronet File class) is one method (see binarydecoder.js
    for an example), json files is another method (see exec/load/json-db.js and friends for a helpful library). One sysop had a patch which added support for sqlite to Synchronet, but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    digital man

    Synchronet "Real Fact" #81:
    Flapuebarg unf vagreany ebg13 fhccbeg sbe fhcresvpvnyyl rapelcgvat grkg.
    Norco, CA WX: 72.8°F, 45.0% humidity, 2 mph NNW wind, 0.00 inches rain/24hrs
  • From echicken@ECBBS to Xeanalyth on Thursday, July 19, 2012 10:14:27
    Re: setTimeout and data storage
    By: Xeanalyth to DOVE-Net.Synchronet_JavaScript on Thu Jul 19 2012 19:25:04

    !JavaScript /home/bbs/mods/stock/main.js line 13: ReferenceError: setTimeout is not defined

    setTimeout is not defined? How does one go about executing
    timed events?

    Careful with that "timed events" term - it has its own meaning in Synchronet (stuff that's been scheduled via SCFG.)

    While we don't have the setTimeout function that's present in many browsers, we do have exec/load/event-timer.js, which mcmlxxix wrote to provide a Timer object. More info is available in the comments at the top of event-timer.js, but here's a rough example of how to use it:

    load("event-timer.js"); // Loads the library
    var t = new Timer(); // Instantiates a timer for your script

    // Add an event to your timer:
    t.addEvent(30000, true, console.print("LOLDONGS"));

    /* As your script loops, you'll need to cycle the timer to have it run any
    pending events. */
    while(stuff is happening) {
    timer.cycle();
    }

    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230

    ---
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
  • From Deuce@SYNCNIX to Xeanalyth on Thursday, July 19, 2012 10:58:32
    Re: setTimeout and data storage
    By: Xeanalyth to DOVE-Net.Synchronet_JavaScript on Thu Jul 19 2012 07:25 pm

    setTimeout is not defined? How does one go about executing
    timed events?

    Using the Timed Events section of the External Programs bit in scfg.

    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    There's the JSON DB (json-db.js) and RecordFile (recordfile.js)... though I'm not sure what you mean be "database style format". There's also the ini bits of the File class.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    ■ Synchronet ■ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Xeanalyth@OGLAROON to echicken on Friday, July 20, 2012 05:02:59
    On 20/07/12 00:14, echicken wrote:


    While we don't have the setTimeout function that's present in many browsers, we
    do have exec/load/event-timer.js, which mcmlxxix wrote to provide a Timer object. More info is available in the comments at the top of event-timer.js, but here's a rough example of how to use it:

    That sounds perfect for what I was after!

    cheers,
    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------

    ---
    ■ Synchronet ■ Currently Private BBS - Testing
  • From Xeanalyth@OGLAROON to Digital Man on Friday, July 20, 2012 05:04:29
    On 19/07/12 19:33, Digital Man wrote:

    ini files (using the Synchronet File class) is one method (see binarydecoder.js
    for an example), json files is another method (see exec/load/json-db.js and friends for a helpful library). One sysop had a patch which added support for
    sqlite to Synchronet, but I'm not aware of any apps (doors, utils, etc.) which
    use it (yet).

    The SQL patch is probably the most appropriate tool for what I'd like to
    do.. any pointers or where I may be able to find it?

    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------

    ---
    ■ Synchronet ■ Currently Private BBS - Testing
  • From Digital Man to Xeanalyth on Thursday, July 19, 2012 15:45:56
    Re: Re: setTimeout and data storage
    By: Xeanalyth to Digital Man on Fri Jul 20 2012 05:04 am

    On 19/07/12 19:33, Digital Man wrote:

    ini files (using the Synchronet File class) is one method (see binarydecoder.js for an example), json files is another method (see exec/load/json-db.js and friends for a helpful library). One sysop had a patch which added support for sqlite to Synchronet, but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    The SQL patch is probably the most appropriate tool for what I'd like to do.. any pointers or where I may be able to find it?

    The patch used to be hosted here: http://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/
    but the file appears to be missing now... get ahold of Ragnarok (Synchronet sysop) and see if it's still available somewhere.

    digital man

    Synchronet "Real Fact" #26:
    Rob Swindell (digital man) was born approximately 4 hours before the Unix epoch.
    Norco, CA WX: 90.7°F, 29.0% humidity, 15 mph WNW wind, 0.00 inches rain/24hrs
  • From Xeanalyth@OGLAROON to Deuce on Friday, July 20, 2012 07:58:20
    On 20/07/12 03:58, Deuce wrote:

    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    There's the JSON DB (json-db.js) and RecordFile (recordfile.js)... though I'm
    not sure what you mean be "database style format". There's also the ini bits
    of the File class.

    by "database style format", I meant just anything that isn't flat text
    and is somewhat index-able. Doesn't need to be much more than a
    persistent hash so JSON DB sounds like it would be the best option.

    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------

    ---
    ■ Synchronet ■ Currently Private BBS - Testing
  • From Corey@TSGC to Xeanalyth on Thursday, July 19, 2012 20:43:56
    Re: Re: setTimeout and data storage
    By: Xeanalyth to Deuce on Fri Jul 20 2012 07:58 am

    Subject: Re: setTimeout and data storage
    @VIA: OGLAROON
    @MSGID: <500882F8.1220.sync_js@oglaroon.servebeer.com>
    @REPLY: <50084AC8.1219.sync_js@nix.synchro.net>
    @TZ: 0258
    On 20/07/12 03:58, Deuce wrote:

    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    There's the JSON DB (json-db.js) and RecordFile (recordfile.js)... though not sure what you mean be "database style format". There's also the ini b of the File class.

    by "database style format", I meant just anything that isn't flat text
    and is somewhat index-able. Doesn't need to be much more than a
    persistent hash so JSON DB sounds like it would be the best option.

    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------


    some program in java,
    some program with java,
    and some do both.

    "Practise safe Lunch, Use a Condiment"


    ---
    ■ Synchronet ■ Three Stooges Gentlemens Club - Las Vegas, Nv
  • From Tracker1@TRN to Xeanalyth on Friday, July 20, 2012 00:37:29
    setTimeout is not defined? How does one go about executing
    timed events?

    on http://www.roughneckbbs.com/Downloads.aspx download, and look into the S3 shell... basically all the input prompts are doing a 1 second timeout, then checking for other stuff (this allows for inbound messages at a command prompt).

    Secondly, is there a standard way for SBBS apps (doors, utils and
    other things) to store arbitrary data in a database style format?
    I cannot find anything in the API documentation that looks like
    it's supported.

    Depends on what you need... if all you need is a key/document store... you can create a directory for your app's data, and put ####.json files... JSON.js should work fine for serialization/deserialization.

    If there isn't... what are other people using for their persistent
    data stores for extensions to and doors for SBBS?

    generally people are using text configs, serializing json, doing something custom, or shoe-horning in a database client driver... I wrote a connector
    for ADO.Net requests at one point... at the time I was using XML, before a version of spidermonkey with E4X support, or for that matter the boom of JSON... didn't perform well enough at the time.. ymmv.

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

    ---
    ■ Synchronet ■ Roughneck BBS - telnet://roughneckbbs.com - http://roughneckbbs.com
  • From Tracker1@TRN to Digital Man on Friday, July 20, 2012 00:39:17
    One sysop had a patch which added support for sqlite to Synchronet,
    but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    Is there an example out there for creating a db, create table, insert/update/delete records etc?

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

    ---
    ■ Synchronet ■ Roughneck BBS - telnet://roughneckbbs.com - http://roughneckbbs.com
  • From Digital Man to Tracker1 on Friday, July 20, 2012 11:52:05
    Re: Re: setTimeout and data storage
    By: Tracker1 to Digital Man on Fri Jul 20 2012 12:39 am

    One sysop had a patch which added support for sqlite to Synchronet,
    but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    Is there an example out there for creating a db, create table, insert/update/delete records etc?

    With Ragnarok's sqlite patch? I have no idea, I don't see the patch anymore, so
    that's a question for Ragnarok.

    digital man

    Synchronet "Real Fact" #48:
    Synchronet program was named 'sbbs' instead of 'sync' to avoid conflict w/Unix. Norco, CA WX: 87.4°F, 35.0% humidity, 6 mph NW wind, 0.00 inches rain/24hrs
  • From Ragnarok@DOCKSUD to Digital Man on Sunday, July 22, 2012 23:55:38
    El 19/07/12 19:45, Digital Man escribi≤:

    The patch used to be hosted here: http://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/
    but the file appears to be missing now... get ahold of Ragnarok (Synchronet sysop) and see if it's still available somewhere.

    digital man

    thanks for warning, i recovery the files.
    Saludos!

    ---
    ■ Synchronet ■ Dock Sud BBS TLD 24 HS - http://www.docksud.com.ar - telnet://bbs.docksud.com.ar
  • From Ragnarok@DOCKSUD to Tracker1 on Sunday, July 22, 2012 23:57:55
    El 20/07/12 04:39, Tracker1 escribi≤:
    One sysop had a patch which added support for sqlite to Synchronet,
    but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    Is there an example out there for creating a db, create table, insert/update/delete records etc?


    you can see the example file:

    http://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/js_sqlite_test.js

    and little example app:

    http://bbs.docksud.com.ar/~ragnarok/sync/rssviewer/

    ---
    ■ Synchronet ■ Dock Sud BBS TLD 24 HS - http://www.docksud.com.ar - telnet://bbs.docksud.com.ar
  • From Xeanalyth@OGLAROON to Ragnarok on Monday, July 23, 2012 14:56:06
    On 23/07/12 12:57, Ragnarok wrote:

    you can see the example file:

    http://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/js_sqlite_test.js

    and little example app:

    http://bbs.docksud.com.ar/~ragnarok/sync/rssviewer/

    Awesome... That's *exactly* what I'm looking for!

    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------

    ---
    ■ Synchronet ■ Currently Private BBS - Testing
  • From Xeanalyth@OGLAROON to Ragnarok on Monday, July 23, 2012 19:46:14
    On 23/07/12 12:57, Ragnarok wrote:

    One sysop had a patch which added support for sqlite to Synchronet,
    but I'm not aware of any apps (doors, utils, etc.) which use it (yet).

    Is there an example out there for creating a db, create table,
    insert/update/delete records etc?


    you can see the example file:

    http://bbs.docksud.com.ar/~ragnarok/sync/js_sqlite/js_sqlite_test.js

    and little example app:

    http://bbs.docksud.com.ar/~ragnarok/sync/rssviewer/

    I've updated your patch to work with the latest CVS source.. along with dealing with updating some calls which are now obsolete in mozjs. I'll
    forward you a copy once I've finished testing it.


    Jared
    --
    Jared Quinn ----------------------+-------------------------------------------O---O- jared@jaredquinn.info | Knowledge is knowing a tomato is a fruit; i 3:712/101@fidonet | Wisdom is not putting it in a fruit salad.\___/ ----------------------+-------------------------------------------------

    ---
    ■ Synchronet ■ Currently Private BBS - Testing