{{fbdoc item="title" value="WIDTH"}}----
Sets or gets the number of rows and columns of the display

{{fbdoc item="syntax"}}##
	**Width** [//columns//] [, //rows//]
	**Width** **Lprint** //columns//
	**Width** { #//filenum// | //devicename// }, //columns//
	//result// = **Width**( )
##
{{fbdoc item="param"}}
	##//columns//##
		columns (in characters) for output
	##//rows//##
		rows (in characters) for output
	##//filenum//##
		file number to apply to
	##//devicename//##
		device name to apply to

{{fbdoc item="ret"}}
	Returns a 32 bit ##[[KeyPgLong|Long]]## where the [[KeyPgHiword|high word]] is the number of rows and the [[KeyPgLoWord|low word]] is the number of columns currently set.

{{fbdoc item="desc"}}
	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 ##[[KeyPgScreengraphics|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 (##[[KeyPgCls|Cls]]##).

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/console/width-func.bas"}}%%(freebasic)
Dim As Long w
w = Width
Print "rows: " & hiword(w)
Print "cols: " & loword(w)
%%

	{{fbdoc item="filename" value="examples/manual/console/width.bas"}}%%(freebasic)
''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
sleep
%%
{{fbdoc item="target"}}
	- In a Windows console any values > ##0## can 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.

{{fbdoc item="diff"}}
	- ##//columns//## was limited to ##40## or ##80##, while ##//rows//## could be ##25##, ##30##, ##43##, ##50## or ##60##, depending on the graphics hardware and screen mode being used.

{{fbdoc item="see"}}
	- ##[[KeyPgLoWord|Loword]]##
	- ##[[KeyPgHiword|Hiword]]##
	- ##[[KeyPgCsrlin|Csrlin]]##
	- ##[[KeyPgPos|Pos]]##

{{fbdoc item="back" value="CatPgConsole|Console Functions"}}