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.
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
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);
});
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
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.
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
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
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
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.
text = text.replace(/@([^@]+)@/g, function(m, code) {
return bbs.atcode(code);
});
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
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
couldtext = text.replace(/@([^@]+)@/g, function(m, code) {
return bbs.atcode(code);
});
That seems to work well. I'm curious, how did you find that you
JavaScriptuse an anonymous function for the replacement value in the
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. ;)
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
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..
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.
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
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..
þ Synchronet þ Decker's Heaven -//- bbs.deckersheaven.com[Psi-Jack -//- Decker]
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
Sysop: | MCMLXXIX |
---|---|
Location: | Prospect, CT |
Users: | 333 |
Nodes: | 10 (0 / 10) |
Uptime: | 17:02:29 |
Calls: | 574 |
Calls today: | 1 |
Messages: | 235855 |