When scripting a commandline utility, console.clear() and other console.* functions are 'undefined' Is there a load(*.js) I need to call at the start of the script to has access to those functions or are they hard coded in sbbs?
When scripting a commandline utility, console.clear() and other console.* functions are 'undefined' Is there a load(*.js) I need to call at the start of the script to has access to those functions or are they hard coded in sbbs?
Re: More dumb questions
By: Mortifis to All on Fri Jul 19 2019 11:18:34
When scripting a commandline utility, console.clear() and other console.* functions are 'undefined' Is there a load(*.js) I need to call at the start of the script to has access to those functions or are they hard coded in sbbs?
'console' only exists in scripts running in the 'bbs' context, ie. under a telnet/rlogin/ssh session.
Its methods are strictly for interacting with a remote terminal and they aren't relevant under jsexec,
the webserver, or other places where Synchronet runs JS.
There are ways to deal with running scripts either under jsexec or in a BBS session (you seemed to have
the idea of doing 'if (js.global.console)').
Sometimes it's just easier to
pick one or the other. This
script in particular (generating a report about dupe users) seems like a utility I'd just want to run
under jsexec and I wouldn't need to run during an ssh session.
Re: More dumb questions
By: Mortifis to All on Fri Jul 19 2019 11:18:34
And yet another one, so when I say 'console' I am referring to running via jsexec in a terminal and optput is stdout ... how does one change font colors and the background color of an input ( readln() ) prompt?
Re: Re: More dumb questions
By: Mortifis to echicken on Fri Jul 19 2019 14:00:37
And yet another one, so when I say 'console' I am referring to running via jsexec in a terminal and optput is stdout ... how does one change font colors and the background color of an input ( readln() ) prompt?
I don't think any of the basic output methods have any provisions for doing magic colour stuff, so you'd
probably have to send escape sequences yourself. It's possible that we have some JS libraries that might
help with that, but I'd have to look (and it's more likely that they rely on stuff that the console
object already does).
Re: Re: More dumb questions
By: Mortifis to echicken on Fri Jul 19 2019 14:00:37
And yet another one, so when I say 'console' I am referring to running via jsexec in a terminal and optput is stdout ... how does one change font colors and the background color of an input ( readln() ) prompt?
I don't think any of the basic output methods have any provisions for doing magic colour stuff, so you'd
probably have to send escape sequences yourself. It's possible that we have some JS libraries that might
help with that, but I'd have to look (and it's more likely that they rely on stuff that the console
object already does).
I see conio.textcolor and conio.textbackground but I am unsure how to use it ... I tried conio.textcolor=3 but it displays jibberish and completely hoses the output
I see conio.textcolor and conio.textbackground but I am unsure how to use it ... I tried conio.textcolor=3 but it displays jibberish and completely hoses the output
Re: Re: More dumb questions
By: Mortifis to echicken on Fri Jul 19 2019 16:33:27
I see conio.textcolor and conio.textbackground but I am unsure how to use it ... I tried conio.textcolor=3 but it displays jibberish and completely hoses the output
I completely forgot that thing existed. Can't remember ever using it, though.
I would imagine that if you want to use it for i/o, you should use its methods and no others.
I just whipped up this quick test and it seemed to do what I expected:
conio.init();
conio.clrscr();
conio.textcolor = 14;
conio.cputs('hihi');
conio.getch();
Sysop: | Coz |
---|---|
Location: | Anoka, MN |
Users: | 2 |
Nodes: | 4 (0 / 4) |
Uptime: | 158:44:12 |
Calls: | 162 |
Files: | 5,334 |
Messages: | 221,585 |