Terminal control/Ringing the terminal bell: Difference between revisions

m
→‎{{header|REXX}}: added notes about ASCII vs. EBCDIC machines, added comments and examples.
No edit summary
m (→‎{{header|REXX}}: added notes about ASCII vs. EBCDIC machines, added comments and examples.)
Line 515:
=={{header|REXX}}==
There is no standard REXX built-in function to handle the sounding of the bell or a PC's speaker.
However, some REXX interpreters have added a non-stardard BIF.
<lang rexx>call beep(freq [,duration]) /*supported (kinda) by Regina. */
 
However, some REXX interpreters have added a non-stardardstandard BIF.
call sound(freq [,duration ]) /*supported by PC/REXX. */
<lang rexx>/*REXX program illustrates methods to ring the terminal bell or use the PC speaker. */
/*╔═══════════════════════════════════════════════════════════════╗
║ ║
║ Note that the hexadecimal code to ring the terminal bell ║
║ is different on an ASCII machine than an EBCDIC machine. ║
║ ║
║ On an ASCII machine, it is (hexadecimal) '07'x. ║
║ " " EBCDIC " " " " '2F'x. ║
║ ║
╚═══════════════════════════════════════════════════════════════╝*/
 
sayif 3=='07F3'x then bell= '2f'x /*workswe underare therunning Windowson DOSan shellEBCDIC machine. */
else bell= '07'x /* " " " " " ASCII " */
 
say copies('07'x,100)bell /*assound above,the but muchbell more annoyingon the terminal. */</lang>
say copies(bell, 20) /*as above, but much more annoying. */
 
/*╔═══════════════════════════════════════════════════════════════╗
║ ║
║ Some REXX interpreters have a built-in function (BIF) to ║
║ to produce a sound on the PC speaker, the sound is specified ║
║ by frequency and an optional duration. ║
║ ║
╚═══════════════════════════════════════════════════════════════╝*/
 
/* [↓] supported by Regina REXX: */
freq= 1200 /*frequency in (nearest) cycles per second. */
call beep freq /*sounds the PC speaker, duration= 1 second.*/
ms= 500 /*duration in milliseconds. */
call beep freq, ms /* " " " " " 1/2 " */
 
 
/* [↓] supported by PC/REXX & Personal REXX:*/
freq= 2000 /*frequency in (nearest) cycles per second. */
call sound freq /*sounds PC speaker, duration= .2 second. */
secs= .333 /*duration in seconds (round to nearest tenth).*/
call sound freq, secs /* " " " " 3/10 " */
 
/*stick a fork in it, we're done making noises.*/</lang>
 
=={{header|Ring}}==