Anonymous user
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:▼
<pre>
Buffer Height: 300
Buffer Width: 80
Window Height: 25
Window Width: 80
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}}==
===
{{works with|brexx}}
{{works with|regina}}
{{works with|rexximc}}
Some
<lang rexx>width = 'tput'( 'cols' )▼
▲width = 'tput'( 'cols' )
height = 'tput'( 'lines' )
say 'The terminal is' width 'characters wide'
say 'and has' height 'lines'</lang>
▲</lang>
===
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:
<lang rexx>width=linesize()</lang>
===
<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.
<lang rexx> parse value scrsize() with sd sw</lang>
|