• setTimeout and data storage

    From Xeanalyth@VERT/OGLAROON to DOVE-Net.Synchronet_JavaScript on Fri Jul 20 02:25:04 2012
    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@VERT to Xeanalyth on Thu Jul 19 09:33:51 2012
    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

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From echicken@VERT/ECBBS to Xeanalyth on Thu Jul 19 17:14:27 2012
    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@VERT/SYNCNIX to Xeanalyth on Thu Jul 19 17:58:32 2012
    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@VERT/OGLAROON to echicken on Fri Jul 20 12:02:59 2012
    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@VERT/OGLAROON to Digital Man on Fri Jul 20 12:04:29 2012
    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@VERT to Xeanalyth on Thu Jul 19 22:45:56 2012
    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

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Xeanalyth@VERT/OGLAROON to Deuce on Fri Jul 20 14:58:20 2012
    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@VERT/TSGC to Xeanalyth on Fri Jul 20 03:43:56 2012
    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@VERT/TRN to Xeanalyth on Fri Jul 20 07:37:29 2012
    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@VERT/TRN to Digital Man on Fri Jul 20 07:39:17 2012
    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@VERT to Tracker1 on Fri Jul 20 18:52:05 2012
    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

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Ragnarok@VERT/DOCKSUD to Digital Man on Mon Jul 23 06:55:38 2012
    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@VERT/DOCKSUD to Tracker1 on Mon Jul 23 06:57:55 2012
    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@VERT/OGLAROON to Ragnarok on Mon Jul 23 21:56:06 2012
    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@VERT/OGLAROON to Ragnarok on Tue Jul 24 02:46:14 2012
    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