NAME

Syntax: NAME oldname as string, newname as string
Type: statement
Category: File

Renames a file originally called oldname to newname.

e.g.

name "dsc001.jpg", "landscape.jpg"


will rename the file "dsc001.jpg" to "landscape.jpg".

Differences:
Between QB:
Name no longer uses the syntax "name oldname as newname" as that syntax is obscure only to this command. Now uses a more structured syntax "name oldname, newname".

NEXT

Type: keyword
Category: control flow

See also for...next.

Differences:
Between QB:
Multiple counters are not supported.

Version 0.05 Beta:
NEXT with multiple identifiers (NEXT a, b, ...), as many old sources seem to have that (v1ctor)

e.g.


NEXT a, b, c

NOT

Syntax: not a
Type: operator
Category: logic

returns true if the condition is false. This swaps the condition from true to false ahd false to true.

i.e.

not &b01010101


will return &b10101010.

See also Logical operators.

OCT$

Syntax: oct$ (n as integer)
Type: function

Returns a number in octal format (base 8) in a string. Octal digits range from 0 to 7, so 8 in decimal is 10 in octal (oct$(8) = "10").

See also bin$, hex$.

ON ERROR

Syntax: on error goto label
Type: statement
Category: Error

ON ERROR triggers a jump to an error handler when an error occurs.

e.g.


on error goto errorhandler 'sets the error handler label
error 24 'simulate error 24
print "this message will not be seen"

errorhandler:
print "Error #"; err; "!" 'show the error number
end 'end the program execution



See also error, err.

ON...GOSUB

Syntax: on expression gosub label1[, label2...]
Type: statement
Category: Keywords

Branches out to different labels depending on the value of an expression. 1 will branch to the first label, 2 to the second, etc. It will also remember where it branched from, and when 'return' is called it will return to where it was branched from.

However this command should be replaced with select case.

Anyway, here is a simple example:


choice = 3
on choice gosub labela, labelb, labelc
print "Good bye."
end

labela:
print "choice a"
return

labelb:
print "choice b"
return

labelc:
print "choice c"
return



See also select case, on...goto, gosub, return.

ON...GOTO

Syntax: on expression goto label1[, label2...]
Type: statement
Category: Keywords

Branches out to different labels depending on the value of an expression. 1 will branch to the first label, 2 to the second, etc.

However this command should be replaced with select case.

Anyway, here is a simple example:


choice = 3
on choice gosub labela, labelb, labelc

labela:
print "choice a"
end

labelb:
print "choice b"
end

labelc:
print "choice c"
end

See also select case, on...gosub, goto.

ONCE

keyword to be used with $INCLUDE or #INCLUDE as in: '$include once: "includethisfileonlyonce.bi" (v1c)
 

OPEN

Syntax: open file$ for {file mode} as #slot [LEN=record length]
Type: statement

Opens a file on the system for reading/writing in the given file slot, with the given file mode.

more written here later, but the basics. This example will read a line of text from the file "file.ext" in the current folder, and print the text on the screen.


f = freefile
open "file.ext" for input as #f
line input #f, ln$
print ln$
close #f



See also close, input #, get (file i/o), put (file i/o).

OPTION BASE

Syntax: option base {0 | 1}
Type: statement

Sets the default lower bound of an array subscript.
e.g.


option base 1
dim foo(10)


foo is now an array that ranges from foo(1) to foo(10). This is the same as dim foo(1 to 10). If option base 0 is used, foo would range from 0 to 10.

OPTION NOKEYWORD

remove intrinsic routines/statements (v1c)

option private

Syntax: option private
Type: statement

Sets subs/functions to be private by default (instead of public by default). This means subs/functions are only accessible within the module and is hidden to other modules, unless they have 'public' before them. This means two subs/functions can have the same name, as long as they are private and are in seperate modules.

e.g.


option private

sub I_am_private()
end sub

public sub I_am_public()
end sub



See also private, public, sub, function, option base.

Differences:
New to FreeBasic.

OR

Syntax: a or b
Type: operator
Category: logic

A bitwise operator which compares each bit in the two numbers and returns true if either coresponding bits are true. Useful to return true if either conditions are true.

i.e.

&b00110011 or &b01010101


will return &b01110111.

See also Logical operators.

OUT

Syntax: out port, value as byte
Type: statement
Category: Gfx

Statement for VGA port output emulation.

Used for lowlevel VGA palette management emulation, this function only accepts port numbers &h3C7, &h3C8 and &h3C9. You do not normally need this function; use 8bit or higher color depth modes and PALETTE instead.

See also PALETTE, INP, WAIT.

Differences:
Between QB:
This is just a limited emulation, and only ports &h3C7, &h3C8 and &h3C9 are supported for DOS VGA palette DAC registers writing operations. A write to any other port will have no effect.

Reason: user mode apps can't access IO ports directly in windows.

OUTPUT

Type: keyword
Category: file mode

A file mode used with open to allow the file to be written to with lines of text.

See also input (file mode).