• Dumb question 2

    From John@VERT/JCBBS to All on Wed Dec 2 03:52:25 2020
    Hi Folks:

    I am starting to learn Jscript. Simple thing, how do I print something that has a CTRL A code or @LASTON@ ? I am using the userlist.js, I would ideally like to use the print or writeln command. Coming from Turbo/Free pascal, Jscript is not easy, having to unlearn the structued way. This is what I have so far:

    // A sample user listing script for Synchronet v3.1+

    // $Id: userlist.js,v 1.6 2019/01/11 09:37:25 rswindell Exp $

    "use strict";

    var str;

    require("sbbsdefs.js", 'USER_DELETED');
    load("sbbsdefs.js");
    load("bajalib.js");
    var lastuser = system.lastuser;
    var s = baja.print
    var u = new User;

    var logons = u.logons;

    printf("Alias Handle Address Location Connection Logons Security\n");
    s ("tes"); print ("@LASTON@");


    Thanks,
    John

    ---
    þ Synchronet þ JCBBS what an unoriginal name:)
  • From Nelgin@VERT/EOTLBBS to John on Wed Dec 2 03:33:46 2020
    John wrote:
    Hi Folks:

    I am starting to learn Jscript. Simple thing, how do I print something that has a CTRL A code or @LASTON@ ? I am using the userlist.js, I would ideally like to use the print or writeln command. Coming from Turbo/Free pascal, Jscript is not easy, having to unlearn the structued way. This is what I have so far:

    // A sample user listing script for Synchronet v3.1+

    // $Id: userlist.js,v 1.6 2019/01/11 09:37:25 rswindell Exp $

    "use strict";

    var str;

    require("sbbsdefs.js", 'USER_DELETED');
    load("sbbsdefs.js");
    load("bajalib.js");
    var lastuser = system.lastuser;
    var s = baja.print
    var u = new User;

    var logons = u.logons;

    printf("Alias Handle Address Location Connection Logons Security\n");
    s ("tes"); print ("@LASTON@");



    You'd need to use console.putmsg since that's the only method that'll display @-Codes. http://wiki.synchro.net/custom:javascript

    However the proper way would probably to use javascript objects.

    I've not looked but I'm sure there's one to do what you need. https://nix.synchro.net/jsobjs.html

    ---
    þ Synchronet þ End Of The Line BBS - endofthelinebbs.com
  • From John@VERT/JCBBS to Nelgin on Wed Dec 2 04:58:25 2020
    Re: Re: Dumb question 2
    By: Nelgin to John on Tue Dec 01 2020 07:33 pm

    Hi Nelgin:

    Thank you! Do you know what object I need to include to call that function?

    Thanks,
    John

    ---
    þ Synchronet þ JCBBS what an unoriginal name:)
  • From Digital Man@VERT to John on Wed Dec 2 03:20:16 2020
    Re: Dumb question 2
    By: John to All on Tue Dec 01 2020 07:52 pm

    Hi Folks:

    I am starting to learn Jscript.

    I know what you mean, but it's actually JavaScript (or ECMAScript). "JScript" is Microsoft's implementation of EMCAScript and not what Synchronet uses.

    Simple thing, how do I print something that
    has a CTRL A code or @LASTON@ ?

    console.putmsg() will expand @-codes. Most other output methods will expand Ctrl-A codes. See http://wiki.synchro.net/custom:javascript#output for a reference.

    s ("tes"); print ("@LASTON@");

    So that's the @-codes will expand to the *current* user's information. Instead, you wanted to print u.statistics.laston_date. And you probably want to convert that (number) to a human-readable string with something like system.datestr(), system.timestr(), or strftime(): http://synchro.net/docs/jsobjs.html
    see exec/fingerservice.js or other exec/*.js files for examples.

    or even convert it to a JavaScript Date object and use all its methods of stringification:
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
    --
    digital man

    Synchronet/BBS Terminology Definition #58:
    Phreak = Telephone system hack[er]
    Norco, CA WX: 66.5øF, 23.0% humidity, 0 mph SW wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From John@VERT/JCBBS to Digital Man on Wed Dec 2 06:26:26 2020
    Re: Dumb question 2
    By: Digital Man to John on Tue Dec 01 2020 07:20 pm

    Great thank you, one example is all i needed to understand getting the object and referencing it.

    Thanks again!
    John

    ---
    þ Synchronet þ JCBBS what an unoriginal name:)