• console.putmsg alternative that returns a string

    From Nightfox@VERT/DIGDIST to All on Tue Sep 30 12:39:49 2014
    Is there an alternative to console.putmsg() that returns a string instead of outputting to the console? What I'd like to do is to have @-codes, etc. interpreted in a string and save that string so I can then pass that string to printf() so I can specify a field length for the text.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Psi-Jack@VERT/DECKHVN2 to Nightfox on Wed Oct 1 09:32:55 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to All on Tue Sep 30 2014 12:39 pm

    Is there an alternative to console.putmsg() that returns a string instead of outputting to the console? What I'd like to do is to have @-codes, etc. interpreted in a string and save that string so I can then pass that string to printf() so I can specify a field length for the text.

    I believe what you're looking for is bbs.atcode():

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Nightfox@VERT/DIGDIST to Psi-Jack on Wed Oct 1 07:44:15 2014
    Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Nightfox on Wed Oct 01 2014 09:32:55

    Is there an alternative to console.putmsg() that returns a string
    instead of outputting to the console? What I'd like to do is to
    have @-codes, etc. interpreted in a string and save that string so I
    can then pass that string to printf() so I can specify a field
    length for the text.

    I believe what you're looking for is bbs.atcode():

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    I saw bbs.atcode() in the docs.. I was hoping for something that handles a whole string, similar to console.putmsg(). bbs.atcode() only interprets a single @-code, which requires writing some more code, but I suppose that will have to do. Thanks.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Digital Man@VERT to Nightfox on Wed Oct 1 16:13:25 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to All on Tue Sep 30 2014 12:39 pm

    Is there an alternative to console.putmsg() that returns a string instead
    of outputting to the console? What I'd like to do is to have @-codes, etc. interpreted in a string and save that string so I can then pass that string to printf() so I can specify a field length for the text.

    I think you're looking for bbs.atcode().

    That said, Synchronet @-codes already support a method for length field specification as well as left and rigth justification:
    http://wiki.synchro.net/custom:atcodes#formatting

    digital man

    Synchronet "Real Fact" #55:
    Synchronet Terminal Server introduced SecureShell (SSH) support w/v3.14a (2006).
    Norco, CA WX: 83.1øF, 45.0% humidity, 3 mph ESE wind, 0.00 inches rain/24hrs

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Wed Oct 1 18:06:21 2014
    Re: console.putmsg alternative that returns a string
    By: Digital Man to Nightfox on Wed Oct 01 2014 16:13:25

    I think you're looking for bbs.atcode().

    I was hoping for something similar to console.putmsg which would interpret codes in a whole string and return the new string, but I suppose I could write something to do that with bbs.atcode().

    That said, Synchronet @-codes already support a method for length field specification as well as left and rigth justification: http://wiki.synchro.net/custom:atcodes#formatting

    That's not exactly what I'm looking for - What I will be using this for is reading messages posted on sub-boards, which might include @-codes. Those might not necessarily include length formatting. I'll be taking each line from the message and word-wrapping the line (as the interpreted @-code will likely differ in length from the @-code) and then displaying the message line on the screen with a specific width.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Psi-Jack@VERT/DECKHVN2 to Nightfox on Thu Oct 2 08:23:32 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Wed Oct 01 2014 07:44 am

    Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Nightfox on Wed Oct 01 2014 09:32:55

    I believe what you're looking for is bbs.atcode():

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    I saw bbs.atcode() in the docs.. I was hoping for something that handles a whole string, similar to console.putmsg(). bbs.atcode() only interprets a single @-code, which requires writing some more code, but I suppose that will have to do. Thanks.

    Hmm, yeah. I don't think there's anything else. This text.replace itself goes through each beginning and ending @ code block and translates each one, at least as far as I can tell it does. the variable, text, becomes the full at-code translated result.

    Either way, you're welcome, and hope it helps. :)

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Psi-Jack@VERT/DECKHVN2 to Digital Man on Thu Oct 2 08:27:57 2014
    Re: console.putmsg alternative that returns a string
    By: Digital Man to Nightfox on Wed Oct 01 2014 04:13 pm

    Re: console.putmsg alternative that returns a string
    By: Nightfox to All on Tue Sep 30 2014 12:39 pm

    Is there an alternative to console.putmsg() that returns a string
    instead of outputting to the console? What I'd like to do is to have
    @-codes, etc. interpreted in a string and save that string so I can
    then pass that string to printf() so I can specify a field length for
    the text.

    I think you're looking for bbs.atcode().

    That said, Synchronet @-codes already support a method for length field specification as well as left and rigth justification: http://wiki.synchro.net/custom:atcodes#formatting

    I think he's looking to get the entire value of the string with
    multiple translated at-codes combined, and possibly even other text, which @-code formatting does not work on. On a singular one, the formatting would work, but combined with others, not so much. :)

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Nightfox@VERT/DIGDIST to Psi-Jack on Thu Oct 2 07:29:35 2014
    Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Nightfox on Thu Oct 02 2014 08:23:32

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    Hmm, yeah. I don't think there's anything else. This text.replace itself goes through each beginning and ending @ code block and translates each one, at least as far as I can tell it does. the variable, text, becomes the full at-code translated result.

    Yep, I've used JavaScript's string replace() function in some of my scripts. And regular expressions are awesome.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Nightfox@VERT/DIGDIST to Psi-Jack on Sun Oct 5 09:51:55 2014
    Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Nightfox on Wed Oct 01 2014 09:32:55

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    That seems to work well. I'm curious, how did you find that you could use an anonymous function for the replacement value in the JavaScript string replace() method? I've often referred to the w3schools.com JavaScript documentation, and their documentation for the string replace() method seems to imply that it expects a string for the replacement value: www.w3schools.com/jsref/jsref_replace.asp

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com
  • From Psi-Jack@VERT/DECKHVN2 to Nightfox on Mon Oct 6 15:27:46 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Sun Oct 05 2014 09:51 am

    Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Nightfox on Wed Oct 01 2014 09:32:55

    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    That seems to work well. I'm curious, how did you find that you could use an anonymous function for the replacement value in the JavaScript string replace() method? I've often referred to the w3schools.com JavaScript documentation, and their documentation for the string replace() method seems to imply that it expects a string for the replacement value: www.w3schools.com/jsref/jsref_replace.asp

    Well, I didn't.. This is just stuff Deuce came up with for the newuser_signup.js I've been testing. ;)

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Nightfox@VERT to Psi-Jack on Mon Oct 6 12:47:50 2014
    text = text.replace(/@([^@]+)@/g, function(m, code) {
    return bbs.atcode(code);
    });

    That seems to work well. I'm curious, how did you find that you
    could
    use an anonymous function for the replacement value in the
    JavaScript
    string replace() method? I've often referred to the w3schools.com JavaScript documentation, and their documentation for the string replace() method seems to imply that it expects a string for the replacement value: www.w3schools.com/jsref/jsref_replace.asp

    Well, I didn't.. This is just stuff Deuce came up with for the newuser_signup.js I've been testing. ;)

    Ah, I see.
    I tried the code that you shared, and I think it might need some more
    tweaking, as it seems it will replace text around a @ even if it's not a valid Synchronet @-code..

    Nightfox

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuce@VERT/SYNCNIX to Nightfox on Mon Oct 6 14:38:12 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Sun Oct 05 2014 09:51 am

    That seems to work well. I'm curious, how did you find that you could use an anonymous function for the replacement value in the JavaScript string replace() method? I've often referred to the w3schools.com JavaScript documentation, and their documentation for the string replace() method
    seems to imply that it expects a string for the replacement value: www.w3schools.com/jsref/jsref_replace.asp

    http://www.synchro.net/docs/js/ref

    Specifically: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Object
    s/String/replace#Specifying_a_function_as_a_parameter


    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Deuce@VERT/SYNCNIX to Nightfox on Mon Oct 6 14:39:36 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Mon Oct 06 2014 12:47 pm

    I tried the code that you shared, and I think it might need some more tweaking, as it seems it will replace text around a @ even if it's not a valid Synchronet @-code..

    It replaces everything between two @s, so two e-mail addresses would get borked
    and merged for example.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Psi-Jack@VERT/DECKHVN2 to Deuce on Tue Oct 7 11:23:29 2014
    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Mon Oct 06 2014 12:47 pm

    I tried the code that you shared, and I think it might need some more tweaking, as it seems it will replace text around a @ even if it's not a valid Synchronet @-code..

    It replaces everything between two @s, so two e-mail addresses would get borked and merged for example.

    Yikes! Yeah.. That could definitely be bad..

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Psi-Jack@VERT/DECKHVN2 to Deuce on Tue Oct 7 14:47:24 2014
    Re: Re: console.putmsg alternative that returns a string
    By: Psi-Jack to Deuce on Tue Oct 07 2014 11:23 am

    Re: console.putmsg alternative that returns a string
    By: Nightfox to Psi-Jack on Mon Oct 06 2014 12:47 pm

    I tried the code that you shared, and I think it might need some
    more tweaking, as it seems it will replace text around a @ even if
    it's not a valid Synchronet @-code..

    It replaces everything between two @s, so two e-mail addresses would
    get borked and merged for example.

    Yikes! Yeah.. That could definitely be bad..

    Quite bad. Yeah.

    ---
    [Psi-Jack -//- Decker]
    þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com
  • From Nightfox@VERT/DIGDIST to Deuce on Tue Oct 7 19:38:13 2014
    Re: console.putmsg alternative that returns a string
    By: Deuce to Nightfox on Mon Oct 06 2014 14:38:12

    http://www.synchro.net/docs/js/ref

    Specifically: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global
    _Object s/String/replace#Specifying_a_function_as_a_parameter

    I see. Thanks for the links.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS - digitaldistortionbbs.com