Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
custom:javascript [2019/05/27 21:35] – [Integration] renamed to Invocation and provided more details. digital mancustom:javascript [2023/08/04 19:24] (current) – [Input] A little more clarity on console.getbyte() digital man
Line 12: Line 12:
  
 You can learn about the core JavaScript language and object model from the following documents:  You can learn about the core JavaScript language and object model from the following documents: 
-  * [[http://developer.mozilla.org/en/JavaScript/Guide|Core JavaScript Guide]] ([[http://developer.mozilla.org/docs/Core_JavaScript_1.5_Guide|Historic: 1.5]]) +  * [[https://developer.mozilla.org/en-US/docs/Web/JavaScript|Core JavaScript Guide]] ([[http://developer.mozilla.org/docs/Core_JavaScript_1.5_Guide|Historic: 1.5]]) 
-  * [[http://developer.mozilla.org/en/JavaScript/Reference|Core JavaScript Reference]] ([[http://developer.mozilla.org/docs/Core_JavaScript_1.5_Reference|Historic: 1.5]])+  * [[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference|Core JavaScript Reference]] ([[http://developer.mozilla.org/docs/Core_JavaScript_1.5_Reference|Historic: 1.5]])
  
 JavaScript is an established, mature scripting language syntactically similar to C++ and Java.  JavaScript is an established, mature scripting language syntactically similar to C++ and Java. 
Line 19: Line 19:
 [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/JavaScript_Overview#JavaScript_and_Java|JavaScript is not Java]].  [[https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/JavaScript_Overview#JavaScript_and_Java|JavaScript is not Java]]. 
  
-The ECMA and ISO standards organizations have standardized the core JavaScript language in [[http://developer.netscape.com/docs/javascript/e262-pdf.pdf|ECMA-262]] (ECMAScript) and ISO-16262. +The ECMA and ISO standards organizations have standardized the core JavaScript language in [[https://262.ecma-international.org/5.1/ECMA-262.pdf|ECMA-262]] (ECMAScript) and ISO-16262. 
  
 ===== Baja and JavaScript ===== ===== Baja and JavaScript =====
Line 65: Line 65:
 From within a Baja module, a JavaScript file may be executed using the following Baja code: From within a Baja module, a JavaScript file may be executed using the following Baja code:
 <code baja> <code baja>
-exec "?modname" # where modname is the JavaScript file.+exec "?modname" # where modname is the JavaScript filename or base filename.
 </code> </code>
 or: or:
 <code baja> <code baja>
-exec "*modname" # where modname is the JavaScript file.+exec "*modname" # where modname is the JavaScript filename or base filename. 
 +</code> 
 +or: 
 +<code baja> 
 +exec_bin "modname" # where modname is the JavaScript filename or base filename.
 </code> </code>
 ===== Object Model ===== ===== Object Model =====
Line 131: Line 135:
 | ''log()''             | Yes              | Yes    | N/A          | N/A |                    | Yes((following the log-level argument)) | Displayed/logged on the server only | | ''log()''             | Yes              | Yes    | N/A          | N/A |                    | Yes((following the log-level argument)) | Displayed/logged on the server only |
 | ''console.print()''   | Yes              | No     | No           | Yes | Telnet-IAC, Ctrl-A | Yes | | | ''console.print()''   | Yes              | No     | No           | Yes | Telnet-IAC, Ctrl-A | Yes | |
-| ''console.write()''   | Yes              | No     | No           PETSCII only | Telnet-IAC         | Yes | No line-counting/auto-pause | +| ''console.write()''   | Yes              | No     | No           Yes | Telnet-IAC         | Yes | No line-counting/auto-pause | 
-| ''console.writeln()'' | Yes              | No     | Yes          | PETSCII only | Telnet-IAC         | Yes | No line-counting/auto-pause |+| ''console.writeln()'' | Yes              | No     | Yes          | Yes | Telnet-IAC         | Yes | No line-counting/auto-pause |
 | ''console.putmsg()''  | Yes              | No     | No           | Yes | Telnet-IAC, Ctrl-A, [[custom:atcodes|@-Codes]], [[custom:colors|Extra Attributes]] | No        | Typically used for displaying text/menu files | | ''console.putmsg()''  | Yes              | No     | No           | Yes | Telnet-IAC, Ctrl-A, [[custom:atcodes|@-Codes]], [[custom:colors|Extra Attributes]] | No        | Typically used for displaying text/menu files |
 | ''console.center()''  | Yes              | No     | Yes          | Yes | Telnet-IAC, Ctrl-A | No | Text centered on screen | | ''console.center()''  | Yes              | No     | Yes          | Yes | Telnet-IAC, Ctrl-A | No | Text centered on screen |
Line 142: Line 146:
 === Carriage Returns === === Carriage Returns ===
 If you wish to send a traditional "carriage return" character to the client terminal (i.e. move the cursor to the far left column without advancing to the next line) it is recommended that you use an output method/function that supports [[custom:Ctrl-A codes]] and you send the Ctrl-A ''[''  sequences //instead of// an ASCII 13 (''\r'') character. This is required for PETSCII terminal compatibility, where an ASCII 13 character performs a complete "newline" sequence (the equivalent of ''\r\n'') on the client terminal. If you wish to send a traditional "carriage return" character to the client terminal (i.e. move the cursor to the far left column without advancing to the next line) it is recommended that you use an output method/function that supports [[custom:Ctrl-A codes]] and you send the Ctrl-A ''[''  sequences //instead of// an ASCII 13 (''\r'') character. This is required for PETSCII terminal compatibility, where an ASCII 13 character performs a complete "newline" sequence (the equivalent of ''\r\n'') on the client terminal.
 +
 +==== Input ==== 
 +
 +^ Method                    ^ BBS((Terminal Server)) ^ JSexec ^ Notes ^
 +| ''read()''                | Yes                    | Yes    | Read up to maxlen (default 128) characters of input  |
 +| ''readln()''              | Yes                    | Yes    | Read a string (line of input) from user, up to maxlen chars (default: 128) |
 +| ''console.inkey()''       | Yes                    | No     | Wait for a key-press or an elapsed timeout duration |
 +| ''console.getstr()''      | Yes                    | No     | Get a string of characters from user  |
 +| ''console.getkey()''      | Yes                    | No     | Get a single key-press       |
 +| ''console.getbyte()''     | Yes                    | No     | Get an unprocessed input byte from remote terminal as a number |
 +| ''console.getnum()''      | Yes                    | No     | Get a number (between 1 and maxnum) from user     |
 +| ''console.getkeys()''     | Yes                    | No     | Get a key from a list of valid keys, or a number  |
 +| ''console.gettemplate()'' | Yes                    | No     | Get a string conforming to a provided input template  |
 +
 +==== Prompt ==== 
 +
 +Often you'll want your script to prompt the user for some input (e.g. a string of text or a single key). A prompt involves both //output//  (first, from the BBS) and //input// (from the user):
 +
 +^ Method              ^ BBS((Terminal Server)) ^ JSexec ^ Notes ^
 +| ''prompt()''        | Yes                    | Yes    |       |
 +| ''confirm()''       | Yes                    | Yes    |       |
 +| ''deny()''          | Yes                    | Yes    |       |
 +| ''console.yesno()'' | Yes                    | No           |
 +| ''console.noyes()'' | Yes                    | No           |
 +| ''console.mnemonics()'' | Yes                    | No           |
 +
 ===== See Also ===== ===== See Also =====
   * [[http://synchro.net/docs/jsobjs.html|Synchronet JavaScript Object Model]]   * [[http://synchro.net/docs/jsobjs.html|Synchronet JavaScript Object Model]]