Jump to content

Terminal control/Dimensions: Difference between revisions

Added COBOL example and reworked the REXX section.
(Added C#)
(Added COBOL example and reworked the REXX section.)
Line 121:
}
</lang>
On the authors system this results in the following output:
 
On the authorsauthor's system this results in the following output:
<pre>
Buffer Height: 300
Buffer Width: 80
Window Height: 25
Window Width: 80
</langpre>
 
This perfectly demonstrates that the buffer may not be the same size as the window.
 
=={{header|COBOL}}==
{{works with|OpenCOBOL}}
<lang cobol> IDENTIFICATION DIVISION.
PROGRAM-ID. terminal-dimensions.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 num-lines PIC 9(3).
01 num-cols PIC 9(3).
 
SCREEN SECTION.
01 display-screen.
03 LINE 01 COL 01 PIC 9(3) FROM num-lines.
03 LINE 01 COL 05 VALUE "rows by " .
03 LINE 01 COL 13 PIC 9(3) FROM num-cols.
03 LINE 01 COL 16 VALUE " columns.".
 
PROCEDURE DIVISION.
ACCEPT num-lines FROM LINES
ACCEPT num-cols FROM COLUMNS
 
DISPLAY display-screen
 
* This pauses the program, as ncurses will immediately revert
* back to the console when the program ends.
CALL "C$SLEEP" USING BY CONTENT 3
 
GOBACK
.</lang>
 
=={{header|Euphoria}}==
Line 307 ⟶ 338:
 
=={{header|REXX}}==
===usingUsing TPUT under Linux/Unix===
{{works with|brexx}}
{{works with|regina}}
{{works with|rexximc}}
 
Some RexxREXX interpreters don't provide basic [[terminal control]] as part of the language. However, it's possible to determine the size of the terminal window by using external system commands:
<lang rexx>width = 'tput'( 'cols' )
<br>However, it's possible to determine the size of the terminal window by using external system commands:
<lang rexx>
width = 'tput'( 'cols' )
height = 'tput'( 'lines' )
 
say 'The terminal is' width 'characters wide'
say 'and has' height 'lines'</lang>
</lang>
 
===using LINESIZE bif===
The <code>LINESIZE</code> built-in function returns the (terminal) screen's width. It is supported by most (classic) REXX interpreters (and some others) such as: CMS REXX, TSO REXX, VSE REXX, the IBM REXX compiler, PC/REXX, Personal REXX, REXX/imc, R4 and ROO. A sample usage of it is:
Most (classic) REXX interpreters (and some others) such as
* CMS REXX
* TSO REXX
* VSE REXX
* IBM REXX compiler
* PC/REXX
* Personal REXX
* REXX/imc
* R4
* ROO
support the &nbsp; '''LINESIZE''' &nbsp; built-in function which returns the (terminal) screen's width.
<br><br>A sample usage of the &nbsp; '''LINESIZE''' &nbsp; bif is:
<lang rexx>width=linesize()</lang>
 
===using SCRSIZE bif===
<code>SCRSIZE</code> is another built-in function, and returns two integers: the screen depth and the screen width. A few classic REXX interpreters support it: PC/REXX, Personal REXX, R4 and ROO.
A few classic REXX interpretors support the &nbsp; '''SCRSIZE''' &nbsp; bif:
* PC/REXX
* Personal REXX
* R4
* ROO
The &nbsp; '''SCRSIZE''' &nbsp; bif returns two integers:
* the screen depth
* the screen width
<lang rexx> parse value scrsize() with sd sw</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.