Check output device is a terminal: Difference between revisions
Content added Content deleted
(added Ol) |
m (→{{header|REXX}}: changed wording a bit, fixed a typo, added whitespace, changed some comments, used a template for the output section, added the output from R4 REXX.) |
||
Line 496: | Line 496: | ||
{{works with|Personal REXX under DOS or in a DOS window under MS Windows}} |
{{works with|Personal REXX under DOS or in a DOS window under MS Windows}} |
||
{{works with|Regina in a DOS window under MS Windows}} |
{{works with|Regina in a DOS window under MS Windows}} |
||
Programming note: The comment about the REXX statements have to be on one line isn't quite true, |
Programming note: The comment about the REXX statements have to be on one line isn't quite true, |
||
<br>but because the REXX special variable '''SIGL''' is defined where it's executed, it makes coding simpler. |
<br>but because the REXX special variable '''SIGL''' is defined where it's executed, it makes coding simpler. |
||
⚫ | |||
⚫ | |||
:::* a '''CALL''' statement is used |
:::* a '''CALL''' statement is used |
||
:::* a ''function'' is invoked |
:::* a ''function'' is invoked |
||
:::* a '''SIGNAL''' statement is used |
:::* a '''SIGNAL''' statement is used |
||
Method used: since REXX has no direct way of determining if the STDIN is a terminal or not, the REXX code (below) |
Method used: since REXX has no direct way of determining if the STDIN is a terminal or not, the REXX code (below) |
||
<br>actually ''raises'' (which is no way to run a railroad) a syntax error when attempting to read the 2<sup>nd</sup> line from STDIN, |
<br>actually ''raises'' (which is no way to run a railroad) a syntax error when attempting to read the 2<sup>nd</sup> line from STDIN, |
||
<br>which causes a routine (named '''syntax:''') to get control, determines where the syntax error occurred, and returns |
<br>which causes a routine (named '''syntax:''') to get control, determines where the syntax error occurred, and returns |
||
<br>appropriate string indicating if STDIN is a '''terminal''' (or '''other'''). |
<br>an appropriate string indicating if STDIN is a '''terminal''' (or '''other'''). |
||
<br><br>Note that under VM/CMS, this can be accomplished with a (host) command within REXX and then examining the results. |
<br><br>Note that under VM/CMS, this can be accomplished with a (host) command within REXX and then examining the results. |
||
<br>On IBM mainframes, a user can have STDIN defined, but the terminal can be ''disconnected''. |
<br>On IBM mainframes, a user can have STDIN defined, but the terminal can be ''disconnected''. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
/*──────────────────────────────────TESTSTDIN subroutine────────────────*/ |
|||
⚫ | |||
⚫ | |||
/*──────────────────────────────────SYNTAX subroutine───────────────────*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
'''output''' |
|||
⚫ | |||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
⚫ | |||
⚫ | |||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
{{out|output|text= when using the default input:}} |
|||
<pre> |
<pre> |
||
output device: terminal |
output device: terminal |
||
</pre> |
|||
{{works with|R4 REXX under DOS or in a DOS window under MS Windows}} |
|||
The following is the output when used with '''R4''' REXX: |
|||
{{out|output|text= when using the default input:}} |
|||
<pre> |
|||
Reading console input (Press Ctrl-Z to quit): |
|||
◄■■■■■■■■ user input (pressed ENTER) |
|||
◄■■■■■■■■ user input (pressed ENTER a 2nd time) |
|||
output device: 6 |
|||
</pre> |
</pre> |
||