• String functions?

    From Sampsa@VERT/B4BBS to All on Wed Jan 28 15:03:42 2015
    I've been dabbling in Synchronet JS lately and noticed that the methods that Syncro provides seem to be a subset of those in the standard.

    For example, there is no trim() method.

    My immediate question is - how do I trim whitespace from a string like trim() does?

    Is there a separate string handling object or something?


    ---
    þ Synchronet þ B4BBS = London, England - b4bbs.sampsa.com:2323 (telnet) or 2222 (ssh)
  • From Digital Man@VERT to Sampsa on Wed Jan 28 17:20:08 2015
    Re: String functions?
    By: Sampsa to All on Wed Jan 28 2015 03:03 pm

    I've been dabbling in Synchronet JS lately and noticed that the methods
    that Syncro provides seem to be a subset of those in the standard.

    It appears you're running Synchronet v3.15b, which uses an older version of the
    Mozilla-JavaScript engine (SpiderMonkey). Upgrade to v3.16a (The currently development build) and you'll get a much newer JavaScript engine as well.

    For example, there is no trim() method.

    There very well might be in the newer JavaScript engine.

    My immediate question is - how do I trim whitespace from a string like trim() does?

    Is there a separate string handling object or something?

    "String" is the standard JavaScript object for handling strings.

    Synchronet also includes some C-like global functions for string handling, like
    "truncsp" for truncating white-space off the end of a string: http://synchro.net/docs/jsobjs.html

    digital man

    Synchronet "Real Fact" #38:
    Synchronet first supported Windows NT v6.x (a.k.a. Vista/Win7) w/v3.14a (2006). Norco, CA WX: 67.6øF, 46.0% humidity, 8 mph WSW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Khelair@VERT/TINFOIL to Digital Man on Thu Jan 29 09:09:50 2015
    Re: String functions?
    By: Digital Man to Sampsa on Wed Jan 28 2015 17:20:08

    It appears you're running Synchronet v3.15b, which uses an older version of the Mozilla-JavaScript engine (SpiderMonkey). Upgrade to v3.16a (The currently development build) and you'll get a much newer JavaScript engine as well.

    Ah, yes, I was going to ask about this. Now that I'm delving into file IO; the File object is the one that was proposed for SpiderMonkey that I've googled, no?

    -=-
    Borg Burger: We do it our way; your way is irrelevant.

    ---
    þ Synchronet þ Tinfoil Tetrahedron BBS telnet://tinfoil.synchro.net
  • From Digital Man@VERT to Khelair on Thu Jan 29 14:41:42 2015
    Re: JavaScript functionality
    By: Khelair to Digital Man on Thu Jan 29 2015 09:09 am

    Re: String functions?
    By: Digital Man to Sampsa on Wed Jan 28 2015 17:20:08

    It appears you're running Synchronet v3.15b, which uses an older version of the Mozilla-JavaScript engine (SpiderMonkey). Upgrade to v3.16a (The currently development build) and you'll get a much newer JavaScript engine as well.

    Ah, yes, I was going to ask about this. Now that I'm delving into file IO; the File object is the one that was proposed for SpiderMonkey that I've googled, no?

    Possibly. Originally, the Synchronet File class was based on the jsshell implementation that came with SpiderMonkey, but has been enhanced greatly since
    then.

    digital man

    Synchronet "Real Fact" #58:
    Synchronet apparel and merchandise can be purchased at cafepress.com/synchronet Norco, CA WX: 70.3øF, 36.0% humidity, 5 mph WNW wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From LaRRy LaGoMoRpH@VERT/GRUDGEDU to Sampsa on Wed Feb 4 22:28:36 2015
    Re: String functions?
    By: Sampsa to All on Wed Jan 28 2015 03:03 pm

    I've been dabbling in Synchronet JS lately and noticed that the methods that Syncro provides seem to be a subset of those in the standard.

    For example, there is no trim() method.

    My immediate question is - how do I trim whitespace from a string like trim( does?

    Is there a separate string handling object or something?



    It's easy enough to make this function using a regex, in fact if you search google for "javascript trim" it will come up on the w3schools page at the bottom for where it is unsupported I'm just gonna type it in but you can find a tidbit more info there.

    function trimString(str){
    return str.replace(/^\s+|\s+$/gm,'');
    }

    I could have possibly typed that wrong. Giving you the answer cause you owned up to your boner in the other forum(s?). If that doesn't work check the page, cause it should but I may have typed the regex wrong.

    ll morph G futureland.grudgemirror.com LaRRy LaGoMoRpH\-/
    O
    =M=
    'not your average board check it out' /-\


    ---
    þ Synchronet þ Futureland.Grudgemirror.Com ** LIVE ** Music and
  • From Sampsa@VERT/B4BBS to LaRRy LaGoMoRpH on Thu Feb 5 17:31:00 2015
    LaRRy LaGoMoRpH wrote to Sampsa <=-

    I could have possibly typed that wrong. Giving you the answer cause
    you owned up to your boner in the other forum(s?). If that doesn't
    work check the page, cause it should but I may have typed the regex
    wrong.

    The upgrade did the trick - but thanks anyway.

    sampsa

    ... MultiMail, the new multi-platform, multi-format offline reader!
    --- MultiMail/Darwin v0.49
    þ Synchronet þ B4BBS = London, England - b4bbs.sampsa.com:2323 (telnet) or 2222 (ssh)
  • From Tracker1@VERT to Sampsa on Sun Feb 8 16:24:49 2015
    I've been dabbling in Synchronet JS lately and noticed that the methods
    that Syncro provides seem to be a subset of those in the standard.

    For example, there is no trim() method.

    My immediate question is - how do I trim whitespace from a string like trim() does?

    Is there a separate string handling object or something?

    String.prototype.trim = String.prototype.trim || function() {
    return this.replace(/^\s+|\s+$/,'');
    };

    I'm not sure which version of Spidermonkey Synchronet now uses, but it's been in there for several years now.. it was added to JS as part of ECMAScript 5. You can probably snag the ES5 SHIMS, and load that at the top of a common include in your login/logon script.
    --
    Michael J. Ryan
    http://tracker1.info/

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Tracker1@VERT to Khelair on Sun Feb 8 16:27:35 2015
    Ah, yes, I was going to ask about this. Now that I'm delving into file IO; the File object is the one that was proposed for SpiderMonkey that I've googled, no?

    Synchronet's File IO uses it's own interface, it doesn't really follow the proposed file interface, or commonjs, or node's... If you really want to do file manipulation from JS, you may be better off doing those parts with
    node.js or io.js ... There are some much richer libraries out there for this, but they won't necessarily run under Synchronet.
    --
    Michael J. Ryan
    http://tracker1.info/

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuce@VERT/SYNCNIX to Tracker1 on Sun Feb 8 17:20:33 2015
    Re: Re: JavaScript functionality
    By: Tracker1 to Khelair on Sun Feb 08 2015 04:27 pm

    Synchronet's File IO uses it's own interface, it doesn't really follow the proposed file interface, or commonjs, or node's... If you really want to
    do file manipulation from JS, you may be better off doing those parts with node.js or io.js ... There are some much richer libraries out there for this, but they won't necessarily run under Synchronet.

    The Synchronet file IO interface is actually more flexable and powerful than any of the ones you mentioned (they don't do file range locking or share modes for example) and tend to be POSIX-centric for the additional features they support.

    If you want serious cross-platform file manipulation, it's hard to beat Synchronet's object model. Of course, you're tying youself to Synchonet then, but I absolutely wouldn't say you'll be "better off" doing those parts in a different JS engine.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Sampsa@VERT/B4BBS to Tracker1 on Mon Feb 9 15:27:00 2015
    Tracker1 wrote to Sampsa <=-

    @VIA: VERT
    @MSGID: <54D7FE51.1802.sync-js@vert.synchro.net>
    @REPLY: <54C8FA4E.1725.sync_js@b4bbs.com>
    @TZ: 41e0
    I've been dabbling in Synchronet JS lately and noticed that the methods
    that Syncro provides seem to be a subset of those in the standard.

    For example, there is no trim() method.

    My immediate question is - how do I trim whitespace from a string like trim() does?

    Is there a separate string handling object or something?

    String.prototype.trim = String.prototype.trim || function() {
    return this.replace(/^\s+|\s+$/,'');
    };

    I'm not sure which version of Spidermonkey Synchronet now uses, but
    it's been in there for several years now.. it was added to JS as part
    of ECMAScript 5. You can probably snag the ES5 SHIMS, and load that at
    the top of a common include in your login/logon script.

    I upgrade to 3.15 and the core JS string functions are now there.

    BTW, what I was working on is a door menu to BBS Interlink (www.bbslink.net) which is a really
    cool game server (I don't run it, just a happy user) and I replaced my whole door menu with a bit
    of JS that looks like Synchronet menu but connects out to their server for each door.

    I like the idea of a central door server for multi-user games, figured there'd be more players.

    sampsa


    ... MultiMail, the new multi-platform, multi-format offline reader!
    --- MultiMail/Darwin v0.49
    þ Synchronet þ B4BBS = London, England - b4bbs.sampsa.com:2323 (telnet) or 2222 (ssh)