Repository navigation
Width
Home › Console Functions › Width
Sets or returns the number of columns and rows of the console.
Width [columns] [, rows]
Width LPrint columns
Width { #filenum | devicename }, columns
result = Width( )columnsrowsfilenumdevicename
Sets the maximum number of columns of characters of an output device (console, printer or text file). If text sent to the device reaches the width an automatic carriage return is generated.
Using Width as a function returns the current console width in the low word and the current height in the high word.
If a device is not given then Width takes effect on the active console/graphics screen, and a second argument specifying maximum number of rows is allowed.
In graphics modes Width is used to indirectly select the font size by setting one of the character height * width pairs allowed (See Screen (Graphics)). If rows / cols is an invalid combination, no changes are made to the screen display.
Valid font heights are 8 pixels, 14 pixels and 16 pixels. The fonts all have a fixed width of 8 pixels.
(see second example)
Using the Width command in graphic mode also forces a screen clear (Cls).
Returns a 32 bit Long where the High Word is the number of rows and the Low Word is the number of columns currently set.
- In a Windows console any values >
0can be used in windowed mode. - On a DOS or Windows full-screen console, the valid dimensions depend on the capabilities of the hardware.
- Linux doesn't allow applications to change the console size.
-
columnswas limited to40or80, whilerowscould be25,30,43,50or60, depending on the graphics hardware and screen mode being used.
Dim As Long w
w = Width
Print "rows: " & HiWord(w)
Print "cols: " & LoWord(w)''Set up a graphics screen
Const W = 320, H = 200
ScreenRes W, H
Dim As Long twid
Dim As UInteger tw, th
'' Fetch and print current text width/height:
twid = Width()
tw = LoWord(twid): th = HiWord(twid)
Print "Default for current screen (8*8)"
Print "Width: " & tw
Print "Height: " & th
Sleep
Width W\8, H\16 '' Use 8*16 font
twid = Width()
tw = LoWord(twid): th = HiWord(twid)
Print "Set to 8*16 font"
Print "Width: " & tw
Print "Height: " & th
Sleep
Width W\8, H\14 '' Use 8*14 font
twid = Width()
tw = LoWord(twid): th = HiWord(twid)
Print "Set to 8*14 font"
Print "Width: " & tw
Print "Height: " & th
Sleep
Width W\8, H\8 '' Use 8*8 font
twid = Width()
tw = LoWord(twid): th = HiWord(twid)
Print "Set to 8*8 font"
Print "Width: " & tw
Print "Height: " & th
SleepCategory: Console Functions
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing