UBOUND

Syntax: ubound(array[, dimension])
Type: function

Ubound returns the highest index that can be used in the array 'array'.

Optionally 'dimension' says what dimension to check the highest bound. 1 for first dimension, and 2 for second dimension etc.

e.g.


dim array(-10 to 10, 5 to 15, 1 to 2) as integer
print ubound(array, 1) 'returns 10
print ubound(array, 2) 'returns 15
print ubound(array, 3) 'returns 2



See also lbound, dim.

ubyte

Type: data type

8-bit unsigned whole-number data type.

See also byte, data types.

Differences:
New to FreeBasic.

UCASE$

Syntax: ucase$ (text$)
Type: function

returns the input string making all letters in upper case.

e.g.

print ucase$("Hello World abCDefGH")

See also lcase$.

UDT

arguments now can be declared and passed by value too (v1c)
 

 

uinteger

Type: data type

32-bit unsigned whole-number data type.

See also integer, data types.

Differences:
New to FreeBasic.

union

Type: statement

Differences:
New to FreeBasic.

UNLOCK

Syntax: UNLOCK fileslot [, {record | [start] TO end}]
Type: statement
Category: File

Unlock will unlock access to a previously locked file, or part of a file.

See lock to do the opposite (lock access to a file), and for sample code.

unsigned

Syntax: as unsigned {integer-based data type}

Forces an integer-based data type to be unsigned (cannot contain negative numbers, but has it's maximum value doubled).

e.g. notice what is displayed:


dim x as unsigned integer
x = -1
print x

Differences:
New to FreeBasic.

UNTIL

Type: keyword
Category: conditional

UNTIL is used with the do...loop structure. See it for more info.

ushort

Type: data type

16-bit unsigned whole-number data type.

See also short, data types.

Differences:
New to FreeBasic.

VAL

Syntax: val( number$ )
Type: function

Converts a string to a number. The number must appear at the beginning of the string. This is the opposite function of str$.

e.g. val("10") will return 10,
and val("-271.3") will return -271.3.
If the string is invalid (asin doesnt contain a number) the result will be 0 (val("abcd") is 0).

e.g.


dim a as string, b as integer
a = "123"
b = val(a)
print a, b



See also str$.

VARPTR

Syntax: varptr(variable)
Type: function

Returns the memory address of a variable. This was used for pointer features in older basic dialects, and is still useful for pointer arithmetic in FreeBasic.

An example of using varptr:


dim a as integer, addr as integer
a = 10
addr = varptr(a)
pokei addr, -1000
print a
poke addr + 1, 128 'change 1/2 of the bits using basic pointer arithmetic
print a



See also poke

VIEW (Graphics)

Syntax: VIEW [[SCREEN] (x1, y1)-(x2, y2)[,[ color][, border]]]
Type: statement
Category: Gfx

Statement to define new physical coordinates mapping and clipping region.

'SCREEN' - When specified, any x,y coordinate will be relative to the top-left corner of the screen, and not to the left-top corner of the viewport.

'x1',y1','x2','y2' - Coordinates of the top-left and bottom-right corners of the new viewport.

'color' - Color with which to clear the new viewport; if you omit this argument, the viewport will not be cleared.

'border' - Color of the border box surrounding the new viewport. If you omit this argument, no border box will be drawn.

Use this statement to set a new clipping region, also known as viewport. The new viewport will override the previous one, if any; if the SCREEN argument is omitted, all future coordinates specifications will be relative to the top-left corner of the new viewport, instead of relative to the top-left corner of the screen. Any graphical primitive will be affected by the new viewport, and drawing outside specified region will produce no effect. If color is specified, in the same format as the one supported by COLOR, the new viewport is cleared with it; if border is specified, also in COLOR format, a box using border as color will be drawn surrounding given region. If all arguments are omitted, the viewport is reset to the screen mode size.

See also SCREEN (graphics), WINDOW, PMAP, VIEW (Text).

VIEW (Text)

Type: statement
Category: Console

Sets the boundaries of the console screen text area.

lillo: is this supported in linux?

Differences:
diff: scrolling quirks may not be exactly the same.

WAIT

Syntax: WAIT port, and_expr[, xor_expr]
Type: statement
Category: Gfx

Statement for DOS port data waiting emulation. This is here for compadibility and is not recommended to be used.

'port' - DOS port number onto wait data for.

'and_expr' - Integer expression to be ANDed with data from the port; if the result of this operation is not 0, the statement returns.

'xor_expr' - Integer expression to be XORed with data from the port, before passing it to and_expr. If you omit this argument, 0 is assumed.

The only port number WAIT supports is &h3DA, for vertical blank syncing. You should only call WAIT this way:

WAIT &h3DA, 8



Any other combination of port, and_expr and xor_expr will have no effect.

Example:
See the SCREENSET example.

See also INP, OUT.

Differences:
Between QB:
This is just an emulation of the QB WAIT statement, and only supports port number &h3DA. This is because it is specific to DOS, many other platforms cannot access ports directly.

WEND

Type: keyword
Category: control flow

See while...wend.

WHILE...WEND

Type: statement
Category: control flow

Syntax:
While condition
...
Wend

While...wend repeats the statements between while and wend, while the condition is true.

e.g.

x = 10
while x > 5
print "x is :"; x
x = x - 1
wend

See also do...loop.

width

Syntax: width columns, rows
Type: statement
Category: Console

Sets the console screen size in windows. This command doesnt work in linux.

e.g.


width 40, 25
print "hello"

Differences:
Between QB:
Only works for console, no file or printer.

 

With.. end with

type MYTYPE
a as integer
b as double
c as string * 4
end type

dim shared t(10) as MYTYPE

t(0).a = 1
t(0).b = 2.0
t(0).c = "3"

i = 5

with t(i)
.a = t(0).a
.b = t(0).b
.c = t(0).c
end with
 

WINDOW

Syntax: WINDOW [[SCREEN] (x1, y1)-(x2, y2)]
Type: statement
Category: Console

Statement to define new view coordinates mapping for current viewport.

'SCREEN' - Optional argument specifying y coordinates increase from top to bottom.

'x1','y1','x2','y2' - New floating point values corresponding to the opposite corners of the current viewport.

WINDOW is used to define a new coordinates system. '(x1,y1)' and '(x2,y2)' are the new coordinates to be mapped to the opposite corners of the current viewport; all future coordinates passed to gfx primitive statements will be affected by this new mapping. If SCREEN is omitted, the new coordinates system will be cartesian, that is, with y coordinates increasing from bottom to top. Call WINDOW with no argument to disable the coordinates transformation.

See also SCREEN (graphics), VIEW (graphics), pmap.

Windowtitle

Syntax: WINDOWTITLE title$
Type: statement
Category: Gfx

Statement to set the program window title.

'title$' - String to be assigned as new window title.

This statement is useful to change the program window title. The new title set will become active immediately if the program already runs in windowed mode, otherwise will become the new title for any window produced by subsequent calls to the SCREEN (graphics) statement. If you never call this function before setting a new windowed mode via SCREEN (graphics), the program window will have your executable file name without extension as title by default.

Example:


WINDOWTITLE "FreeBASIC example program"
SCREEN 15
SLEEP



See also screen (graphics).

Differences:
New to FreeBasic.

WRITE (File I/O)

Type: statement
Category: File

WRITE (Screen I/O)

Type: statement
Category: Console

XOR

Syntax: a xor b
Type: operator
Category: logic

XOR is "either one or the other" logic. This is the same as or but it will not be true if both bits are true.

A bitwise operator which compares each bit in the two numbers and returns true if either bit is true, but not if both are true. Useful to return true if either conditions are true.

i.e.

&b00110011 or &b01010101


will return &b01100110.

See also Logical operators.