Syntax: sadd (stringvar$)
Type: function
Returns the memory offset of the string data in the string variable.
e.g.
See also varptr.
Syntax: SCREEN mode[,[ depth][,[ num_pages][, fullscreen]]]
Type: statement
Category: Gfx
Statement to set current gfx mode.
'mode' is the graphics screen mode number, see below.
'depth' is the color depth in bits per pixel. If you omit this argument, the
default depth for given mode is set.
'num_pages' is the number of video pages you want, see below. Default if omitted
is 1.
'fullscreen' is a flag. Set this argument to 0 to request a windowed mode, 1 to
request a fullscreen mode. Default if omitted is 0.
The SCREEN statement sets the current gfx mode. Available modes list follows:
Mode 1: 320x200 in CGA emulation. 40x25 text format, 8x8 character size. 16 background colors and one of four sets of foreground colors set by the COLOR statement. Mode 2: 640x200 in CGA emulation. 80x25 text format, 8x8 character size. 16 colors assigned to any of 2 attributes. Mode 7: 320x200 in EGA emulation. 40x25 text format, 8x8 character size. 16 colors assigned to any of 16 attributes. Mode 8: 640x200 80x25 text format, 8x8 character size. 16 colors assigned to any of 16 attributes. Mode 9: 640x350 80x25 or 80x43 text format, 8x14 or 8x8 character size. 64 colors assigned to any of 16 attributes. Mode 11: 640x480 80x30 or 80x60 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 2 attributes. Mode 12: 640x480 80x30 or 80x60 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 16 attributes. Mode 13: 320x200 40x25 text format, 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 14: 320x240 40x30 text format, 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 15: 400x300 50x37 text format, 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 16: 512x384 64x24 or 64x48 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 17: 640x400 80x25 or 80x50 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 18: 640x480 80x30 or 80x60 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 19: 800x600 100x37 or 80x75 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 20: 1024x768 128x48 or 128x96 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes. Mode 21: 1280x1024 160x64 or 160x128 text format, 8x16 or 8x8 character size. Assignment of up to 256K colors to any of 256 attributes.
For modes 14 and up, the depth parameter changes the color depth to the
specified new one; if depth is not specified, these modes run in 8bpp. For modes
13 and below, depth has no effect. The num_pages parameter specifies the number
of "pages" supported by the video mode: a page is either the visible screen or
an offscreen buffer the same size of the screen. You can show a page while
working on another one; see the SCREENSET statement for
details. You can request any number of pages for any video mode; if you omit
num_pages, only the visible page (number 0) will be available. Depending on if
the fullscreen parameter is 0 or 1, SCREEN will try to set the specified video
mode in windowed or fullscreen mode, respectively. If fullscreen is 1 and the
system cannot set specified mode in fullscreen, it'll try in windowed mode. If
fullscreen is 0 and the system fails to open a window for specified mode, it'll
try fullscreen. If everything fails, SCREEN will have no effect and execution
will resume from the statement following the SCREEN call. You should take care
of checking if a gfx mode has been set or not, and behave accordingly; a way to
check if SCREEN is successful is to test the return value of the SCREENPTR
function, have a look at it for details. Once a gfx mode has been set, you can
toggle fullscreen and windowed mode at any time by pressing ALT-ENTER, providing
the system supports it. While in windowed mode, clicking on the window close
button will return CHR$(255)+"X" to INKEY$, while clicking
on the maximize window button will switch to fullscreen mode if possible. A
successful SCREEN call sets currently visible and working pages both to page
number 0, resets the palette to the specified mode one (see
Default
palettes), resets the clipping region to the size of the screen, disables
custom coordinates mappings, moves the gfx cursor to the center of the screen,
moves the text cursor to the top-left corner of the screen and sets foreground
and background colors to bright white and black respectively.
Example:
See also PALETTE, SCREENLOCK,
SCREENUNLOCK, SCREENPTR,
SCREENSET, SCREENCOPY,
SCREENINFO.
Differences:
Between QB:
Parameters differ, FB version allows additional modes and color depths, and
any number of pages in any mode.
Syntax: SCREENCOPY [from_page][, to_page]
Type: statement
Category: Gfx
Statement to copy the contents of a graphical page into another graphical
page.
'from_page' is the page to copy from. If you omit this argument, the current
work page is assumed.
'to_page' is the page to copy to. If you omit this argument, the currently
visible page is assumed.
You can use this function to add a double buffer to your graphics. Any SCREEN
mode supports this function; you must supply valid page numbers otherwise
SCREENCOPY will have no effect. This function has two aliases:
FLIP and PCOPY.
Example:
See SCREENSET example.
See also screen (graphics),
SCREENSET.
Differences:
Between QB:
Function new in FB: works like the QB PCOPY statement, but
works for any gfx mode, providing you requested enough pages.
Syntax: SCREENINFO
Type: function
Category: Gfx
Function to retrieve information about current video mode.
This function can be useful to get current mode informations like gfx driver
name, color depth, screen size and more. It returns a pointer to a read-only
variable of type SCREENINFOTYPE, defined as follows:
Here's a description of available fields:
driver_name Name of current gfx driver in use, like "DirectX" or "X11". w Width of the screen in pixels. h Height of the screen in pixels. depth Current pixel format bits per pixel: this can be 1, 2, 4, 8, 16 or 32. See appendix C for details. pitch Size of a framebuffer row in bytes. bpp Bytes per pixel. mask_color Color value for transparent pixels in current mode. num_pages Number of available pages. flags Mode flags. If bit 0 is set mode is fullscreen, otherwise it's windowed.
If no gfx mode is set when you call this function, the returned structure will
report "none" as driver_name and 0 to all other fields. If you change video mode
via SCREEN (graphics), the informations
returned by previous calls to SCREENINFO are invalidated, and you have to recall
SCREENINFO to obtain the updated new settings. You never have to deallocate the
returned structure.
Example:
See also screen (graphics),
Internal pixel formats.
Differences:
New to FreeBasic.
Syntax: screenlock
Type: statement
Category: Gfx
Statement to lock work page framebuffer.
The SCREENLOCK function locks the current work page framebuffer for direct
memory access. Once the page is locked, the screen contents stop being updated
automatically and you can't call any of the primitive drawing functions until
you unlock the page with the SCREENUNLOCK statement.
While the work page is locked, you can read/write its memory freely; you must
call SCREENUNLOCK when you are done. It is strongly
recommended that you hold a page locked for a time as short as possible, and you
should also note that you are not supposed to call SCREENLOCK if a lock has not
been unlocked first. If the work page is the same as the visible page, any
modifications to the page memory while locked will not become visible until
SCREENUNLOCK is called.
Example:
See SCREENPTR example.
See also SCREEN (graphics),
SCREENUNLOCK, SCREENPTR.
Differences:
New to FreeBasic
Syntax: screenptr
Type: function
Category: Gfx
The SCREENPTR function returns a pointer to the current work page framebuffer
memory, or NULL (0) if no gfx mode is set. It can be used either to test if a
call to SCREEN (graphics) is successful, either
to do read/write operations directly to the work page memory, providing the page
is first locked and later unlocked via the SCREENLOCK
and SCREENUNLOCK statements. The pointer returned by
SCREENPTR is only valid after a successful call to
SCREEN (graphics), and is invalidated by
subsequent calls to SCREEN (graphics).
Example:
See also SCREEN (graphics),
SCREENLOCK, SCREENUNLOCK,
ptr, pointer.
Differences:
New to FreeBasic.
Syntax: SCREENSET [work_page][, visible_page]
Type: statement
Category: Gfx
Statement to set current work and visible pages.
SCREENSET allows to set the current working page and the current visible page.
Page numbers can range 0-(num_pages - 1), where num_pages is the number of pages
set by the most recent call to the SCREEN
(graphics) statement. You can use this function to achieve page-flipping or
double-buffering. If you omit work_page but not visible_page, only visible page
is changed. If you omit visible_page but not work_page, only work page is
changed. If you omit both arguments, both work page and visible page are reset
to page 0.
Example:
See also SCREEN (graphics),
SCREENCOPY.
Differences:
New to FreeBasic.
Syntax: SCREENUNLOCK [start_line][, end_line]
Type: statement
Category: Gfx
Statement to unlock work page framebuffer.
'start_line' is an optional argument specifying first screen line to be updated.
If you omit this argument, top screen line is assumed.
'end_line' is an optional argument specifying last screen line to be updated. If
you omit this argument, bottom screen line is assumed.
SCREENUNLOCK unlocks the current work page assuming it was previously locked by
calling SCREENLOCK; do not call
SCREENUNLOCK if no page has been locked yet. This
function lets the system restart updating the screen regularly, and when called
produces the immediate update of the screen region marked by the given start and
end lines. When no lock is held, you can again safely call the gfx primitive
statements, but you cannot access the work page framebuffer directly via
SCREENPTR.
Example:
See SCREENPTR example.
See also SCREEN (graphics),
SCREENLOCK, SCREENPTR.
Differences:
New to FreeBasic.
Syntax: seek (file slot) as integer
Type: function
Returns the position (in bytes) within a file given the file slot.
e.g.
See also seek (set), open.
Syntax: seek (file slot, position)
Type: statement
Sets the position (in bytes) within a file for the next read/write to occur
at (given the file slot).
e.g. if you want to skip to the 100th byte in the file for reading/writing:
See also seek (return), open.
Type: statement
- SELECT CASE AS CONST statement, only integer constants
are allowed and a jump table is generated making the it much
faster than an ordinary SELECT when more than 4 CASE's have to be checked (v1c)
Syntax:
Select case (expression) case (expression list) ... [case (expression list 2) ...] [case else ...] end select Select case executes specific code depending on the value of an expression. If the expression matches the first case then it's code is executed otherwise the next cases are compaired and if one case matches then its code is executed. If no cases are matched and there is a 'case else' on the end then it wll be executed, otherwise the whole select case block will be skipped. Syntax of an expression list:
value [{to value | IS (conditional operator) value}][, ...]
example of expression lists:
Example of select case in use:
See also if...then.
Syntax: setdate newdate$
Type: statement
To set the date you just format the date and send to SetDate in a valid
format following one of the following: "mm-dd-yy", "mm-dd-yyyy", "mm/dd/yy", or
"mm/dd/yyyy" (mm is the month, dd is the day, yy and yyyy is the year.
e.g. to set the current date:
Syntax: setenviron "var=value
Type: statement
Category: misc
Modifies system environment variables.
E.g. to set the system variable "path" to "c:":
Differences:
Between QB:
This is the same as the command ENVIRON command.
SETMOUSE gfx statement to set mouse position and cursor visibility (lillo)
Syntax: sgn (number)
Type: function
Category: math
Returns -1 if the arguement is negative, returns 0 if the arguement is 0, and
returns 1 if the arguement is positive.
e.g.
Type: statement
Shared makes variables to be used in the main code and inside
subs/functions.
e.g.
Differences:
Between QB:
Only supported when used with DIM, REDIM or COMMON.
Type: statement
Category: Misc
Shell sends commands to the system command prompt.
e.g. for windows:
e.g. for linux:
Differences:
Between QB:
Argument is not optional, pass at least "".
Syntax: integer shl integer
Type: operator
Category: math
shifts all bits in the integer (to the left of shl) to the left by the
integer given (to the right of shl).
i.e.
&b0110 shl 1 will become &b1100.
This is the opposite of shr.
See also
Arithmetic operators.
Type: data type
16-bit signed whole-number data type.
See also ushort,
data types.
Differences:
The name "short" is new to FreeBasic, however they are the same as integers in
QB.
Syntax: integer shr integer
Type: operator
Category: math
shifts all bits in the integer (to the left of shr) to the right by the
integer given (to the right of shr).
i.e.
&b0110 shr 1 will become &b0011.
This is the opposite of shl.
See also
Arithmetic operators.
Syntax: SIN (angle as single)
Type: function
Category: math
Returns the sine of the angle (given in radians).
Type: data type
32-bit floating point (decimal) number.
See also
data types.
Syntax: sleep [time]
Type: statement
Category: Misc
If a time is given, sleep will wait 'time' milliseconds.
If no time is given, sleep will wait until the user presses a key.
e.g.
Differences:
Between QB:
Has millisecond accuracy, 1 is equal to 1ms, not 1 sec. Also pressing a key does
not interrupt the sleep process unless the time limit was omited.
Syntax: space$(n)
Type: function
Returns a string full of spaces, with the length of 'n'.
e.g.
See also string$.
Syntax: spc(n)
Type: function
Category: Console
Redundant although still supported. Use space$ instead.
This was probably a command in old basic dialects. Originally it was only used
with print and lprint. Now you can
use space$.
Syntax: sqr (number)
Type: function
Category: math
Returns the square root of the number given.
This is the same as number ^ (1/2).
e.g.
See also
arithmetic operators.
Type: statement
Declares variables and arrays which become local to a procedure and preserves
values between procedure calls (the values are not destroyed when the procedure
is ended).
See also $static.
Differences:
Between QB:
Can be used with arrays too, same way as DIM or REDIM.
Syntax: declare {function | sub} procName stdcall alias "procAliasName"
(parameterlist...) [as type]
Type: calling convention
See also declare, cdecl,
pascal.
v1c, havnt finished example..
Differences:
New to FreeBasic.
Type: keyword
Category: control flow
See for...next.
Type: statement
Category: Misc
Ends the execution of the program and returns to the system. It is
recommended to use end, as this command is provided only to
be compadibile with older basic dialects.
See also end.
Differences:
Between QB:
works the same way as END or SYSTEM.
Syntax: str$( number )
Type: function
Converts a number into a string. This is the opposite function of
val.
So str$(3) will become "3",
and str$(-3.1415) will become "-3.1415".
e.g.
See also val.
(See http://docs.netive.ru/susv3/idx/is.html )
strcat - concatenate two stringsThe strcat() function shall append a copy of the string pointed to by s2 (including the terminating null byte) to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1. If copying takes place between objects that overlap, the behavior is undefined.
RETURN VALUE
The strcat() function shall return s1; no return value is reserved to indicate an error.
(See http://docs.netive.ru/susv3/idx/is.html )
strrchr - string scanning operation
The strrchr() function shall locate the last occurrence of c (converted to a char) in the string pointed to by s. The terminating null byte is considered to be part of the string.
RETURN VALUE
Upon successful completion, strrchr() shall return a pointer to the byte or a null pointer if c does not occur in the string.
The strcmp() function shall compare the string pointed to by s1 to the string pointed to by s2.
The sign of a non-zero return value shall be determined by the sign of the difference between the values of the first pair of bytes (both interpreted as type unsigned char) that differ in the strings being compared.
Upon completion, strcmp() shall return an integer greater than, equal to, or less than 0, if the string pointed to by s1 is greater than, equal to, or less than the string pointed to by s2, respectively.
(See http://docs.netive.ru/susv3/idx/is.html )
strcpy - copy a stringThe strcpy() function shall copy the string pointed to by s2 (including the terminating null byte) into the array pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.
RETURN VALUE
The strcpy() function shall return s1; no return value is reserved to indicate an error
(See http://docs.netive.ru/susv3/idx/is.html )
strlen - get string length
The strlen() function shall compute the number of bytes in the string to which s points, not including the terminating null byte.
The strlen() function shall return the length of s; no return value shall be reserved to indicate an error.
(See http://docs.netive.ru/susv3/idx/is.html )
strncat - concatenate a string with part of another
The strncat() function shall append not more than n bytes (a null byte and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1. A terminating null byte is always appended to the result. If copying takes place between objects that overlap, the behavior is undefined.
RETURN VALUE
The strncat() function shall return s1; no return value shall be reserved to indicate an error.
The strncmp() function shall compare not more than n bytes (bytes that follow a null byte are not compared) from the array pointed to by s1 to the array pointed to by s2.
The sign of a non-zero return value is determined by the sign of the difference between the values of the first pair of bytes (both interpreted as type unsigned char) that differ in the strings being compared.
Upon successful completion, strncmp() shall return an integer greater than, equal to, or less than 0, if the possibly null-terminated array pointed to by s1 is greater than, equal to, or less than the possibly null-terminated array pointed to by s2 respectively.
(See http://docs.netive.ru/susv3/idx/is.html )
strncpy - copy part of a string
The strncpy() function shall copy not more than n bytes (bytes that follow a null byte are not copied) from the array pointed to by s2 to the array pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.
If the array pointed to by s2 is a string that is shorter than n bytes, null bytes shall be appended to the copy in the array pointed to by s1, until n bytes in all are written.
RETURN VALUE
The strncpy() function shall return s1; no return value is reserved to indicate an error.
(See http://docs.netive.ru/susv3/idx/is.html )
strrchr - string scanning operation
The strrchr() function shall locate the last occurrence of c (converted to a char) in the string pointed to by s. The terminating null byte is considered to be part of the string.
RETURN VALUE
Upon successful completion, strrchr() shall return a pointer to the byte or a null pointer if c does not occur in the string.
(See http://docs.netive.ru/susv3/idx/is.html )
strstr - find a substring
The strstr() function shall locate the first occurrence in the string pointed to by s1 of the sequence of bytes (excluding the terminating null byte) in the string pointed to by s2.
RETURN VALUE
Upon successful completion, strstr() shall return a pointer to the located string or a null pointer if the string is not found.
If s2 points to a string with zero length, the function shall return s1.
Type: data type
String is a data type which stores text, words, letters, or
characters. An example of "hello" is a string. All strings in
FreeBasic are text or letters surrounded in double quotes ("...").
inline string indexing as in "char = somestring[idx]" (V1c)
e.g. using strings:
see also
data types.
Type: function
Syntax:
string$(n, code)
string$(n, character$)
String repeats a character (given by the character code number, or
a string) 'n' times.
e.g. using string$ to make text underlined:
Syntax: [public | private] sub name ([parameter[,
parameter...]])
Type: statement
A small block of code used to perform a a sub-program based on
input parameters. This is used to code a common bit of code once,
and simply called to execute the code. Asin if you have common
code that must be executed which is only different by a few
values, placing the main bit of code in a sub will save you
writing the similar code many times over. Subs are either
public, or private
(default is public).
Sub is the same as function except it
doesnt allows a return value.
Example of writing colored text using a sub:
See also function, exit,
public, private.
Syntax: swap a, b
Type: statement
Swaps the value of two variables.
e.g. using swap to order 2 numbers:
Syntax: system
Type: statement
Category: Misc
Closes all open files and returns to the system. This is the
same as end and is here for compadibility
between older basic dialects. It is recommended to use
end instead.
e.g.
See also end.