mirror of
https://github.com/DualBrain/QB64.git
synced 2023-11-19 13:10:13 +00:00
Compare commits
4 commits
30b50c5658
...
9b4bb8f06b
Author | SHA1 | Date | |
---|---|---|---|
9b4bb8f06b | |||
6bab502741 | |||
ba9a914232 | |||
232b593b49 |
|
@ -1,3 +1,7 @@
|
|||
theme: jekyll-theme-slate
|
||||
title: QB64.com
|
||||
description: QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.
|
||||
description: QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.
|
||||
include:
|
||||
- wiki/*
|
||||
keep_files:
|
||||
- wiki/*
|
||||
|
|
46
wiki/$ASSERTS.md
Normal file
46
wiki/$ASSERTS.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
The [$ASSERTS]($ASSERTS) metacommand enables debug tests with the [_ASSERT](_ASSERT) macro.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$ASSERTS]($ASSERTS)
|
||||
|
||||
> [$ASSERTS]($ASSERTS):CONSOLE
|
||||
|
||||
## Description
|
||||
|
||||
* If an error message is passed to the [_ASSERT](_ASSERT) statement, it is displayed in the console window if [$ASSERTS]($ASSERTS):CONSOLE is used.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Adding test checks for parameter inputs in a function.
|
||||
|
||||
```vb
|
||||
|
||||
$ASSERTS:CONSOLE
|
||||
|
||||
DO
|
||||
a = INT(RND * 10)
|
||||
b$ = myFunc$(a)
|
||||
PRINT a, , b$
|
||||
_LIMIT 3
|
||||
LOOP UNTIL _KEYHIT
|
||||
|
||||
FUNCTION myFunc$ (value AS SINGLE)
|
||||
_ASSERT value > 0, "Value cannot be zero"
|
||||
_ASSERT value <= 10, "Value cannot exceed 10"
|
||||
|
||||
IF value > 1 THEN plural$ = "s"
|
||||
myFunc$ = STRING$(value, "*") + STR$(value) + " star" + plural$ + " :-)"
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_ASSERT](_ASSERT)
|
||||
* [$CHECKING]($CHECKING)
|
||||
* [Relational Operations](Relational-Operations)
|
25
wiki/$CHECKING.md
Normal file
25
wiki/$CHECKING.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
The [$CHECKING]($CHECKING) metacommand turns C++ event checking ON or OFF.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$CHECKING]($CHECKING):{ON|OFF}
|
||||
|
||||
## Description
|
||||
|
||||
* The Metacommand does **not** require a comment or REM before it. There is no space after the colon.
|
||||
* The OFF action turns event checking off and should **only be used when running stable, errorless code.**
|
||||
* The default [$CHECKING]($CHECKING):ON action is only required when checking has been turned OFF previously.
|
||||
* When [$CHECKING]($CHECKING):OFF is used, all error code and the reporting code is removed from the EXE program.
|
||||
* **Warning: Turning OFF error checking could create a General Protection Fault (or segfault). Use only with 100% stable sections of code.**
|
||||
|
||||
### Details
|
||||
|
||||
* After every QB64 command is translated to C++, the compiler adds special code sections to check for [ON TIMER (n)](ON-TIMER-(n)) events and errors that may have occured in the last function call. Disabling error checking with the [$CHECKING]($CHECKING):OFF directive prevents the compiler from adding the extra code sections.
|
||||
* Setting [$CHECKING]($CHECKING):OFF is only designed for 100% stable, errorless sections of code, where every CPU cycle saved counts, such as in a software 3D texture mapper, for example.
|
||||
|
||||
## See Also
|
||||
|
||||
* [ON TIMER(n)](ON-TIMER(n))
|
||||
* [ON ERROR](ON-ERROR)
|
||||
* [Metacommand](Metacommand)
|
||||
* [ERROR Codes](ERROR-Codes)
|
62
wiki/$COLOR.md
Normal file
62
wiki/$COLOR.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
[$COLOR]($COLOR) is a metacommand that adds named color [CONST](CONST) in a program.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$COLOR]($COLOR):{0|32}
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
* [$COLOR]($COLOR):0 adds [CONST](CONST) for colors 0-15. The actual constant names can be found in the file **source/utilities/color0.bi**.
|
||||
* [$COLOR]($COLOR):32 adds [CONST](CONST) for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file **source/utilities/color32.bi**.
|
||||
* [$COLOR]($COLOR) is a shorthand to manually using [$INCLUDE]($INCLUDE) pointing to the files listed above.
|
||||
* *NOTE*: When using [$NOPREFIX]($NOPREFIX), the color constants change to **C_<old name>** (ex: **Blue** becomes **C_Blue**).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Adding named color constants for SCREEN 0:
|
||||
|
||||
```vb
|
||||
|
||||
$COLOR:0
|
||||
COLOR BrightWhite, Red
|
||||
PRINT "BrightWhite on red."
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Bright white on red.
|
||||
|
||||
```
|
||||
|
||||
Adding named color constants for 32-bit modes:
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 400, 32)
|
||||
$COLOR:32
|
||||
COLOR CrayolaGold, DarkCyan
|
||||
PRINT "CrayolaGold on DarkCyan."
|
||||
|
||||
|
||||
```
|
||||
|
||||
Using [$COLOR]($COLOR) with [$NOPREFIX]($NOPREFIX):
|
||||
|
||||
```vb
|
||||
|
||||
$NOPREFIX
|
||||
$COLOR:0
|
||||
COLOR C_BrightWhite, C_Red
|
||||
PRINT "BrightWhite on Red."
|
||||
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [COLOR](COLOR), [SCREEN](SCREEN)
|
||||
* [_NEWIMAGE](_NEWIMAGE), [$INCLUDE]($INCLUDE)
|
||||
* [$NOPREFIX]($NOPREFIX)
|
||||
* [Metacommand](Metacommand)
|
90
wiki/$CONSOLE.md
Normal file
90
wiki/$CONSOLE.md
Normal file
|
@ -0,0 +1,90 @@
|
|||
The [$CONSOLE]($CONSOLE) [metacommand](metacommand) creates a console window that can be used throughout a QB64 program module.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$CONSOLE]($CONSOLE)[:ONLY]
|
||||
|
||||
## Description
|
||||
|
||||
* [_CONSOLE](_CONSOLE) **ON** or **OFF** may be used to show or hide the console window at run time.
|
||||
* The **:ONLY** option can be used when only a console window is desired without a program window.
|
||||
* [_DEST](_DEST) and [_SOURCE](_SOURCE) are automatically set to [_CONSOLE](_CONSOLE) when the **:ONLY** option is used, in order to send screen output to the console window and get input from it too.
|
||||
* In normal [$CONSOLE]($CONSOLE) mode (dual screen) you have to manually set [_DEST](_DEST) and [_SOURCE](_SOURCE) to [_CONSOLE](_CONSOLE) in order to work with the console window.
|
||||
* [_SCREENHIDE](_SCREENHIDE) and [_SCREENSHOW](_SCREENSHOW) can be used to hide or show the main program window.
|
||||
* [_DELAY](_DELAY) or [SLEEP](SLEEP) can be used to allow the console window to be set in front of the main program window.
|
||||
* [_CONSOLETITLE](_CONSOLETITLE) can be used to change the title of the console window.
|
||||
* **Note:** Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
|
||||
> To copy console text output, right click the title bar and select *Edit* for *Mark* to highlight and repeat to *Copy*
|
||||
* QB64 [Metacommand](Metacommand)s are not commented out with ' or REM, differently from QBasic metacommands.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Hiding and displaying a console window. Use [_DELAY](_DELAY) to place console in front of main program window.
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE
|
||||
_DELAY 4
|
||||
|
||||
_CONSOLE OFF
|
||||
_DELAY 4
|
||||
_CONSOLE ON
|
||||
|
||||
_DEST _CONSOLE
|
||||
PRINT "Close this console window or click main window and press a key!"
|
||||
|
||||
```
|
||||
|
||||
How to use a Console window to copy screen output using the *Edit* menu by right clicking the console title bar.
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE
|
||||
_DEST _CONSOLE
|
||||
|
||||
c&& = -1: d& = -1: e% = -1: f%% = -1
|
||||
hx$ = HEX$(f%%)
|
||||
PRINT "Max hex _BYTE = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(e%)
|
||||
PRINT "Max hex INTEGER = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(d&)
|
||||
PRINT "Max hex LONG = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(c&&)
|
||||
PRINT "Max hex _INTEGER64 = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(9223372036854775807)
|
||||
PRINT "Max _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits"
|
||||
hx$ = HEX$(-9223372036854775808)
|
||||
PRINT "Min _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits"
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Max hex _BYTE = FF with 2 digits = 255
|
||||
Max hex INTEGER = FFFF with 4 digits = 65535
|
||||
Max hex LONG = FFFFFFFF with 8 digits = 4294967295
|
||||
Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
|
||||
Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits
|
||||
Min _INTEGER64 value = 8000000000000000 with 16 digits
|
||||
|
||||
```
|
||||
|
||||
> *Console:* Right click and select *Edit* > *Select All* (mouse highlight after) then hit Enter or select *Edit* > *Copy* to the [_CLIPBOARD$ (function)](_CLIPBOARD$-(function)).
|
||||
|
||||
```text
|
||||
|
||||
Max hex _BYTE = FF with 2 digits = 255
|
||||
Max hex INTEGER = FFFF with 4 digits = 65535
|
||||
Max hex LONG = FFFFFFFF with 8 digits = 4294967295
|
||||
Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
|
||||
|
||||
```
|
||||
|
||||
> *Copied text:* The above text was copied after *Select All* was selected and the smaller area was re-highlighted with the mouse.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CONSOLE](_CONSOLE)
|
||||
* [$SCREENHIDE]($SCREENHIDE), [$SCREENSHOW]($SCREENSHOW) (QB64 [Metacommand](Metacommand)s)
|
||||
* [_SCREENHIDE](_SCREENHIDE), [_SCREENSHOW](_SCREENSHOW)
|
||||
* [C Libraries](C-Libraries)
|
39
wiki/$DEBUG.md
Normal file
39
wiki/$DEBUG.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
**$DEBUG** is precompiler [Metacommand](Metacommand), which enables debugging features, allowing you to step through your code running line by line and to inspect variables and change their values in real time.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$DEBUG]($DEBUG)
|
||||
|
||||
## Description
|
||||
|
||||
* **$DEBUG** injects extra code in the resulting binary, allowing the IDE to control the execution flow of your program.
|
||||
* When **$DEBUG** is used, the IDE will connect to your running program using a local TCP/IP connection.
|
||||
* You may get a prompt from your Operating System regarding this, so it may be necessary to allow the IDE to receive connections.
|
||||
* No external connections are created, and your running program will only attempt to connect locally to the IDE.
|
||||
* The default TCP/IP port starts at 9001. Multiple running instances of the IDE will attempt to open ports 9002 and up.
|
||||
* You can change the base port in the Debug menu.
|
||||
* The metacommand is supposed to be removed once your program is ready for release, although leaving it in won't have any effect if your program isn't run from the IDE.
|
||||
* The only drawback of leaving the metacommand in is that your binary will end up being larger than required.
|
||||
|
||||
## $DEBUG Mode Operation
|
||||
|
||||
* To start execution in pause mode, you can use **F7** or **F8**.
|
||||
* There will be an arrow next to the line number where execution is paused, indicating the next line that will be run.
|
||||
* When you enable **$DEBUG** mode, you can set breakpoints by clicking the line number at which you wish to stop execution. This can also be achieved by using the **F9** key.
|
||||
* Breakpoints are indicated by a red dot next to the line number.
|
||||
* To clear all breakpoints, hit **F10**.
|
||||
* To skip a line during execution, shift-click a line number
|
||||
* Lines marked for skipping are indicated by an exclamation mark next to the line number.
|
||||
* **F4** opens the Variable List dialog, which allows you to add variables to the Watch List.
|
||||
* During execution, the Variable List dialog also allows you to set the values of variables and also to create Watchpoints.
|
||||
* Watchpoints halt execution, similarly to breakpoints, but do so when a variable matches the condition you specify.
|
||||
* You can use relational operators (=, <>, >=, <=, >, <) to create watchpoint conditions.
|
||||
* After a breakpoint or a watchpoint is reached, **F5** can be used to continue execution.
|
||||
* **F6** can be used when the execution pointer is inside a sub/function. When used, execution will proceed until the procedure is ended.
|
||||
* **F7** can be used to run line by line, and can be used to debug code inside subs/functions (Step Into).
|
||||
* **F8** can be used to run line by line without entering sub/function calls (Step Over).
|
||||
* **F12** can be used to show the current call stack (which procedure calls led to the current line).
|
||||
|
||||
## See Also
|
||||
|
||||
* [Metacommand](Metacommand)s
|
50
wiki/$DYNAMIC.md
Normal file
50
wiki/$DYNAMIC.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
The [$DYNAMIC]($DYNAMIC) [Metacommand](Metacommand) allows the creation of dynamic (resizable) arrays.
|
||||
|
||||
## Syntax
|
||||
|
||||
> {[REM](REM) | ['](apostrophe) } [$DYNAMIC]($DYNAMIC)
|
||||
|
||||
## Description
|
||||
|
||||
* QBasic [Metacommand](Metacommand) require [REM](REM) or [Apostrophe](Apostrophe) (') before them and are normally placed at the start of the main module.
|
||||
* Dynamic arrays can be resized using [REDIM](REDIM). The array's type cannot be changed.
|
||||
* All data in the array will be lost when [REDIM](REDIM)ensioned except when [_PRESERVE](_PRESERVE) is used.
|
||||
* [REDIM](REDIM) [_PRESERVE](_PRESERVE) can preserve and may move the previous array data when the array boundaries change.
|
||||
* [_PRESERVE](_PRESERVE) allows the [UBOUND](UBOUND) and [LBOUND](LBOUND) boundaries of an array to be changed. The number of dimensions cannot change.
|
||||
* [$DYNAMIC]($DYNAMIC) arrays must be [REDIM](REDIM)ensioned if [ERASE](ERASE) or [CLEAR](CLEAR) are used as the arrays are removed completely.
|
||||
|
||||
## Example(s)
|
||||
|
||||
[REDIM](REDIM)ing a $DYNAMIC array using [_PRESERVE](_PRESERVE) to retain previous array values.
|
||||
|
||||
```vb
|
||||
|
||||
REM $DYNAMIC 'create dynamic arrays only
|
||||
DIM array(10) 'create array with 11 elements
|
||||
FOR i = 0 TO 10
|
||||
array(i) = i: PRINT array(i); 'set and display element values
|
||||
NEXT
|
||||
PRINT
|
||||
REDIM _PRESERVE array(10 TO 20)
|
||||
FOR i = 10 TO 20
|
||||
PRINT array(i);
|
||||
NEXT
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
0 1 2 3 4 5 6 7 8 9 10
|
||||
|
||||
0 1 2 3 4 5 6 7 8 9 10
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$STATIC]($STATIC), [$INCLUDE]($INCLUDE)
|
||||
* [DIM](DIM), [REDIM](REDIM), [_DEFINE](_DEFINE)
|
||||
* [STATIC](STATIC)
|
||||
* [ERASE](ERASE), [CLEAR](CLEAR)
|
||||
* [Arrays](Arrays), [Metacommand](Metacommand)
|
1
wiki/$ELSE.md
Normal file
1
wiki/$ELSE.md
Normal file
|
@ -0,0 +1 @@
|
|||
See [$IF]($IF).
|
1
wiki/$ELSEIF.md
Normal file
1
wiki/$ELSEIF.md
Normal file
|
@ -0,0 +1 @@
|
|||
See [$IF]($IF).
|
1
wiki/$END-IF.md
Normal file
1
wiki/$END-IF.md
Normal file
|
@ -0,0 +1 @@
|
|||
See [$IF]($IF).
|
33
wiki/$ERROR.md
Normal file
33
wiki/$ERROR.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
The [$ERROR]($ERROR) metacommand triggers a compilation error.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$ERROR]($ERROR) MESSAGE
|
||||
|
||||
## Description
|
||||
|
||||
* The Metacommand does **not** require a comment or REM before it.
|
||||
* MESSAGE is any text. Quotation marks are not required.
|
||||
* When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and MESSAGE is shown to the user. This is useful in [$IF]($IF) blocks.
|
||||
|
||||
### Details
|
||||
|
||||
* If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with [$IF]($IF).
|
||||
* An [$ERROR]($ERROR) directive not inside an [$IF]($IF) (or [$ELSEIF]($ELSEIF)) block is useless because the program will never compile.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
$IF VERSION < 2.1 OR WINDOWS = 0 THEN
|
||||
$ERROR Requires Windows QB64 version 2.1 or above
|
||||
$END IF
|
||||
|
||||
```
|
||||
|
||||
*Output*: Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements).
|
||||
|
||||
## See Also
|
||||
|
||||
* [Metacommand](Metacommand)
|
||||
* [$IF]($IF)
|
31
wiki/$EXEICON.md
Normal file
31
wiki/$EXEICON.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
**$EXEICON** pre-compiler metacommand embeds a designated icon file into the compiled EXE file to be viewed in Windows Explorer.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$EXEICON]($EXEICON):'iconfile.ico'
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* 'iconfile.ico' is a valid [ICO file format](https://en.wikipedia.org/wiki/ICO)
|
||||
|
||||
## Description
|
||||
|
||||
* Calling [_ICON](_ICON) without an imageHandle& uses the embeded icon, if available.
|
||||
* Starting with **build 20170906/64**, the window will automatically use the icon embedded by [$EXEICON]($EXEICON), without having to call _ICON.
|
||||
* **[Keywords currently not supported](Keywords-currently-not-supported-by-QB64)**.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Embeds a designated icon file into the compiled EXE which can be viewed in Windows Explorer folders.
|
||||
|
||||
```vb
|
||||
|
||||
$EXEICON:'mush.ico'
|
||||
_ICON
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_ICON](_ICON)
|
||||
* [_TITLE](_TITLE)
|
81
wiki/$IF.md
Normal file
81
wiki/$IF.md
Normal file
|
@ -0,0 +1,81 @@
|
|||
**$IF** is precompiler [Metacommand](Metacommand), which determines which sections of code inside its blocks are included into the final code for compliing.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$IF]($IF) variable = expression THEN
|
||||
> .
|
||||
> [$ELSEIF]($ELSEIF) variable = expression THEN
|
||||
> .
|
||||
> [$ELSE]($ELSE)
|
||||
> .
|
||||
> [$END IF]($END-IF)
|
||||
|
||||
* $IF is the start of a precompiler code block which includes or excludes sections of code from being compiled.
|
||||
* There is no single line $IF statement. $IF must be in a valid $IF THEN...$END IF block to work properly.
|
||||
* Like all other metacommands, you can not use more than one metacommand per line. **Use of : to separate statements in a single line is not allowed.**
|
||||
* Variable names can contain numbers, letters and periods, in any order.
|
||||
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters and periods, in any order.
|
||||
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are:
|
||||
* **WIN** or **WINDOWS** if the user is running QB64 in a Windows environment.
|
||||
* **LINUX** if the user is running QB64 in a Linux environment.
|
||||
* **MAC** or **MACOSX** if the user is running QB64 in a macOS environment.
|
||||
* **32BIT** if the user is running a 32-bit version of QB64.
|
||||
* **64BIT** if the user is running a 64-bit version of QB64.
|
||||
* **VERSION**, which is set to the version of the QB64 compiler. This is a number and can be ordered, see example below.
|
||||
* Special values **DEFINED** and **UNDEFINED** can be used to check whether a precompiler variable has already been assigned a value. Useful for code in libraries which may be repeated.
|
||||
* [$END IF]($END-IF) denotes the end of a valid precompiler $IF block.
|
||||
* [$ELSEIF]($ELSEIF) must follow a valid $IF or $ELSEIF statement.
|
||||
* If [$ELSE]($ELSE) is used, it must be used as the last conditional check before $END IF. $ELSEIF cannot come after $ELSE.
|
||||
* There can only be one $ELSE in an **$IF-$ELSEIF-$ELSE-$END IF** block, and it must be the last block selection before the $END IF. $ELSEIF cannot follow $ELSE.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
$LET ScreenMode = 32
|
||||
$IF ScreenMode = 0 THEN
|
||||
CONST Red = 4
|
||||
$ELSEIF ScreenMode = 32 THEN
|
||||
CONST Red = _RGB32(255,0,0)
|
||||
$END IF
|
||||
|
||||
COLOR Red
|
||||
PRINT "Hello World"
|
||||
|
||||
```
|
||||
|
||||
*Explanation:* The same CONST is defined twice inside the program. Normally, defining a CONST more than once generates an error, but the $IF condition here is choosing which CONST will be inside the final program.
|
||||
|
||||
As long as Screenmode is 0, the program will exclude the code where CONST Red is defined as color 4. If Screenmode is 32, CONST Red will be defined as _RGB32(255, 0, 0).
|
||||
|
||||
The [$LET]($LET) and $IF statements let the programmer control the code that actually gets compiled, while excluding the other blocks completely.
|
||||
|
||||
```vb
|
||||
|
||||
$IF WIN THEN
|
||||
CONST Slash = "\"
|
||||
$ELSE
|
||||
CONST Slash = "/"
|
||||
$END IF
|
||||
|
||||
PRINT "The proper slash for your operating system is "; Slash
|
||||
|
||||
```
|
||||
|
||||
*Explanation:* For the above, the CONST slash is defined by the automatic internal flags which returns what operating system is being used at compile time. On a Windows PC, the Slash will be the backslash; for any other OS it will be the forward slash.
|
||||
|
||||
```vb
|
||||
|
||||
$IF VERSION < 1.5 THEN
|
||||
$ERROR Requires QB64 version 1.5 or greater
|
||||
$END IF
|
||||
|
||||
```
|
||||
|
||||
*Explanation:* VERSION is a predefined variable that holds the QB64 compiler version. If we know our program needs features only available above a certain version, we can check for that and give the user a helpful error message instead of a confusing error elsewhere in the program.
|
||||
|
||||
## See Also
|
||||
|
||||
* [$LET]($LET)
|
||||
* [$ERROR]($ERROR)
|
||||
* [Metacommand](Metacommand)s
|
43
wiki/$INCLUDE.md
Normal file
43
wiki/$INCLUDE.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
[$INCLUDE]($INCLUDE) is a metacommand that is used to insert a source code file into your program which is then executed at the point of the insertion.
|
||||
|
||||
## Syntax
|
||||
|
||||
> {[REM](REM) | ['](apostrophe) } [$INCLUDE]($INCLUDE): 'sourceFile'
|
||||
|
||||
## Description
|
||||
|
||||
* QBasic [Metacommand](Metacommand) must be commented with [REM](REM) or an apostrophe.
|
||||
* The sourceFile name must be enclosed in apostrophes and can include a path.
|
||||
* $INCLUDE is often used to add functions and subs from an external text QBasic code library.
|
||||
* The $INCLUDE metacommand should be the only statement on a line.
|
||||
|
||||
### How to $INCLUDE a BAS or Text file with a QB64 Program
|
||||
|
||||
* Assemble the code to be reused into a file.
|
||||
* Common extensions are **.BI** (for declarations, usually included in the beginning of a program) or **.BM** (with SUBs and FUNCTIONs, usually included at the end of a program).
|
||||
* Any extension can be used, as long as the file contains code in plain text (binary files are not accepted).
|
||||
* $INCLUDE any [DIM](DIM), [CONST](CONST), [SHARED](SHARED) arrays or [DATA](DATA) at the **beginning** of the main program code.
|
||||
* $INCLUDE [SUB](SUB)s or [FUNCTION](FUNCTION)s at the bottom of the main program code **after any SUB procedures.**
|
||||
* **Note:** [TYPE](TYPE) definitions, [DATA](DATA) and [DECLARE LIBRARY](DECLARE-LIBRARY) can be placed inside of sub-procedures.
|
||||
* **Compile** the program.
|
||||
**Note: Once the program is compiled, the included text files are no longer needed with the program EXE.*
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
** '$INCLUDE:** 'QB.BI'
|
||||
|
||||
```
|
||||
|
||||
### More examples
|
||||
|
||||
* [SelectScreen](SelectScreen) (member-contributed $INCLUDE demo)
|
||||
* [FILELIST$](FILELIST$) (member-contributed file search function)
|
||||
* [SAVEIMAGE](SAVEIMAGE) (SUB program that creates bitmaps)
|
||||
|
||||
## See Also
|
||||
|
||||
* [INTERRUPT](INTERRUPT), [INTERRUPTX](INTERRUPTX)
|
||||
* [TYPE](TYPE), [DIM](DIM)
|
||||
* [Metacommand](Metacommand)
|
31
wiki/$LET.md
Normal file
31
wiki/$LET.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
[$LET]($LET) is a precompiler command, which is now usable by modern day [cavemen](cavemen) to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$LET]($LET) variable = expression
|
||||
|
||||
## Description
|
||||
|
||||
* Unlike [LET](LET), [$LET]($LET) is not optional.
|
||||
* $LET A = 12 sets a precompiler variable "a" to the value of 12. This variable is only valid for the precompiler itself and does nothing to affect the values of any variable/constant which might also be called "a" in the program.
|
||||
* Variable names must follow QB64's variable naming conventions.
|
||||
* You can check a precompiler variable against special values **DEFINED** and **UNDEFINED**, in order to assess whether the variable has already been assigned a value. Useful for code in libraries which may be repeated.
|
||||
* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are:
|
||||
* **WIN** or **WINDOWS** if the user is running QB64 in a Windows environment.
|
||||
* **LINUX** if the user is running QB64 in a Linux environment.
|
||||
* **MAC** or **MACOSX** if the user is running QB64 in a macOS environment.
|
||||
* **32BIT** if the user is running a 32-bit version of QB64.
|
||||
* **64BIT** if the user is running a 64-bit version of QB64.
|
||||
* **VERSION**, which is set to the version of the QB64 compiler.
|
||||
|
||||
## Example(s)
|
||||
|
||||
* See example 1 in [$IF]($IF).
|
||||
|
||||
## See Also
|
||||
|
||||
* [$IF]($IF)
|
||||
* [$ELSE]($ELSE)
|
||||
* [$ELSEIF]($ELSEIF)
|
||||
* [$END IF]($END-IF)
|
||||
* [Cavemen](Cavemen)
|
23
wiki/$NOPREFIX.md
Normal file
23
wiki/$NOPREFIX.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
The [$NOPREFIX]($NOPREFIX) metacommand allows all QB64 functions and statements to be used without the leading underscore (_).
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$NOPREFIX]($NOPREFIX)
|
||||
|
||||
## Description
|
||||
|
||||
* QB64-specific keywords are by default prefixed with an underscore, in order to differentiate them from legacy keywords inherited from QBasic/QuickBASIC 4.5.
|
||||
* The convention exists in order to allow older code to be loaded and compiled in QB64 without naming conflicts with existing variables or constants.
|
||||
* If you are writing new code with QB64, and not importing code from QBasic/QuickBASIC 4.5, [$NOPREFIX]($NOPREFIX) allows you to reduce typing by not having to use underscores in modern keywords.
|
||||
* **SUB _GL** still must be prefixed.
|
||||
* When [$NOPREFIX]($NOPREFIX) is used, QB64 keywords can be used both with or without the leading underscore, so that both [_DISPLAY](_DISPLAY) and [DISPLAY](_DISPLAY) are valid in the same program, for example.
|
||||
* [$NOPREFIX]($NOPREFIX) can be placed anywhere in a program.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
|
||||
## See Also
|
||||
|
||||
* [Keywords (Alphabetical)](Keyword-Reference---Alphabetical)
|
||||
* [Metacommand](Metacommand)
|
111
wiki/$RESIZE.md
Normal file
111
wiki/$RESIZE.md
Normal file
|
@ -0,0 +1,111 @@
|
|||
The [$RESIZE]($RESIZE) [Metacommand](Metacommand) determines if a program window can be resized by the user.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$RESIZE]($RESIZE):{ON|OFF|STRETCH|SMOOTH}
|
||||
|
||||
## Description
|
||||
|
||||
* $RESIZE:ON is used to allow the program window to be resized by a program user. Otherwise it cannot be changed.
|
||||
* $RESIZE:OFF (**default**) is used when the program's window size cannot be changed by the user.
|
||||
* $RESIZE:STRETCH the screen will be stretched to fit the new window size with a 1 to 1 ratio of width and height.
|
||||
* $RESIZE:SMOOTH the screen will be stretched also, but with linear filtering applied to the pixels.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Resizing a program screen when the user changes it without clearing the entire screen image:
|
||||
|
||||
```vb
|
||||
|
||||
$RESIZE:ON
|
||||
|
||||
SCREEN _NEWIMAGE(160, 140, 32)
|
||||
_DELAY 0.1
|
||||
_SCREENMOVE 20, 20
|
||||
_DISPLAY
|
||||
|
||||
' CLEAR _RESIZE FLAG BY READING IT ONCE
|
||||
temp& = _RESIZE
|
||||
|
||||
DO
|
||||
|
||||
_LIMIT 60
|
||||
|
||||
IF CheckResize(_SOURCE) = -1 THEN
|
||||
FOR i = 1 TO 10
|
||||
CIRCLE (RND * _WIDTH(0) - 1, RND * _HEIGHT(0) - 1), RND * 100 + 5, _RGB32(RND * 255, RND * 255, RND * 255)
|
||||
NEXT
|
||||
ELSE
|
||||
FOR i = 1 TO 200
|
||||
PSET (RND * _WIDTH(0) - 1, RND * _HEIGHT(0) - 1), _RGB32(RND * 255, RND * 255, RND * 255)
|
||||
NEXT
|
||||
END IF
|
||||
|
||||
_DISPLAY
|
||||
|
||||
k& = _KEYHIT
|
||||
|
||||
LOOP UNTIL k& = 27 OR k& = 32
|
||||
|
||||
SYSTEM
|
||||
|
||||
' *************************************************************************************************
|
||||
' * *
|
||||
' * CheckResize: This FUNCTION checks if the user resized the window, and if so, recreates the *
|
||||
' * ORIGINAL SCREEN image to the new window size. *
|
||||
' * *
|
||||
' * Developer Note: You must use $RESIZE:ON, $RESIZE:SMOOTH, or $RESIZE:SMOOTH at *
|
||||
' * the beginning of your project for this to work. *
|
||||
' * This FUNCTION only works in QB64 version 1.000 and up. *
|
||||
' * *
|
||||
' *************************************************************************************************
|
||||
FUNCTION CheckResize (CurrentScreen AS _UNSIGNED LONG)
|
||||
|
||||
' *** Define local variable for temporary screen
|
||||
DIM TempScreen AS _UNSIGNED LONG
|
||||
|
||||
CheckResize = 0
|
||||
|
||||
' *** Check to see if the user resized the window. If so, change the SCREEN image to the correct size.
|
||||
IF _RESIZE THEN
|
||||
|
||||
' *** First, create a copy of the current SCREEN image.
|
||||
TempScreen = _COPYIMAGE(CurrentScreen, 32)
|
||||
|
||||
' *** Set the SCREEN to the copied image, releasing the current SCREEN image.
|
||||
SCREEN TempScreen
|
||||
|
||||
' *** Remove (FREE) the original SCREEN image.
|
||||
_FREEIMAGE CurrentScreen
|
||||
|
||||
' *** Create a new "original" SCREEN image.
|
||||
CurrentScreen = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)
|
||||
|
||||
' *** Set the SCREEN to the new "original" image, releasing the copied SCREEN image.
|
||||
SCREEN CurrentScreen
|
||||
|
||||
' DRAW PREVIOUS SCREEN ON THE NEW ONE
|
||||
_PUTIMAGE (0, 0), TempScreen, CurrentScreen
|
||||
|
||||
_DISPLAY
|
||||
|
||||
' *** Remove (FREE) the copied SCREEN image.
|
||||
_FREEIMAGE TempScreen
|
||||
|
||||
' *** Tell the caller there was a resize
|
||||
CheckResize = -1
|
||||
|
||||
END IF
|
||||
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_RESIZE](_RESIZE), [_RESIZE (function)](_RESIZE-(function))
|
||||
* [_RESIZEWIDTH](_RESIZEWIDTH), [_RESIZEHEIGHT](_RESIZEHEIGHT) (functions return the requested dimensions)
|
36
wiki/$SCREENHIDE.md
Normal file
36
wiki/$SCREENHIDE.md
Normal file
|
@ -0,0 +1,36 @@
|
|||
The [$SCREENHIDE]($SCREENHIDE) [Metacommand](Metacommand) can be used to hide the main program window throughout a program.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$SCREENHIDE]($SCREENHIDE)
|
||||
|
||||
* $SCREENHIDE may be used at the start of a program to hide the main program window when using a [$CONSOLE]($CONSOLE) window.
|
||||
* The [_SCREENHIDE](_SCREENHIDE) statement must be used before [_SCREENSHOW](_SCREENSHOW) can be used in sections of a program.
|
||||
* **QB64 [Metacommand](Metacommand)s cannot be commented out with [apostrophe](apostrophe) or [REM](REM)**.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Hiding a program when displaying a message box in Windows.
|
||||
|
||||
```vb
|
||||
|
||||
$SCREENHIDE
|
||||
DECLARE DYNAMIC LIBRARY "user32"
|
||||
FUNCTION MessageBoxA& (BYVAL hWnd%&, BYVAL lpText%&, BYVAL lpCaption%&, BYVAL uType~&)
|
||||
END DECLARE
|
||||
DECLARE DYNAMIC LIBRARY "kernel32"
|
||||
SUB ExitProcess (BYVAL uExitCode~&)
|
||||
END DECLARE
|
||||
DIM s0 AS STRING
|
||||
DIM s1 AS STRING
|
||||
s0 = "Text" + CHR$(0)
|
||||
s1 = "Caption" + CHR$(0)
|
||||
ExitProcess MessageBoxA(0, _OFFSET(s0), _OFFSET(s1), 0)
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [$SCREENSHOW]($SCREENSHOW)
|
||||
* [_SCREENHIDE](_SCREENHIDE), [_SCREENSHOW](_SCREENSHOW)
|
||||
* [_CONSOLE](_CONSOLE)
|
18
wiki/$SCREENSHOW.md
Normal file
18
wiki/$SCREENSHOW.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
The [$SCREENSHOW]($SCREENSHOW) [Metacommand](Metacommand) can be used to display the main program window throughout the program.
|
||||
|
||||
## Syntax
|
||||
|
||||
> $SCREENSHOW
|
||||
|
||||
## Description
|
||||
|
||||
* The metacommand is intended to be used in a modular program when a screen surface is necessary in one or more modules.
|
||||
* $SCREENSHOW can only be used after [$SCREENHIDE]($SCREENHIDE) or [_SCREENHIDE](_SCREENHIDE) have been used in another program module.
|
||||
* If [$SCREENHIDE]($SCREENHIDE) and then [$SCREENSHOW]($SCREENSHOW) are used in the same program module the window will not be hidden.
|
||||
* **QB64 [Metacommand](Metacommand)s cannot be commented out with [apostrophe](apostrophe) or [REM](REM).**
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [$SCREENHIDE]($SCREENHIDE) (QB64 [Metacommand](Metacommand)s)
|
||||
* [_SCREENHIDE](_SCREENHIDE), [_SCREENSHOW](_SCREENSHOW)
|
||||
* [_CONSOLE](_CONSOLE)
|
37
wiki/$STATIC.md
Normal file
37
wiki/$STATIC.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
The [$STATIC]($STATIC) [Metacommand](Metacommand) allows the creation of static (unresizable) arrays.
|
||||
|
||||
## Syntax
|
||||
|
||||
> {[REM](REM) | ['](apostrophe) } [$STATIC]($STATIC)
|
||||
|
||||
## Description
|
||||
|
||||
* QBasic [Metacommand](Metacommand)s require a REM or apostrophy (') before them and are normally placed at the start of the main module.
|
||||
* Static arrays cannot be resized. If a variable is used to size any array, it becomes [$DYNAMIC]($DYNAMIC).
|
||||
* A [REDIM](REDIM) statement has no effect on [$STATIC]($STATIC) arrays except perhaps a [ERROR Codes](ERROR-Codes) at the [REDIM](REDIM) statement.
|
||||
* The array's type cannot be changed once [DIM](DIM) and a literal value sets the dimensions and element size.
|
||||
* [$STATIC]($STATIC) defined program [arrays](arrays) cannot be [REDIM](REDIM) or use [_PRESERVE](_PRESERVE).
|
||||
|
||||
## Example(s)
|
||||
|
||||
When a variable is used, the array can be resized despite $STATIC. The array becomes [$DYNAMIC]($DYNAMIC).
|
||||
|
||||
```vb
|
||||
|
||||
'$STATIC
|
||||
|
||||
INPUT "Enter array size: ", size
|
||||
DIM array(size) 'using an actual number instead of the variable will create an error!
|
||||
|
||||
REDIM array(2 * size)
|
||||
|
||||
PRINT UBOUND(array)
|
||||
|
||||
```
|
||||
|
||||
> *Note:* [DIM](DIM) using a literal numerical size will create a Duplicate definition error.
|
||||
|
||||
## See Also
|
||||
|
||||
* [$DYNAMIC]($DYNAMIC), [STATIC](STATIC)
|
||||
* [Arrays](Arrays), [Metacommand](Metacommand)
|
39
wiki/$VERSIONINFO.md
Normal file
39
wiki/$VERSIONINFO.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
The [$VERSIONINFO]($VERSIONINFO) [Metacommand](Metacommand) adds text metadata to the resulting executable for identification purposes across the OS. Windows-only.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$VERSIONINFO]($VERSIONINFO):key=value
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* Text *keys* can be: **Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Web**
|
||||
* Numeric keys can be:**FILEVERSION#** and **PRODUCTVERSION#**
|
||||
|
||||
## Description
|
||||
|
||||
* Text and numerical values are string literals without quotes entered by programmer. **No variables are accepted.** (variable names would be interpreted as literals).
|
||||
* Numeric key=*value* must be 4 comma-separated numerical text values entered by programmer which usually stand for major, minor, revision and build numbers).
|
||||
* A manifest file is automatically embedded into the resulting .exe file so that Common Controls v6.0 gets linked at runtime, if required.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170429/52 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Adding metadata to a Windows exe compiled with QB64:
|
||||
|
||||
```vb
|
||||
|
||||
$VERSIONINFO:CompanyName=Your company name goes here
|
||||
$VERSIONINFO:FILEVERSION#=1,0,0,0
|
||||
$VERSIONINFO:PRODUCTVERSION#=1,0,0,0
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$EXEICON]($EXEICON)
|
||||
* [_ICON](_ICON)
|
||||
* [VERSIONINFO resource (MSDN)](https://msdn.microsoft.com/library/windows/desktop/aa381058(v=vs.85).aspx)
|
24
wiki/$VIRTUALKEYBOARD.md
Normal file
24
wiki/$VIRTUALKEYBOARD.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
[DEPRECATED] The [$VIRTUALKEYBOARD]($VIRTUALKEYBOARD) [Metacommand](Metacommand) turns the virtual keyboard ON or OFF.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [$VIRTUALKEYBOARD]($VIRTUALKEYBOARD):{ON|OFF}
|
||||
|
||||
## Description
|
||||
|
||||
* Places a virtual keyboard on screen, which can be used in touch-enabled devices like Windows tablets.
|
||||
* Deprecated.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
$VIRTUALKEYBOARD:ON
|
||||
|
||||
DO: LOOP UNTIL INKEY$ = CHR$(27)
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [Metacommand](Metacommand)s
|
160
wiki/&B.md
Normal file
160
wiki/&B.md
Normal file
|
@ -0,0 +1,160 @@
|
|||
The **&B&** prefix denotes that an integer value is expressed in a binary base 2 format using **QB64** only.
|
||||
|
||||
## Syntax
|
||||
|
||||
> a& = **&B1110110000111111**
|
||||
|
||||
* The base 2 numbering system uses binary digit values of 1 or 0, or bits on or bits off in computer register switches or memory.
|
||||
* Leading zero values **can** be omitted as they add nothing to the byte return value.
|
||||
* Eight binary digits would represent a one-byte value ranging from 0 to 255. Four-digit values("nibbles") range from 0 to 15.
|
||||
* Decimal values returned can be any **signed** [INTEGER](INTEGER), [LONG](LONG) integer, or [_INTEGER64](_INTEGER64) value so use those type of variables when converting directly as shown in the Syntax. The program ["overflow"](ERROR-Codes) error limits are listed as:
|
||||
* [INTEGER](INTEGER): 16 binary digits or a decimal value range from -32,768 to 32,767
|
||||
* [LONG](LONG): 32 binary digits or a decimal value range from -2,147,483,648 to 2,147,483,647
|
||||
* [_INTEGER64](_INTEGER64): 64 binary digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
|
||||
* [LONG](LONG) values can be returned by appending the & or ~%([_UNSIGNED](_UNSIGNED) [INTEGER](INTEGER)) symbols after the binary number.
|
||||
* [VAL](VAL) can be used to convert "&B" prefixed string values to decimal.
|
||||
|
||||
**[BITS](_BIT)**
|
||||
|
||||
* The **MSB** is the most significant(largest) bit value and **LSB** is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte:
|
||||
|
||||
* **"Big-endian"**: MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time.
|
||||
* **"Little-endian"**: LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time.
|
||||
|
||||
```text
|
||||
'''Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000'''
|
||||
---------------------------------- --------
|
||||
'''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240
|
||||
'''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15
|
||||
```
|
||||
|
||||
> The big-endian method compares exponents of 2 <sup>7</sup> down to 2 <sup>0</sup> while the little-endian method does the opposite.
|
||||
|
||||
**[BYTES](_BYTE)**
|
||||
|
||||
* [INTEGER](INTEGER) values consist of 2 bytes called the **HI** and **LO** bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [SINGLE](SINGLE) or [DOUBLE](DOUBLE) values!
|
||||
|
||||
```text
|
||||
'''16 BIT INTEGER OR REGISTER'''
|
||||
'''AH (High Byte Bits) AL (Low Byte Bits)'''
|
||||
BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0
|
||||
---------------------------------------|--------------------------------------
|
||||
HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1
|
||||
|
|
||||
DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1
|
||||
```
|
||||
|
||||
> The HI byte's **MSB** is often called the **sign** bit! When all 16 of the integer binary bits are on, the decimal return is -1.
|
||||
|
||||
```text
|
||||
'''Comparing the Base Numbering Systems'''
|
||||
|
||||
'''Decimal (base 10) Binary (base 2) Hexadecimal (base 16) Octal (base 8)'''
|
||||
|
||||
0 0000 0 0
|
||||
1 0001 1 1
|
||||
2 0010 2 2
|
||||
3 0011 3 3
|
||||
4 0100 4 4
|
||||
5 0101 5 5
|
||||
6 0110 6 6
|
||||
7 0111 7 7 -- maxed
|
||||
8 1000 8 10
|
||||
maxed-- 9 1001 9 11
|
||||
10 1010 A 12
|
||||
11 1011 B 13
|
||||
12 1100 C 14
|
||||
13 1101 D 15
|
||||
14 1110 E 16
|
||||
15 ------------- 1111 <--- Match ---> F ---------------- 17 -- max 2
|
||||
16 10000 10 20
|
||||
|
||||
When the Decimal value is 15, the other 2 base systems are all maxed out!
|
||||
The Binary values can be compared to all of the HEX value digit values so
|
||||
it is possible to convert between the two quite easily. To convert a HEX
|
||||
value to Binary just add the 4 binary digits for each HEX digit place so:
|
||||
|
||||
F A C E
|
||||
&HFACE = 1111 + 1010 + 1100 + 1101 = &B1111101011001101
|
||||
|
||||
To convert a Binary value to HEX you just need to divide the number into
|
||||
sections of four digits starting from the right (LSB) end. If one has less
|
||||
than 4 digits on the left end you could add the leading zeros like below:
|
||||
|
||||
&B101011100010001001 = 0010 1011 1000 1000 1001
|
||||
hexadecimal = 2 + B + 8 + 8 + 9 = &H2B889
|
||||
|
||||
See the Decimal to Binary conversion function that uses **[HEX$](HEX$)** on the **[&H](&H)** page.
|
||||
|
||||
```
|
||||
|
||||
## Example(s)
|
||||
|
||||
A Decimal to Binary [STRING](STRING) function that does not return leading zeroes.
|
||||
|
||||
```vb
|
||||
|
||||
PRINT BIN$(255) '1 byte(8 bits) maximum
|
||||
PRINT BIN$(32767) 'integer(2 byte, 15 bits) maximum
|
||||
PRINT BIN$(-32768) 'integer(2 byte, 16 bits) minimum
|
||||
PRINT BIN$(-1) 'all 16 bits on
|
||||
|
||||
FUNCTION BIN$(n%)
|
||||
max% = 8 * LEN(n%) ': MSB% = 1 'uncomment for 16 (32 or 64) bit returns
|
||||
FOR i = max% - 1 TO 0 STEP -1 'read as big-endian MSB to LSB
|
||||
IF (n% AND 2 ^ i) THEN MSB% = 1: B$ = B$ + "1" ELSE IF MSB% THEN B$ = B$ + "0"
|
||||
NEXT
|
||||
IF B$ = "" THEN BIN$ = "0" ELSE BIN$ = B$ 'check for empty string
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
<sub>Code by Ted Weissgerber</sub>
|
||||
|
||||
```text
|
||||
|
||||
11111111
|
||||
111111111111111
|
||||
1000000000000000
|
||||
1111111111111111
|
||||
|
||||
```
|
||||
|
||||
*Note:* The MSB% flag allows zeroes to be added. Uncomment the MSB% = 1 statement for returns with leading zeroes.
|
||||
|
||||
QB64 converts the binary values from the example above to [INTEGER](INTEGER) decimal values automatically.
|
||||
|
||||
```VB
|
||||
|
||||
DEFLNG A-Z
|
||||
a = &B11111111
|
||||
b = &B111111111111111
|
||||
c = &B1000000000000000 '& 'or ~%
|
||||
d = &B1111111111111111 '& 'or ~%
|
||||
|
||||
PRINT a, b, c, d '' ''
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
255 32767 -32768 -1
|
||||
|
||||
```
|
||||
|
||||
> *Bonus example:* Add an **&** symbol after the negative binary numbers to see the [LONG](LONG) decimal values below.
|
||||
|
||||
```text
|
||||
|
||||
255 32767 32768 65535
|
||||
|
||||
```
|
||||
|
||||
> *Note:* The [LONG](LONG) values returned are the same as the values you can get using [_UNSIGNED](_UNSIGNED) [INTEGER](INTEGER) (~%).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_BIT](_BIT), [_BYTE](_BYTE)
|
||||
* [_SHL](_SHL), [_SHR](_SHR)
|
||||
* [OCT$](OCT$), [&O](&O) (octal)
|
||||
* [HEX$](HEX$), [&H](&H) (hexadecimal)
|
94
wiki/&H.md
Normal file
94
wiki/&H.md
Normal file
|
@ -0,0 +1,94 @@
|
|||
The **&H** prefix denotes that an integer value is expressed in a Hexadecimal base 16 format. Every 2 digits represent a [_BYTE](_BYTE).
|
||||
|
||||
## Syntax
|
||||
|
||||
> a& = &HFACE
|
||||
|
||||
* The base 16 numbering system uses hexadecimal digit values of 0 to F. A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
|
||||
* Leading zero values can be omitted just like in decimal values as they add nothing to the return value.
|
||||
* Decimal values returned can be any **signed** [INTEGER](INTEGER), [LONG](LONG) integer, or [_INTEGER64](_INTEGER64) value so use those type of variables when converting directly as shown above in the Syntax. The program ["overflow"](ERROR-Codes) error limits are listed as:
|
||||
* [_BYTE](_BYTE): 2 hex digits or a decimal value range from -128 to 127. [_UNSIGNED](_UNSIGNED): 0 to 255.
|
||||
* [INTEGER](INTEGER): 4 hex digits or a decimal value range from -32,768 to 32,767. [_UNSIGNED](_UNSIGNED): 0 to 65535.
|
||||
* [LONG](LONG): 8 hex digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [_UNSIGNED](_UNSIGNED): 0 to 4294967295.
|
||||
* [_INTEGER64](_INTEGER64): 16 hex digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
|
||||
* [_UNSIGNED](_UNSIGNED) [_INTEGER64](_INTEGER64): 0 to 18446744073709551615.
|
||||
* The maximum hexadecimal value for each numerical type is the maximum number of digits listed above, each valued at F.
|
||||
* Convert hexadecimal to [[LONG]] values by appending the values with &. Example: &H8000 = -32768: &H8000& = 32768
|
||||
* [LONG](LONG) 32-bit [_RGB](_RGB) values can be made using hexadecimal values from **&HFF000000** to **&HFFFFFFFF** with full [_ALPHA](_ALPHA) only.
|
||||
* [LONG] 32-bit [_RGBA](_RGBA) values can be made using hexadecimal values from **&H00000000** to **&HFFFFFFFF** with any [_ALPHA](_ALPHA).
|
||||
* Hexadecimal **0x** is often used to prefix [HEX$](HEX$) port addresses in documentation. Replace 0x with [&H](&H) in QB64 or QBasic.
|
||||
* To convert hex strings returned from [HEX$](HEX$) with [VAL](VAL) you need to prefix the string with &H (for example; if the string is "FF" you should do VAL("&HFF") or VAL("&H" + hexvalue$).
|
||||
|
||||
## Example(s)
|
||||
|
||||
The maximum octal values of decimal value -1 in each numerical type are:
|
||||
|
||||
```vb
|
||||
c&& = -1: d& = -1: e% = -1: f%% = -1
|
||||
hx$ = HEX(f%%)
|
||||
PRINT "Max hex _BYTE = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(e%)
|
||||
PRINT "Max hex INTEGER = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(d&)
|
||||
PRINT "Max hex LONG = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(c&&)
|
||||
PRINT "Max hex _INTEGER64 = "; hx$; " with"; LEN(hx$); "digits ="; VAL("&H" + hx$)
|
||||
hx$ = HEX$(9223372036854775807)
|
||||
PRINT "Max _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits"
|
||||
hx$ = HEX$(-9223372036854775808)
|
||||
PRINT "Min _INTEGER64 value = "; hx$; " with"; LEN(hx$); "digits"
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Max hex _BYTE = FF with 2 digits = 255
|
||||
Max hex INTEGER = FFFF with 4 digits = 65535
|
||||
Max hex LONG = FFFFFFFF with 8 digits = 4294967295
|
||||
Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
|
||||
Max _INTEGER64 value = 7FFFFFFFFFFFFFFF with 16 digits
|
||||
Min _INTEGER64 value = 8000000000000000 with 16 digits
|
||||
|
||||
```
|
||||
|
||||
Converting a decimal number to a binary string value using [HEX$](HEX$).
|
||||
|
||||
```vb
|
||||
|
||||
FUNCTION BIN$ (n&)
|
||||
h$ = HEX$(n&) 'get hexadecimal string value
|
||||
FOR i = 1 TO LEN(h$) 'scan the HEX$ digits
|
||||
SELECT CASE MID$(h$, i, 1) 'read each HEX$ digit
|
||||
CASE "0": b$ = b$ + "0000"
|
||||
CASE "1": b$ = b$ + "0001"
|
||||
CASE "2": b$ = b$ + "0010"
|
||||
CASE "3": b$ = b$ + "0011"
|
||||
CASE "4": b$ = b$ + "0100"
|
||||
CASE "5": b$ = b$ + "0101"
|
||||
CASE "6": b$ = b$ + "0110"
|
||||
CASE "7": b$ = b$ + "0111"
|
||||
CASE "8": b$ = b$ + "1000"
|
||||
CASE "9": b$ = b$ + "1001"
|
||||
CASE "A": b$ = b$ + "1010"
|
||||
CASE "B": b$ = b$ + "1011"
|
||||
CASE "C": b$ = b$ + "1100"
|
||||
CASE "D": b$ = b$ + "1101"
|
||||
CASE "E": b$ = b$ + "1110"
|
||||
CASE "F": b$ = b$ + "1111"
|
||||
END SELECT
|
||||
NEXT i
|
||||
b$ = RIGHT$(b$, LEN(b$) - INSTR(b$, "1") + 1) 'eliminate leading zeroes
|
||||
IF VAL(b$) THEN BIN$ = b$ ELSE BIN$ = "0" 'return zero if n& = 0
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
<sub>Code by CodeGuy</sub>
|
||||
|
||||
> *Explanation:* Hexadecimal digits can be any value up to 15 which also corresponds to all four bits on in binary. The function above just adds every four-bit binary string value together to return the binary value. After they are concatenated, the leading bit on is found by [INSTR](INSTR) and everything from that point is kept removing the leading zeros.
|
||||
|
||||
## See Also
|
||||
|
||||
* [HEX$](HEX$), [OCT$](OCT$)
|
||||
* [&B](&B) (binary), [&O](&O) (octal)
|
||||
* [Base Comparisons](Base-Comparisons)
|
46
wiki/&O.md
Normal file
46
wiki/&O.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
The **&O** prefix denotes that an integer value is expressed in an Octal base 8 format.
|
||||
|
||||
## Syntax
|
||||
|
||||
> a& = &O12345671234
|
||||
|
||||
* The base eight numbering system only uses octal digit values of 0 to 7.
|
||||
* Leading zero values **can** be omitted as they add nothing to the return value.
|
||||
* Decimal values returned can be any **signed** [INTEGER](INTEGER), [LONG](LONG) integer, or [_INTEGER64](_INTEGER64) value so use those type of variables when converting directly as shown above. The program ["overflow"](ERROR-Codes) error limits are listed as:
|
||||
* [INTEGER](INTEGER): 6 octal digits or a decimal value range from -32,768 to 32,767
|
||||
* [LONG](LONG): 11 octal digits or a decimal value range from -2,147,483,648 to 2,147,483,647
|
||||
* [_INTEGER64](_INTEGER64): 22 octal digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
|
||||
* [LONG](LONG) Octal values can be expressed by appending & after the number. Example: &O100000& = 32768
|
||||
|
||||
## Example(s)
|
||||
|
||||
*Example:* The maximum octal values of decimal value -1 in each numerical type are:
|
||||
|
||||
```vb
|
||||
|
||||
c&& = -1: d& = -1: e% = -1: f%% = -1
|
||||
oc$ = OCT$(f%%)
|
||||
PRINT "Max octal _BYTE = "; oc$; " with"; LEN(oc$); "digits ="; VAL("&O" + oc$)
|
||||
oc$ = OCT$(e%)
|
||||
PRINT "Max octal INTEGER = "; oc$; " with"; LEN(oc$); "digits ="; VAL("&O" + oc$)
|
||||
oc$ = OCT$(d&)
|
||||
PRINT "Max octal LONG = "; oc$; " with"; LEN(oc$); "digits ="; VAL("&O}}" + oc$)
|
||||
oc$ = OCT$(c&&)
|
||||
PRINT "Max octal _INTEGER64 = "; oc$; " with"; LEN(oc$); "digits ="; VAL("&O" + oc$)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Max octal _BYTE = 377 with 3 digits = 255
|
||||
Max octal INTEGER = 177777 with 6 digits = 65535
|
||||
Max octal LONG = 37777777777 with 11 digits = 4294967295
|
||||
Max octal _INTEGER64 = 1777777777777777777777 with 22 digits =-1
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [OCT$](OCT$), [HEX$](HEX$), [VAL](VAL)
|
||||
* [&B](&B) (binary), [&H](&H) (hexadecimal)
|
||||
* [Base Comparisons](Base-Comparisons)
|
18
wiki/-.md
Normal file
18
wiki/-.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
The [-](-) mathematical operator performs subtraction on two numerical values or [negation](negation) a single value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> return_value = number1 [-](-) number2
|
||||
|
||||
## Description
|
||||
|
||||
* Numbers used can be any literal or variable numerical value type.
|
||||
* Subtracting a negative value will actually perform addition with the other value.
|
||||
* Subtracting a negative or [negation](negation) value will make the return value more positive.
|
||||
* Addition and subtraction are the last operations performed in QBasic's normal order of operations.
|
||||
* Subtraction cannot be performed on [STRING](STRING) values.
|
||||
|
||||
## See Also
|
||||
|
||||
* [+](+) (addition operator)
|
||||
* [Mathematical Operations](Mathematical-Operations)
|
2
wiki/.gitignore
vendored
Normal file
2
wiki/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Obsidian working folder
|
||||
.obsidian/
|
43
wiki/^.md
Normal file
43
wiki/^.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
The [^](^) operation raises a numerical value to an exponential value expressing how many times the value is multiplied by itself.
|
||||
|
||||
## Syntax
|
||||
|
||||
> return_value = number [^](^) {whole_exponent|(fractional_exponent)}
|
||||
|
||||
## Description
|
||||
|
||||
* The number value can be any type literal or variable numerical value.
|
||||
* Exponents can be any positive or negative integer or fractional numerical value inside of parenthesis brackets.
|
||||
* If the exponent is zero, the value returned is 1.
|
||||
* Fractional(or decimal point) exponents MUST be enclosed in **() brackets** and will return the fractional exponential root of a value.
|
||||
* Exponential operations are done first in the QBasic order of operations.
|
||||
* The square root of a number can be returned by the [SQR](SQR) function or by using an exponent of (1 [/](/) 2). Brackets required.
|
||||
* Values returned may be expressed using exponential or [Scientific notation](Scientific-notation) using **E** for SINGLE or **D** for DOUBLE precision.
|
||||
* WARNING: Exponential returns may exceed numerical type limitations and create an [ERROR Codes](ERROR-Codes)!
|
||||
|
||||
## Example(s)
|
||||
|
||||
Getting the cube root of a number.
|
||||
|
||||
```vb
|
||||
|
||||
INPUT "Enter a number to calculate it's cube root: ", num$
|
||||
number! = VAL(num$) 'gets single number value
|
||||
cuberoot# = number! ^ (1 / 3)
|
||||
PRINT cuberoot# 'double type variable for accuracy
|
||||
|
||||
```
|
||||
|
||||
*Details:* The value returned will most likely be a [SINGLE](SINGLE) or [DOUBLE](DOUBLE) value. Make sure that the return variable type matches the likely program operations!
|
||||
|
||||
```text
|
||||
|
||||
Enter a number to calculate it's cube root: 144
|
||||
5.241482788417793
|
||||
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [SQR](SQR), [Mathematical Operations](Mathematical-Operations)
|
58
wiki/_ACCEPTFILEDROP.md
Normal file
58
wiki/_ACCEPTFILEDROP.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
The [_ACCEPTFILEDROP](_ACCEPTFILEDROP) statement prepares a program window to receive files dropped from Windows Explorer in a drag/drop operation.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_ACCEPTFILEDROP](_ACCEPTFILEDROP) [{ON|OFF}]
|
||||
|
||||
## Description
|
||||
|
||||
* Calling the statement with no parameters turns drag/dropping ON.
|
||||
* To know when files have been dropped into your program's window, check that [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES) is greater than 0.
|
||||
* Use [_DROPPEDFILE](_DROPPEDFILE) to read the list, either sequentially or by index.
|
||||
* If using [_DROPPEDFILE](_DROPPEDFILE) with an index, you must call [_FINISHDROP](_FINISHDROP) after you finish working with the list.
|
||||
* **[Keywords currently not supported](Keywords-currently-not-supported-by-QB64)**.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.3 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Accepting files dragged from a folder and processing the list received sequentially.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(128, 25, 0)
|
||||
|
||||
_ACCEPTFILEDROP 'enables drag/drop functionality
|
||||
PRINT "Drag files from a folder and drop them in this window..."
|
||||
|
||||
DO
|
||||
IF _TOTALDROPPEDFILES THEN
|
||||
FOR i = 1 TO _TOTALDROPPEDFILES
|
||||
a$ = _DROPPEDFILE 'reads the list sequentially; when the result is empty ("") it means the list is over
|
||||
COLOR 15
|
||||
PRINT i,
|
||||
IF _FILEEXISTS(a$) THEN
|
||||
COLOR 2: PRINT "file",
|
||||
ELSE
|
||||
IF _DIREXISTS(a$) THEN
|
||||
COLOR 3: PRINT "folder",
|
||||
ELSE
|
||||
COLOR 4: PRINT "not found", 'highly unlikely, but who knows?
|
||||
END IF
|
||||
END IF
|
||||
COLOR 15
|
||||
PRINT a$
|
||||
NEXT
|
||||
END IF
|
||||
|
||||
_LIMIT 30
|
||||
LOOP
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES), [_DROPPEDFILE](_DROPPEDFILE), [_FINISHDROP](_FINISHDROP)
|
||||
* [_FILEEXISTS](_FILEEXISTS), [_DIREXISTS](_DIREXISTS)
|
55
wiki/_ACOS.md
Normal file
55
wiki/_ACOS.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
The [_ACOS](_ACOS) function returns the angle measured in radians based on an input [COS](COS)ine value ranging from -1 to 1.
|
||||
|
||||
## Syntax
|
||||
|
||||
> radian_angle! = [_ACOS](_ACOS)(cosine_value!)
|
||||
|
||||
## Description
|
||||
|
||||
* The *cosine_value!* must be measured >= -1 and <= 1, or an error will be generated. (PRINT _ACOS(1.2) would give the result of -1.#IND, which is basically QB64's way of telling us that the number doesn't exist, much like 1/0 would.)
|
||||
* ARCCOSINE is the inverse function of [COS](COS)ine, which lets us turn a [COS](COS)ine value back into an angle.
|
||||
* Note: Due to rounding with floating point math, the _ACOS may not always give a perfect match for the COS angle which generated this. You can reduce the number of rounding errors by increasing the precision of your calculations by using [DOUBLE](DOUBLE) or [_FLOAT](_FLOAT) precision variables instead of [SINGLE](SINGLE).
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Converting a radian angle to its COSine and using that value to find the angle in degrees again using _ACOS:
|
||||
|
||||
```vb
|
||||
|
||||
DEFDBL A-Z
|
||||
|
||||
INPUT "Give me an Angle (in Degrees) => "; Angle
|
||||
PRINT
|
||||
C = COS(_D2R(Angle)) '_D2R is the command to convert Degrees to Radians, which is what COS expects
|
||||
PRINT "The COSINE of the Angle is: "; C
|
||||
A = _ACOS(C)
|
||||
PRINT "The ACOS of "; C; " is: "; A
|
||||
PRINT "Notice, A is the Angle in Radians. If we convert it to degrees, the value is "; _R2D(A)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Give me an Angle (in Degrees) => ? 60
|
||||
|
||||
The COSINE of the Angle is: .5000000000000001
|
||||
The ACOS of .5000000000000001 is: 1.047197551196598
|
||||
Notice, A is the Angle in Radians. If we convert it to degrees, we discover the value is 60
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G) (degree to gradient, [_D2R](_D2R) (degree to radian)
|
||||
* [_G2D](_G2D) (gradient to degree), [_G2R](_G2R) (gradient to degree
|
||||
* [_R2D](_R2D) (radian to degree), [_R2G](_R2G) (radian to gradient
|
||||
* [COS](COS) (cosine), [SIN](SIN) (sine), [TAN](TAN) (tangent)
|
||||
* [_ASIN](_ASIN) (arc sine), [ATN](ATN) (arc tangent)
|
||||
* [_ACOSH](_ACOSH) (arc hyperbolic cosine), [_ASINH](_ASINH) (arc hyperbolic sine), [_ATANH](_ATANH) (arc hyperbolic tangent)
|
||||
* [_ATAN2](_ATAN2) (Compute arc tangent with two parameters)
|
||||
* [_HYPOT](_HYPOT) (hypotenuse)
|
||||
* [Mathematical Operations](Mathematical-Operations)
|
17
wiki/_ACOSH.md
Normal file
17
wiki/_ACOSH.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
The [_ACOSH](_ACOSH) returns the nonnegative arc hyperbolic cosine of x!, expressed in radians.
|
||||
|
||||
## Syntax
|
||||
|
||||
> return_value! = [_ACOSH](_ACOSH)(x!)
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G) (degree to gradient, [_D2R](_D2R) (degree to radian)
|
||||
* [_G2D](_G2D) (gradient to degree), [_G2R](_G2R) (gradient to degree)
|
||||
* [_R2D](_R2D) (radian to degree), [_R2G](_R2G) (radian to gradient)
|
||||
* [COS](COS) (cosine), [SIN](SIN) (sine), [TAN](TAN) (tangent)
|
||||
* [_ACOS](_ACOS) (arc cosine), [_ASIN](_ASIN) (arc sine), [ATN](ATN) (arc tangent)
|
||||
* [_ASINH](_ASINH) (arc hyperbolic sine), [_ATANH](_ATANH) (arc hyperbolic tangent)
|
||||
* [_ATAN2](_ATAN2) (Compute arc tangent with two parameters)
|
||||
* [_HYPOT](_HYPOT) (hypotenuse)
|
||||
*[Mathematical Operations](Mathematical-Operations)
|
78
wiki/_ALLOWFULLSCREEN.md
Normal file
78
wiki/_ALLOWFULLSCREEN.md
Normal file
|
@ -0,0 +1,78 @@
|
|||
The [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) statement allows setting the behavior of the ALT+ENTER combo.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) [{_STRETCH|_SQUAREPIXELS|OFF|_ALL}][, {_SMOOTH|OFF|_ALL}]
|
||||
|
||||
## Description
|
||||
|
||||
* Calling the statement with no parameters enables all four possible full screen modes (and is the default state when a program is started): both [_STRETCH](_STRETCH) ([_SMOOTH](_SMOOTH) and _OFF) and [_SQUAREPIXELS](_SQUAREPIXELS) ([_SMOOTH](_SMOOTH) and _OFF).
|
||||
* Using [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) _ALL, _ALL has the same effect.
|
||||
* [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) only affects the behavior of ALT+ENTER. The [_FULLSCREEN](_FULLSCREEN) statement is not bound by [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN)'s settings so all modes can be accessed programmatically.
|
||||
* To limit just the mode but allow both _SMOOTH + _OFF antialiasing modes, pass just the first parameter: *Example:* [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) _SQUAREPIXELS
|
||||
* To allow multiple modes with _SMOOTH or _OFF as default, pass just the second parameter. *Example:* [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) , _SMOOTH
|
||||
* Any possible permutation of the parameters is allowed.
|
||||
* With [_ALLOWFULLSCREEN](_ALLOWFULLSCREEN) _OFF you can trap Alt+Enter manually in your program and reassign it. See example 2 below.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.3 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Allowing only one full-screen mode with square pixels and no anti-aliasing:
|
||||
|
||||
```vb
|
||||
|
||||
_ALLOWFULLSCREEN _SQUAREPIXELS, OFF
|
||||
|
||||
```
|
||||
|
||||
Disabling _FULLSCREEN with Alt+ENTER so the combo can be manually trapped:
|
||||
|
||||
```vb
|
||||
|
||||
DO
|
||||
CLS
|
||||
|
||||
LOCATE 7
|
||||
PRINT " - Press ALT+ENTER to test trapping the combo..."
|
||||
PRINT " _ Press SPACEBAR to allow fullscreen again..."
|
||||
|
||||
k& = _KEYHIT
|
||||
|
||||
IF k& = 13 THEN
|
||||
IF _KEYDOWN(100307) OR _KEYDOWN(100308) THEN
|
||||
altEnter = altEnter + 1
|
||||
END IF
|
||||
ELSEIF k& = 32 THEN
|
||||
fullscreenEnabled = NOT fullscreenEnabled
|
||||
END IF
|
||||
|
||||
LOCATE 14
|
||||
IF fullscreenEnabled THEN
|
||||
_ALLOWFULLSCREEN _ALL, _ALL
|
||||
altEnter = 0
|
||||
PRINT "_ALLOWFULLSCREEN _ALL, _ALL"
|
||||
|
||||
LOCATE 18
|
||||
PRINT "ALT+ENTER will trigger all four fullscreen modes now."
|
||||
ELSE
|
||||
_ALLOWFULLSCREEN OFF
|
||||
PRINT "_ALLOWFULLSCREEN OFF"
|
||||
END IF
|
||||
|
||||
IF altEnter THEN
|
||||
LOCATE 18
|
||||
PRINT "ALT+ENTER manually trapped"; altEnter; "times."
|
||||
END IF
|
||||
|
||||
_DISPLAY
|
||||
_LIMIT 30
|
||||
LOOP
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_FULLSCREEN](_FULLSCREEN), [_SMOOTH (function)](_SMOOTH-(function))
|
74
wiki/_ALPHA.md
Normal file
74
wiki/_ALPHA.md
Normal file
|
@ -0,0 +1,74 @@
|
|||
The [_ALPHA](_ALPHA) function returns the alpha channel transparency level of a color value used on a screen page or image.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result& = [_ALPHA](_ALPHA)(color~& [, imageHandle&])
|
||||
|
||||
## Description
|
||||
|
||||
* If imageHandle& is omitted, it is assumed to be the current write page. Invalid handles will create [ERROR Codes](ERROR-Codes) errors.
|
||||
* [_NEWIMAGE](_NEWIMAGE) 32 bit [SCREEN](SCREEN) modes will always use an [_UNSIGNED](_UNSIGNED) [LONG](LONG) *color~&* value.
|
||||
* Color values that are set as a [_CLEARCOLOR](_CLEARCOLOR) always have an alpha level of 0 (transparent).
|
||||
* [_SETALPHA](_SETALPHA) can set any alpha level from 0 (or fully transparent) to 255 (or opaque).
|
||||
* Normal color values that are set by [_RGB](_RGB) or [_RGB32](_RGB32) always have an alpha level of 255(opaque).
|
||||
* In 4 (16 color) or 8 (256 color) bit palette screens the function will always return 255.
|
||||
*[_RED32](_RED32), [_GREEN32](_GREEN32), [_BLUE32](_BLUE32) and [_ALPHA32](_ALPHA32) are all equivalent to [_RED](_RED), [_GREEN](_GREEN), [_BLUE](_BLUE) and [_ALPHA](_ALPHA) but they are highly optimized and only accept a 32-bit color (B8:G8:R8:A8). Using them (opposed to dividing then ANDing 32-bit color values manually) makes code easy to read.
|
||||
* **NOTE: 32 bit [_NEWIMAGE](_NEWIMAGE) screen page backgrounds are transparent black or [_ALPHA](_ALPHA) 0. Use [_DONTBLEND](_DONTBLEND) or [CLS](CLS) for opaque.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Alpha transparency levels are always 255 in 4 or 8 bit screen modes.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 13
|
||||
|
||||
clr~& = _RGBA(255, 0, 255, 192) 'returns closest palette color attribute
|
||||
PRINT "Color:"; clr~&
|
||||
|
||||
COLOR clr~&
|
||||
PRINT "Alpha:"; _ALPHA(clr~&)
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Color 36
|
||||
Alpha: 255
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* [_RGBA](_RGBA) cannot change the [_ALPHA](_ALPHA) level. [_ALPHA32](_ALPHA32) would return 0 on any non-32 bit image or page.
|
||||
|
||||
Finding the transparency of a 32 bit screen mode's background before and after [CLS](CLS).
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
BG& = POINT(1, 1)
|
||||
PRINT "Alpha ="; _ALPHA(BG&); "Press a key to use CLS!"
|
||||
K$ = INPUT$(1)
|
||||
CLS
|
||||
BG& = POINT(1, 1)
|
||||
PRINT "CLS Alpha ="; _ALPHA(BG&)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
CLS Alpha = 255
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* Set the ALPHA value to 255 using [CLS](CLS) to make the background opaque when overlaying pages.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_ALPHA32](_ALPHA32), [_SETALPHA](_SETALPHA)
|
||||
* [_RGBA](_RGBA), [_RGBA32](_RGBA32) (set color with alpha)
|
||||
* [_CLEARCOLOR](_CLEARCOLOR), [_CLEARCOLOR (function)](_CLEARCOLOR-(function))
|
||||
* [_RED](_RED), [_GREEN](_GREEN), [_BLUE](_BLUE)
|
||||
* [_RED32](_RED32), [_GREEN32](_GREEN32). [_BLUE32](_BLUE32)
|
||||
* [CLS](CLS), [COLOR](COLOR), [Images](Images)
|
54
wiki/_ALPHA32.md
Normal file
54
wiki/_ALPHA32.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
The [_ALPHA32](_ALPHA32) function returns the alpha transparency level of a 32 bit color value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> alpha& = [_ALPHA32](_ALPHA32)(color32~&)**
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* color32& is the [_UNSIGNED](_UNSIGNED) [LONG](LONG) 32 bit color value used to retrieve the alpha level.
|
||||
* Color values that are set as a [_CLEARCOLOR](_CLEARCOLOR) always have an alpha level of 0 (transparent).
|
||||
* [_SETALPHA](_SETALPHA) can set any alpha level from 0 (or fully transparent) to 255 (or opaque).
|
||||
* Normal color values that are set by [_RGB](_RGB) or [_RGB32](_RGB32) always have an alpha level of 255 (opaque).
|
||||
|
||||
## Description
|
||||
|
||||
* In 4-bit (16 colors) or 8-bit (256 colors) palette screens the function will return 0.
|
||||
* [_RED32](_RED32), [_GREEN32](_GREEN32), [_BLUE32](_BLUE32) and [_ALPHA32](_ALPHA32) are all equivalent to [_RED](_RED), [_GREEN](_GREEN), [_BLUE](_BLUE) and [_ALPHA](_ALPHA) but they are highly optimized and only accept a 32-bit color (RGBA) value. Using these in your code (opposed to dividing then ANDing 32-bit color values) makes code easy to read.
|
||||
* **NOTE: 32 bit [_NEWIMAGE](_NEWIMAGE) screen page backgrounds are transparent black or [_ALPHA](_ALPHA) 0. Use [_DONTBLEND](_DONTBLEND) or [CLS](CLS) for opaque!**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Finding the alpha transparency level in a 32 bit screen using an [_RGBA](_RGBA) [_UNSIGNED](_UNSIGNED) [LONG](LONG) color value.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
|
||||
clr~& = _RGBA(255, 0, 255, 192)
|
||||
PRINT "Color:"; clr~&
|
||||
|
||||
COLOR clr~&
|
||||
PRINT "Alpha32:"; _ALPHA32(clr~&)
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Color: 3237937407
|
||||
Alpha32: 192
|
||||
|
||||
```
|
||||
|
||||
> *Notes:* The color value is equivalent to [&H](&H) &HC0FF00FF where &HC0 equals 192. [_RGB](_RGB) alphas are always &HFF(255).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_ALPHA](_ALPHA), [_SETALPHA](_SETALPHA)
|
||||
* [_RGBA](_RGBA), [_RGBA32](_RGBA32) (set color with alpha)
|
||||
* [_RED](_RED), [_GREEN](_GREEN), [_BLUE](_BLUE)
|
||||
* [_RED32](_RED32), [_GREEN32](_GREEN32). [_BLUE32](_BLUE32)
|
||||
* [_CLEARCOLOR](_CLEARCOLOR), [_CLEARCOLOR (function)](_CLEARCOLOR-(function))
|
||||
* [Images](Images)
|
55
wiki/_ASIN.md
Normal file
55
wiki/_ASIN.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
The [_ASIN](_ASIN) function returns the angle measured in radians based on an input [SIN](SIN)e value ranging from -1 to 1.
|
||||
|
||||
## Syntax
|
||||
|
||||
> radian_angle! = [_ASIN](_ASIN)(sine_value!)
|
||||
|
||||
## Description
|
||||
|
||||
* The sine_value! must be measured >= -1 and <= 1, or else it will generate a return value of **-1.#IND**, which is basically QB64's way of telling us that the number doesn't exist.
|
||||
* ARCSINE is the inverse function of [SIN](SIN)e, and turns a [SIN](SIN)e value back into an angle.
|
||||
* Note: Due to rounding with floating point math, the [_ASIN](_ASIN) may not always give a perfect match for the [SIN](SIN) angle which generated this. You can reduce the number of rounding errors by increasing the precision of your calculations by using [DOUBLE](DOUBLE) or [_FLOAT](_FLOAT) precision variables instead of [SINGLE](SINGLE).
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Converting a radian angle to its SINe and using that value to find the angle in degrees again using _ASIN:
|
||||
|
||||
```vb
|
||||
|
||||
DEFDBL A-Z
|
||||
|
||||
INPUT "Give me an Angle (in Degrees) => "; Angle
|
||||
PRINT
|
||||
C = SIN(_D2R(Angle)) '_D2R is the command to convert Degrees to Radians, which is what SIN expects
|
||||
PRINT "The SINE of the Angle is: "; C
|
||||
A = _ASIN(C)
|
||||
PRINT "The ASIN of "; C; " is: "; A
|
||||
PRINT "Notice, A is the Angle in Radians. If we convert it to degrees, the value is "; _R2D(A)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Give me an Angle (in Degrees) => ? 60
|
||||
|
||||
The SINE of the Angle is: .8660254037844386
|
||||
The ACOS of .8660254037844386 is: 1.047197551196598
|
||||
Notice, A is the Angle in Radians. If we convert it to degrees, we discover the value is 60
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G) (degree to gradient, [_D2R](_D2R) (degree to radian)
|
||||
* [_G2D](_G2D) (gradient to degree), [_G2R](_G2R) (gradient to degree
|
||||
* [_R2D](_R2D) (radian to degree), [_R2G](_R2G) (radian to gradient
|
||||
* [COS](COS) (cosine), [SIN](SIN) (sine), [TAN](TAN) (tangent)
|
||||
* [_ACOS](_ACOS) (arc cosine), [ATN](ATN) (arc tangent)
|
||||
* [_ACOSH](_ACOSH) (arc hyperbolic cosine), [_ASINH](_ASINH) (arc hyperbolic sine), [_ATANH](_ATANH) (arc hyperbolic tangent)
|
||||
* [_ATAN2](_ATAN2) (Compute arc tangent with two parameters)
|
||||
* [_HYPOT](_HYPOT) (hypotenuse)
|
||||
*[Mathematical Operations](Mathematical-Operations)
|
17
wiki/_ASINH.md
Normal file
17
wiki/_ASINH.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
The [_ASINH](_ASINH) function returns the arc hyperbolic sine of x, expressed in radians.
|
||||
|
||||
## Syntax
|
||||
|
||||
> return_value! = [_ASINH](_ASINH)(x!)
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G) (degree to gradient, [_D2R](_D2R) (degree to radian)
|
||||
* [_G2D](_G2D) (gradient to degree), [_G2R](_G2R) (gradient to degree)
|
||||
* [_R2D](_R2D) (radian to degree), [_R2G](_R2G) (radian to gradient)
|
||||
* [COS](COS) (cosine), [SIN](SIN) (sine), [TAN](TAN) (tangent)
|
||||
* [_ACOS](_ACOS) (arc cosine), [_ASIN](_ASIN) (arc sine), [ATN](ATN) (arc tangent)
|
||||
* [_ACOSH](_ACOSH) (arc hyperbolic cosine), [_ATANH](_ATANH) (arc hyperbolic tangent)
|
||||
* [_ATAN2](_ATAN2) (Compute arc tangent with two parameters)
|
||||
* [_HYPOT](_HYPOT) (hypotenuse)
|
||||
*[Mathematical Operations](Mathematical-Operations)
|
46
wiki/_ASSERT.md
Normal file
46
wiki/_ASSERT.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
The [_ASSERT](_ASSERT) statement can be used to perform tests in code that's in development, for debugging purposes.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_ASSERT](_ASSERT) condition[, errorMessage$]
|
||||
|
||||
## Description
|
||||
|
||||
* condition is the condition that must be met in order to consider the _ASSERT valid.
|
||||
* Optional errorMessage$ is the message to be displayed in the console window if [$ASSERTS]($ASSERTS) is used.
|
||||
* If the condition is not met (that is, if it evaluates to 0), an error occurs ("_ASSERT failed on line #") and program execution stops.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Adding test checks for parameter inputs in a function.
|
||||
|
||||
```vb
|
||||
|
||||
$ASSERTS:CONSOLE
|
||||
|
||||
DO
|
||||
a = INT(RND * 10)
|
||||
b$ = myFunc$(a)
|
||||
PRINT a, , b$
|
||||
_LIMIT 3
|
||||
LOOP UNTIL _KEYHIT
|
||||
|
||||
FUNCTION myFunc$ (value AS SINGLE)
|
||||
_ASSERT value > 0, "Value cannot be zero"
|
||||
_ASSERT value <= 10, "Value cannot exceed 10"
|
||||
|
||||
IF value > 1 THEN plural$ = "s"
|
||||
myFunc$ = STRING$(value, "*") + STR$(value) + " star" + plural$ + " :-)"
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$ASSERTS]($ASSERTS)
|
||||
* [$CHECKING]($CHECKING)
|
||||
* [Relational Operations](Relational-Operations)
|
34
wiki/_ATAN2.md
Normal file
34
wiki/_ATAN2.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
The [_ATAN2](_ATAN2) function returns the radian angle between the positive x-axis of a plane and the point given by the coordinates (x, y).
|
||||
|
||||
## Syntax
|
||||
|
||||
> angle! = [_ATAN2](_ATAN2)(y, x)
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* y is the vertical axis position (row) as a positive, zero or negative floating point value.
|
||||
* x is the horizontal axis position (column) as a positive, zero or negative floating point value.
|
||||
|
||||
## Description
|
||||
|
||||
* The [DOUBLE](DOUBLE) radian angle returned is **positive** for upper row values where y > 0.
|
||||
* _ATAN2(y, x) = [ATN](ATN)(y# / x#) when x > 0
|
||||
* _ATAN2(y, x) = [ATN](ATN)(y# / x#) + [_PI](_PI) when x < 0
|
||||
* _ATAN2(y, x) = [_PI](_PI) / 2 when x = 0
|
||||
* The [DOUBLE](DOUBLE) radian angle returned is 0 when x > 0 and [_PI](_PI) when x < 0 where y = 0
|
||||
* The [DOUBLE](DOUBLE) radian angle returned is **negative** for lower row values where y < 0.
|
||||
* _ATAN2(y, x) = [ATN](ATN)(y# / x#) when x > 0
|
||||
* _ATAN2(y, x) = [ATN](ATN)(y# / x#) - [_PI](_PI) when x < 0
|
||||
* _ATAN2(y, x) = -[_PI](_PI) / 2 when x = 0
|
||||
* _ATAN2(0, 0) is undefined and the function returns 0 instead of a division error.
|
||||
|
||||
## Error(s)
|
||||
|
||||
* With [ATN](ATN)(y / x), x can never be 0 as that would create a Division by Zero [ERROR Codes](ERROR-Codes) 11 or #IND.
|
||||
|
||||
## See Also
|
||||
|
||||
* [ATN](ATN) (arctangent)
|
||||
* [_PI](_PI) (QB64 function)
|
||||
* [Mathematical Operations](Mathematical-Operations)
|
||||
* [Atan2 reference](https://en.wikipedia.org/wiki/Atan2)
|
17
wiki/_ATANH.md
Normal file
17
wiki/_ATANH.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
The [_ATANH](_ATANH) returns the arc hyperbolic tangent of x!, expressed in radians.
|
||||
|
||||
## Syntax
|
||||
|
||||
> return_value! = [_ATANH](_ATANH)(x!)
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G) (degree to gradient, [_D2R](_D2R) (degree to radian)
|
||||
* [_G2D](_G2D) (gradient to degree), [_G2R](_G2R) (gradient to degree)
|
||||
* [_R2D](_R2D) (radian to degree), [_R2G](_R2G) (radian to gradient)
|
||||
* [COS](COS) (cosine), [SIN](SIN) (sine), [TAN](TAN) (tangent)
|
||||
* [_ACOS](_ACOS) (arc cosine), [_ASIN](_ASIN) (arc sine), [ATN](ATN) (arc tangent)
|
||||
* [_ACOSH](_ACOSH) (arc hyperbolic cosine), [_ASINH](_ASINH) (arc hyperbolic sine)
|
||||
* [_ATAN2](_ATAN2) (Compute arc tangent with two parameters)
|
||||
* [_HYPOT](_HYPOT) (hypotenuse)
|
||||
*[Mathematical Operations](Mathematical-Operations)
|
19
wiki/_AUTODISPLAY-(function).md
Normal file
19
wiki/_AUTODISPLAY-(function).md
Normal file
|
@ -0,0 +1,19 @@
|
|||
The [_AUTODISPLAY (function)](_AUTODISPLAY-(function)) function returns the current display mode as true (-1) if automatic or false (0) if disabled using [_DISPLAY](_DISPLAY).
|
||||
|
||||
## Syntax
|
||||
|
||||
> displayStatus%% = [_AUTODISPLAY (function)](_AUTODISPLAY-(function))
|
||||
|
||||
## Description
|
||||
|
||||
* The function returns true (-1) if [_AUTODISPLAY](_AUTODISPLAY) is enabled. This is the default state and indicates that every screen change (text or graphics) is displayed immediately to the user.
|
||||
* If [_DISPLAY](_DISPLAY) is used, then [_AUTODISPLAY (function)](_AUTODISPLAY-(function)) returns 0, to indicate that screen changes (text or graphics) are only displayed per request, by calling [_DISPLAY](_DISPLAY) again to refresh the screen.
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170924/69 and up.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_AUTODISPLAY](_AUTODISPLAY)
|
||||
* [_DISPLAY](_DISPLAY)
|
16
wiki/_AUTODISPLAY.md
Normal file
16
wiki/_AUTODISPLAY.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
The [_AUTODISPLAY](_AUTODISPLAY) statement enables the automatic display of the screen image changes previously disabled by [_DISPLAY](_DISPLAY).
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_AUTODISPLAY](_AUTODISPLAY)
|
||||
|
||||
## Description
|
||||
|
||||
* [_AUTODISPLAY](_AUTODISPLAY) is on by default and displays the screen at around 30 frames per second (normal vertical retrace speed).
|
||||
* [_DISPLAY](_DISPLAY) disables automatic graphic displays, but it also eliminates having to use PCOPY or page flipping when used correctly. Placing _DISPLAY after screen draws or other screen changes assures completion of the changes before they are displayed. The speed of QB64 code execution makes this a viable option.
|
||||
* The [_AUTODISPLAY (function)](_AUTODISPLAY-(function)) can be used to detect the current display behavior.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DISPLAY](_DISPLAY)
|
||||
* [_AUTODISPLAY (function)](_AUTODISPLAY-(function))
|
51
wiki/_AXIS.md
Normal file
51
wiki/_AXIS.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
The [_AXIS](_AXIS) function returns the relative position of a specified axis number on a controller device.
|
||||
|
||||
## Syntax
|
||||
|
||||
> move! = [_AXIS](_AXIS)(axis_number%)
|
||||
|
||||
* [SINGLE](SINGLE) values returned range between -1 and 1 as maximums and 0 indicating minimum or axis center.
|
||||
* When the mouse is moved on the program screen, moves left or above center are negative while below or right are positive.
|
||||
* The *axis_number* must be a number which does not exceed the number of axis found by the [_LASTAXIS](_LASTAXIS) function.
|
||||
* **The number of [_DEVICES](_DEVICES) must be read before using [_DEVICE$](_DEVICE$), [_DEVICEINPUT](_DEVICEINPUT) or [_LASTAXIS](_LASTAXIS).**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Reading multiple controller device buttons, axis and wheels.
|
||||
|
||||
```vb
|
||||
|
||||
FOR i = 1 TO _DEVICES
|
||||
PRINT STR$(i) + ") " + _DEVICE$(i) + " Buttons:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
|
||||
NEXT
|
||||
|
||||
DO
|
||||
d& = _DEVICEINPUT
|
||||
IF d& THEN ' the device number cannot be zero!
|
||||
PRINT "Found"; d&;
|
||||
FOR b = 1 TO _LASTBUTTON(d&)
|
||||
PRINT _BUTTONCHANGE(b); _BUTTON(b);
|
||||
NEXT
|
||||
FOR a = 1 TO _LASTAXIS(d&)
|
||||
PRINT _AXIS(a);
|
||||
NEXT
|
||||
FOR w = 1 TO _LASTWHEEL(d&)
|
||||
PRINT _WHEEL(w);
|
||||
NEXT
|
||||
PRINT
|
||||
END IF
|
||||
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* When there is no device control to read, a [FOR...NEXT](FOR...NEXT) n = 1 TO 0 loop will not run thus avoiding a control function read error.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LASTWHEEL](_LASTWHEEL), [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS)
|
||||
* [_WHEEL](_WHEEL), [_BUTTON](_BUTTON), [_BUTTONCHANGE](_BUTTONCHANGE)
|
||||
* [_DEVICE$](_DEVICE$), [_DEVICES](_DEVICES)
|
||||
* [_MOUSEMOVEMENTX](_MOUSEMOVEMENTX), [_MOUSEMOVEMENTY](_MOUSEMOVEMENTY) (relative movement)
|
||||
* [Controller Devices](Controller-Devices)
|
55
wiki/_BACKGROUNDCOLOR.md
Normal file
55
wiki/_BACKGROUNDCOLOR.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
The [_BACKGROUNDCOLOR](_BACKGROUNDCOLOR) function returns the current background color.
|
||||
|
||||
## Syntax
|
||||
|
||||
> BGcolor& = [_BACKGROUNDCOLOR](_BACKGROUNDCOLOR)
|
||||
|
||||
## Description
|
||||
|
||||
* Use it to get the current background color to restore later in a program.
|
||||
* Returns the closest attribute value of the background color.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Storing a background color for later use.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 0
|
||||
COLOR 1, 3
|
||||
CLS
|
||||
BG% = _BACKGROUNDCOLOR
|
||||
PRINT BG%
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
3
|
||||
|
||||
```
|
||||
|
||||
Understanding the function output
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 0
|
||||
COLOR 1, 11
|
||||
CLS
|
||||
BG% = _BACKGROUNDCOLOR
|
||||
PRINT BG% 'prints the attribute as 3 instead of 11
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
3
|
||||
|
||||
```
|
||||
|
||||
> *Explanation: SCREEN 0 background colors over 7 will return the lower intensity color attribute values: EX: attribute - 8
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEFAULTCOLOR](_DEFAULTCOLOR)
|
||||
* [COLOR](COLOR), [SCREEN](SCREEN)
|
||||
* [SCREEN (function)](SCREEN-(function))
|
||||
* [Windows Libraries](Windows-Libraries)
|
104
wiki/_BIT.md
Normal file
104
wiki/_BIT.md
Normal file
|
@ -0,0 +1,104 @@
|
|||
The [_BIT](_BIT) datatype can return only values of 0 (bit off) and -1 (bit on).
|
||||
|
||||
## Syntax
|
||||
|
||||
> [DIM](DIM) variable [AS](AS) [_UNSIGNED] [_BIT](_BIT) [* numberofbits]
|
||||
|
||||
> [_DEFINE](_DEFINE) Letter[-Range|,...] [AS](AS) [_UNSIGNED] [_BIT](_BIT) [* numberofbits]
|
||||
|
||||
## Description
|
||||
|
||||
* An [_UNSIGNED](_UNSIGNED) _BIT can hold 0 or 1 instead of 0 and -1, if you set the numberofbits you can hold larger values depending on the number of bits you have set (_BIT * 8 can hold the same values as [_BYTE](_BYTE) for example) and the information below is compromised if setting any number of bits other than 1.
|
||||
* If you set the variable to any other number then the least significant bit of that number will be set as the variables number, if the bit is 1 (on) then the variable will be -1 and if the bit is 0 (off) then the variable will be 0.
|
||||
* The least significant bit is the last bit on a string of bits (11111) since that bit will only add 1 to the value if set. The most significant bit is the first bit on a string of bits and changes the value more dramatically (significantly) if set on or off.
|
||||
* The _BIT datatype can be succesfully used as a [Boolean](Boolean) (TRUE or FALSE) and it requires minimal amount of memory (the lowest amount possible actually, one byte can hold 8 bits, if you want to use bits in order to decrease memory usage, use them as arrays as a _BIT variable by itself allocates 4 bytes - DIM bitarray(800) AS _BIT uses 100 bytes).
|
||||
* **When a variable has not been assigned or has no type suffix, the value defaults to [SINGLE](SINGLE).**
|
||||
* **[Keywords_currently_not_supported_by_QB64](Keywords-currently-not-supported-by-QB64)** Use a [_BYTE](_BYTE) and assign up to 8 bit values as shown below.
|
||||
|
||||
Use a [_BYTE](_BYTE) and assign up to 8 bit values as shown below.
|
||||
|
||||
***Suffix Symbols** The [_BIT](_BIT) type suffix used is below the grave accent (\`), usually located under the tilde (~) key (not an apostrophe). Foreign keyboards may not have the \` key. Try Alt+96 in the IDE.
|
||||
|
||||
> You can define a bit on-the-fly by adding a \` after the variable, like this: `variable\` = -1`
|
||||
|
||||
> If you want an unsigned bit you can define it on-the-fly by adding ~\` instead, like this: `variable~\` = 1`
|
||||
|
||||
> You can set the number of bits on the fly by just adding that number - this defines it as being two bits: `variable\`2 = -1`
|
||||
|
||||
**[_BIT](_BIT)**
|
||||
|
||||
* The **MSB** is the most significant(largest) bit value and **LSB** is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte:
|
||||
|
||||
* **"Big-endian"**: MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time.
|
||||
* **"Little-endian"**: LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time.
|
||||
|
||||
```text
|
||||
|
||||
**Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000**
|
||||
---------------------------------- --------
|
||||
**Big-Endian Bit On Value:** 128 64 32 16 8 4 2 1 240
|
||||
**Little-Endian Bit On Value:** 1 2 4 8 16 32 64 128 15
|
||||
|
||||
```
|
||||
|
||||
> The big-endian method compares exponents of 2<sup>7</sup> down to 2<sup>0</sup> while the little-endian method does the opposite.
|
||||
|
||||
**[_BYTE](_BYTE)**
|
||||
|
||||
* [INTEGER](INTEGER) values consist of 2 bytes called the **HI** and **LO** bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [SINGLE](SINGLE) or [DOUBLE](DOUBLE) values!
|
||||
|
||||
```text
|
||||
|
||||
**16 BIT INTEGER OR REGISTER**
|
||||
**AH (High Byte Bits) AL (Low Byte Bits)**
|
||||
BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0
|
||||
---------------------------------------|--------------------------------------
|
||||
HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1
|
||||
|
|
||||
DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1
|
||||
|
||||
```
|
||||
|
||||
> The HI byte's **MSB** is often called the **sign** bit! When all 16 of the integer binary bits are on, the decimal return is -1.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Shifting bits in a value in QB64 versions prior to 1.3 (you can use [_SHL](_SHL) and [_SHR](_SHR) starting with version 1.3).
|
||||
|
||||
```vb
|
||||
|
||||
n = 24
|
||||
Shift = 3
|
||||
|
||||
PRINT LShift(n, Shift)
|
||||
PRINT RShift(n, Shift)
|
||||
END
|
||||
|
||||
FUNCTION LShift&(n AS LONG, LS AS LONG)
|
||||
IF LS < 0 THEN EXIT FUNCTION
|
||||
LShift = INT(n * (2 ^ LS))
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION RShift&(n AS LONG, RS AS LONG)
|
||||
IF RS < 0 THEN EXIT FUNCTION
|
||||
RShift = INT(n / (2 ^ RS))
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
192
|
||||
3
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [&B](&B) (binary), [_BYTE](_BYTE)
|
||||
* [_SHL](_SHL), [_SHR](_SHR)
|
||||
* [_DEFINE](_DEFINE), [_UNSIGNED](_UNSIGNED)
|
||||
* [DIM](DIM)
|
||||
* [Binary](Binary), [Boolean](Boolean)
|
||||
* [Variable Types](Variable-Types)
|
||||
* [Converting Bytes to Bits](Converting-Bytes-to-Bits)
|
15
wiki/_BLEND-(function).md
Normal file
15
wiki/_BLEND-(function).md
Normal file
|
@ -0,0 +1,15 @@
|
|||
The [_BLEND (function)](_BLEND-(function)) function returns enabled or disabled for the current window or a specified image handle when 32 bit.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result% = [_BLEND (function)](_BLEND-(function)) [(imageHandle&)]
|
||||
|
||||
## Description
|
||||
|
||||
* _BLEND returns -1 if enabled or 0 if disabled by [_DONTBLEND](_DONTBLEND) statement.
|
||||
* **Note: [_DONTBLEND](_DONTBLEND) is faster than the default [_BLEND](_BLEND) unless you really need to use it in 32 bit.**
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DONTBLEND](_DONTBLEND), [_BLEND](_BLEND)
|
||||
* [Images](Images)
|
64
wiki/_BLEND.md
Normal file
64
wiki/_BLEND.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
The [_BLEND](_BLEND) statement turns on 32 bit alpha blending for an image or screen mode and is on by default.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_BLEND](_BLEND) [imageHandle&]
|
||||
|
||||
### Parameters
|
||||
|
||||
* imageHandle& refers to an image in memory. If not specified, the current destination page (See [_DEST](_DEST)) is affected.
|
||||
|
||||
## Description
|
||||
|
||||
* Alpha blending is on by default when loading a .PNG image to a 32-bit surface.
|
||||
* Normally it is used to turn blending on after a previous [_DONTBLEND](_DONTBLEND) call.
|
||||
* [_BLEND](_BLEND) can only be used on 32-bit surfaces, otherwise it will produce the error [ERROR Codes](ERROR-Codes).
|
||||
* **Note: [_DONTBLEND](_DONTBLEND) is faster than the default [_BLEND](_BLEND) unless you really need to use it in 32 bit.**
|
||||
* **32 bit screen surface backgrounds (black) have zero [_ALPHA](_ALPHA) so that they are transparent when placed over other surfaces.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
|
||||
'CLS , _RGB(128, 128, 128) 'change background color for other results
|
||||
|
||||
_DONTBLEND
|
||||
|
||||
bg& = POINT(0, 0)
|
||||
PRINT _RED(bg&), _GREEN(bg&), _BLUE(bg&), _ALPHA(bg&)
|
||||
|
||||
LINE (100, 100)-(200, 200), _RGBA32(255, 128, 0, 128), BF
|
||||
|
||||
LINE (440, 100)-(540, 200), _RGBA32(0, 0, 255, 64), BF
|
||||
|
||||
K$ = INPUT$(1)
|
||||
|
||||
_BLEND
|
||||
|
||||
LINE (270, 300)-(370, 400), _RGBA32(255, 128, 0, 128), BF
|
||||
m& = POINT(303, 302)
|
||||
PRINT _RED(m&), _GREEN(m&), _BLUE(m&), _ALPHA(m&)
|
||||
K$ = INPUT$(1)
|
||||
|
||||
LINE (270, 300)-(370, 400), _RGBA32(0, 0, 255, 64), BF
|
||||
m& = POINT(303, 302)
|
||||
PRINT _RED(m&), _GREEN(m&), _BLUE(m&), _ALPHA(m&)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
_RGBA(255,128,0,128) onto _RGBA(0,0,255,64)
|
||||
|
||||
results in
|
||||
|
||||
_RGBA(95,48,64,128)
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DONTBLEND](_DONTBLEND), [_BLEND (function)](_BLEND-(function))
|
||||
* [Images](Images)
|
31
wiki/_BLINK-(function).md
Normal file
31
wiki/_BLINK-(function).md
Normal file
|
@ -0,0 +1,31 @@
|
|||
The [_BLINK](_BLINK) function returns the current blink setting for SCREEN 0 colors. If enabled, returns -1 (default), otherwise returns 0.
|
||||
|
||||
## Syntax
|
||||
|
||||
> blinkState%% = [_BLINK](_BLINK)
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170816/61 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
COLOR 16, 7
|
||||
|
||||
'Try uncommenting the line below:
|
||||
'_BLINK OFF
|
||||
|
||||
IF _BLINK THEN
|
||||
PRINT "I'm blinking"
|
||||
ELSE
|
||||
PRINT "I'm not blinking"
|
||||
END IF
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_BLINK](_BLINK) (statement)
|
||||
* [OUT](OUT)
|
35
wiki/_BLINK.md
Normal file
35
wiki/_BLINK.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
The [_BLINK](_BLINK) statement toggles blinking colors in text mode (SCREEN 0). Default state is ON.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_BLINK](_BLINK) {ON|OFF}
|
||||
|
||||
## Description
|
||||
|
||||
* SCREEN 0 emulates the VGA palette with regular colors from 0 to 15 and blinking colors from 16-31 (these are the same colors as 0-15, except their blink attribute is set to on). [_BLINK](_BLINK) OFF emulates writing to the video memory and disabling blinking for colors 16-31.
|
||||
* Using colors 16-31 for the foreground with [_BLINK](_BLINK) set to OFF will produce high intensity background colors.
|
||||
* [_BLINK](_BLINK) is only effective in SCREEN 0. It's ignored in graphic modes.
|
||||
* IF [_DISPLAY](_DISPLAY) is used, blinking is disabled, even if _BLINK is ON, but high intensity backgrounds aren't enabled in this case.
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170816/61 up (August 16, 2017).
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
COLOR 16, 7
|
||||
PRINT "This is printed in black over gray background. Black letters are blinking."
|
||||
PRINT "Hit a key..."
|
||||
SLEEP
|
||||
_BLINK OFF
|
||||
PRINT "Now the same text is printed in black over bright white, because blinking was disabled."
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_BLINK (function)](_BLINK-(function))
|
||||
* [OUT](OUT)
|
||||
* [_DISPLAY](_DISPLAY)
|
27
wiki/_BLUE.md
Normal file
27
wiki/_BLUE.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
The [_BLUE](_BLUE) function returns the palette intensity or the blue component intensity of a 32-bit image color.
|
||||
|
||||
## Syntax
|
||||
|
||||
> blueintensity& = [_BLUE](_BLUE)(rgbaColorIndex&[, imageHandle&])
|
||||
|
||||
## Description
|
||||
|
||||
* rgbaColorIndex& is the *RGBA* color value or palette index of the color to retrieve the blue component intensity from.
|
||||
* The [LONG](LONG) intensity value returned ranges from 0 (no intensity, not present) to 255 (full intensity).
|
||||
* If imageHandle& specifies a 32-bit color image, rgbaColorIndex& is interpreted as a 32-bit *RGBA* color value.
|
||||
* If imageHandle& specifies an image that uses a palette, rgbaColorIndex& is interpreted as a palette index.
|
||||
* If imageHandle& is not specified, it is assumed to be the current write page.
|
||||
* If imageHandle& is an invalid handle, an [ERROR Codes](ERROR-Codes) error will occur.
|
||||
* If rgbaColorIndex& is outside the range of valid indexes for a given image mode, an [ERROR Codes](ERROR-Codes) error occurs.
|
||||
* Uses index parameters passed by the [_RGB](_RGB), [_RGBA](_RGBA), [_RGB32](_RGB32) or [_RGBA32](_RGBA32) funtions.
|
||||
* An image handle is optional.
|
||||
|
||||
## Example(s)
|
||||
|
||||
* See the example for [POINT](POINT).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_RED](_RED), [_GREEN](_GREEN)
|
||||
* [_RGB](_RGB), [RGB32](RGB32)
|
||||
* [_LOADIMAGE](_LOADIMAGE)
|
20
wiki/_BLUE32.md
Normal file
20
wiki/_BLUE32.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
The [_BLUE32](_BLUE32) function returns the blue component intensity of a 32-bit image or surface color.
|
||||
|
||||
## Syntax
|
||||
|
||||
> blue32color& = [_BLUE32](_BLUE32)(rgbaColor&)
|
||||
|
||||
## Description
|
||||
|
||||
* rgbaColor& is the 32-bit *RGBA* color value to retrieve the blue component intensity value from.
|
||||
* *RGBA* color values are returned by the [_PALETTECOLOR (function)](_PALETTECOLOR-(function)), [POINT](POINT), [_RGB](_RGB), [_RGB32](_RGB32), [_RGBA](_RGBA) or [_RGBA32](_RGBA32) functions.
|
||||
* [LONG](LONG) intensity values returned range from 0 (no intensity, not present) to 255 (full intensity).
|
||||
|
||||
## Example(s)
|
||||
|
||||
* See the example for [POINT](POINT).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_RED32](_RED32), [_GREEN32](_GREEN32)
|
||||
* [_RGB32](_RGB32), [_BLUE](_BLUE)
|
54
wiki/_BUTTON.md
Normal file
54
wiki/_BUTTON.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
The [_BUTTON](_BUTTON) function returns -1 when specified button number on a controller device is pressed.
|
||||
|
||||
## Syntax
|
||||
|
||||
> press%% = [_BUTTON](_BUTTON)(button_number%)
|
||||
|
||||
## Description
|
||||
|
||||
* The **[_DEVICEINPUT](_DEVICEINPUT) function should be read first to specify which device [_BUTTON](_BUTTON) is intended to check.**
|
||||
* Values returned are -1 for a press and 0 when a button is released or not pressed.
|
||||
* The button_number% must be a number which does not exceed the number of buttons found by the [_LASTBUTTON](_LASTBUTTON) function.
|
||||
* **The number of [_DEVICES](_DEVICES) must be read before using [_DEVICE$](_DEVICE$), [_DEVICEINPUT](_DEVICEINPUT) or [_LASTBUTTON](_LASTBUTTON).**
|
||||
* **Note:** The number 2 button is the center button in this device configuration. Center is also designated as [_MOUSEBUTTON](_MOUSEBUTTON)(3).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Reading multiple controller device buttons, axis and wheels.
|
||||
|
||||
```vb
|
||||
|
||||
FOR i = 1 TO _DEVICES
|
||||
PRINT STR$(i) + ") " + _DEVICE$(i) + " Buttons:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
|
||||
NEXT
|
||||
|
||||
DO
|
||||
d& = _DEVICEINPUT
|
||||
IF d& THEN ' the device number cannot be zero!
|
||||
PRINT "Found"; d&;
|
||||
FOR b = 1 TO _LASTBUTTON(d&)
|
||||
PRINT _BUTTONCHANGE(b); _BUTTON(b);
|
||||
NEXT
|
||||
FOR a = 1 TO _LASTAXIS(d&)
|
||||
PRINT _AXIS(a);
|
||||
NEXT
|
||||
FOR w = 1 TO _LASTWHEEL(d&)
|
||||
PRINT _WHEEL(w);
|
||||
NEXT
|
||||
PRINT
|
||||
END IF
|
||||
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* When there is no device control to read, a [FOR...NEXT](FOR...NEXT) n = 1 TO 0 loop will not run thus avoiding a control function read error.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LASTWHEEL](_LASTWHEEL), [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS)
|
||||
* [_AXIS](_AXIS), [_WHEEL](_WHEEL), [_BUTTONCHANGE](_BUTTONCHANGE)
|
||||
* [_DEVICE$](_DEVICE$), [_DEVICES](_DEVICES)
|
||||
* [_MOUSEBUTTON](_MOUSEBUTTON)
|
||||
* [Controller Devices](Controller-Devices)
|
54
wiki/_BUTTONCHANGE.md
Normal file
54
wiki/_BUTTONCHANGE.md
Normal file
|
@ -0,0 +1,54 @@
|
|||
The [_BUTTONCHANGE](_BUTTONCHANGE) function returns -1 or 1 when a specified button number on a controller device has been pressed or released.
|
||||
|
||||
## Syntax
|
||||
|
||||
> press% = [_BUTTONCHANGE](_BUTTONCHANGE)(button_number%)
|
||||
|
||||
## Description
|
||||
|
||||
* The **[_DEVICEINPUT](_DEVICEINPUT) function should be read first to specify which device [_BUTTONCHANGE](_BUTTONCHANGE) is intended to check.**
|
||||
* Values returned are -1 for a press and 1 when a button is released. No press or release event returns zero.
|
||||
* The button_number% must be a number which does not exceed the number of buttons found by the [_LASTBUTTON](_LASTBUTTON) function.
|
||||
* **The number of [_DEVICES](_DEVICES) must be read before using [_DEVICE$](_DEVICE$), [_DEVICEINPUT](_DEVICEINPUT) or [_LASTBUTTON](_LASTBUTTON).**
|
||||
* **Note:** The center mouse button is button number 2. Center can also be read using [_MOUSEBUTTON](_MOUSEBUTTON)(3).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Reading multiple controller device buttons, axis and wheels.
|
||||
|
||||
```vb
|
||||
|
||||
FOR i = 1 TO _DEVICES
|
||||
PRINT STR$(i) + ") " + _DEVICE$(i) + " Buttons:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
|
||||
NEXT
|
||||
|
||||
DO
|
||||
d& = _DEVICEINPUT
|
||||
IF d& THEN ' the device number cannot be zero!
|
||||
PRINT "Found"; d&;
|
||||
FOR b = 1 TO _LASTBUTTON(d&)
|
||||
PRINT _BUTTONCHANGE(b); _BUTTON(b);
|
||||
NEXT
|
||||
FOR a = 1 TO _LASTAXIS(d&)
|
||||
PRINT _AXIS(a);
|
||||
NEXT
|
||||
FOR w = 1 TO _LASTWHEEL(d&)
|
||||
PRINT _WHEEL(w);
|
||||
NEXT
|
||||
PRINT
|
||||
END IF
|
||||
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* When there is no device control to read, a [FOR...NEXT](FOR...NEXT) n = 1 TO 0 loop will not run thus avoiding a control function read error.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LASTWHEEL](_LASTWHEEL), [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS)
|
||||
* [_AXIS](_AXIS), [_WHEEL](_WHEEL), [_BUTTON](_BUTTON)
|
||||
* [_DEVICE$](_DEVICE$), [_DEVICES](_DEVICES)
|
||||
* [_MOUSEBUTTON](_MOUSEBUTTON)
|
||||
* [Controller Devices](Controller-Devices)
|
111
wiki/_BYTE.md
Normal file
111
wiki/_BYTE.md
Normal file
|
@ -0,0 +1,111 @@
|
|||
A [_BYTE](_BYTE) variable can hold signed variable values from -128 to 127 (one byte or 8 [_BIT](_BIT)s). [_UNSIGNED](_UNSIGNED) from 0 to 255.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [DIM](DIM) byte [AS](AS) [[_UNSIGNED]([_UNSIGNED)] [[_BYTE]]
|
||||
|
||||
## Description
|
||||
|
||||
* Signed _BYTE values can range from -128 to 127.
|
||||
* [_UNSIGNED](_UNSIGNED) _BYTEs can hold values from 0 to 255. [_UNSIGNED](_UNSIGNED) expands the range of positive values.
|
||||
* Can be defined in a **QB64** [_DEFINE](_DEFINE) statement using a starting letter range of variable names.
|
||||
* Also can be used in a subroutine parameter [AS](AS) _BYTE variable definitions.
|
||||
* Define a byte using the suffix %% after the variable name: variable%% = -54
|
||||
* Define an unsigned byte by adding the suffix ~%% after the variable name: variable~%% = 54
|
||||
* **When a variable has not been assigned or has no type suffix, the value defaults to [SINGLE](SINGLE).**
|
||||
|
||||
**[_BIT](_BIT)**
|
||||
|
||||
* The **MSB** is the most significant(largest) bit value and **LSB** is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte:
|
||||
|
||||
* **"Big-endian"**: MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time.
|
||||
* **"Little-endian"**: LSB is the first bit encountered, increasing to the MSB as the last bit by position, memory address or time.
|
||||
|
||||
```text
|
||||
|
||||
**Offset or Position: 0 1 2 3 4 5 6 7 Example: 11110000**
|
||||
---------------------------------- --------
|
||||
**Big-Endian Bit On Value:** 128 64 32 16 8 4 2 1 240
|
||||
**Little-Endian Bit On Value:** 1 2 4 8 16 32 64 128 15
|
||||
|
||||
```
|
||||
|
||||
> The big-endian method compares exponents of 2<sup>7</sup> down to 2<sup>0</sup> while the little-endian method does the opposite.
|
||||
|
||||
**[_BYTE](_BYTE)**
|
||||
|
||||
* [INTEGER](INTEGER) values consist of 2 bytes called the **HI** and **LO** bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [SINGLE](SINGLE) or [DOUBLE](DOUBLE) values!
|
||||
|
||||
```text
|
||||
|
||||
**16 BIT INTEGER OR REGISTER**
|
||||
**AH (High Byte Bits) AL (Low Byte Bits)**
|
||||
BIT: 15 14 13 12 11 10 9 8 | 7 6 5 4 3 2 1 0
|
||||
---------------------------------------|--------------------------------------
|
||||
HEX: 8000 4000 2000 1000 800 400 200 100 | 80 40 20 10 8 4 2 1
|
||||
|
|
||||
DEC: -32768 16384 8192 4096 2048 1024 512 256 | 128 64 32 16 8 4 2 1
|
||||
|
||||
```
|
||||
|
||||
> The HI byte's **MSB** is often called the **sign** bit! When all 16 of the integer binary bits are on, the decimal return is -1.
|
||||
|
||||
## Example(s)
|
||||
|
||||
> How negative assignments affect the _UNSIGNED value returned by a byte (8 bits).
|
||||
|
||||
```vb
|
||||
|
||||
DIM unsig AS _UNSIGNED _BYTE
|
||||
DIM sig AS _BYTE
|
||||
|
||||
CLS
|
||||
unsig = 1
|
||||
sig = 1
|
||||
PRINT "00000001 = unsigned & signed are both" + STR$(unsig AND sig)
|
||||
|
||||
unsig = 127
|
||||
sig = 127
|
||||
PRINT "&B01111111 = unsigned & signed are both" + STR$(unsig AND sig)
|
||||
|
||||
unsig = 255
|
||||
sig = 255
|
||||
PRINT "&B11111111 = unsigned is" + STR$(unsig) + " but signed is " + STR$(sig)
|
||||
|
||||
unsig = 254
|
||||
sig = 254
|
||||
PRINT "&B11111110 = unsigned is" + STR$(unsig) + " but signed is " + STR$(sig)
|
||||
|
||||
unsig = 253
|
||||
sig = 253
|
||||
PRINT "&B11111101 = unsigned is" + STR$(unsig) + " but signed is " + STR$(sig)
|
||||
|
||||
PRINT
|
||||
PRINT "The signed value needs the MSB bit for the sign."
|
||||
PRINT "The most significant bit is furthest to the left."
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
&B00000001 = unsigned & signed are both 1
|
||||
&B01111111 = unsigned & signed are both 127
|
||||
&B11111111 = unsigned is 255 but signed is -1
|
||||
&B11111110 = unsigned is 254 but signed is -2
|
||||
&B11111101 = unsigned is 253 but signed is -3
|
||||
|
||||
The signed value needs the MSB bit for the sign.
|
||||
The most significant bit is furthest to the left.
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_BIT](_BIT), [&B](&B)
|
||||
* [_DEFINE](_DEFINE), [DIM](DIM)
|
||||
* [_UNSIGNED](_UNSIGNED)
|
||||
* [_SHL](_SHL), [_SHR](_SHR)
|
||||
* [Mathematical Operations](Mathematical-Operations)
|
||||
* [Screen Memory](Screen-Memory)
|
||||
* [Variable Types](Variable-Types)
|
||||
* [Converting Bytes to Bits](Converting-Bytes-to-Bits)
|
15
wiki/_CAPSLOCK-(function).md
Normal file
15
wiki/_CAPSLOCK-(function).md
Normal file
|
@ -0,0 +1,15 @@
|
|||
The [_CAPSLOCK (function)](_CAPSLOCK-(function)) function returns the current state of the Caps Lock key as on (-1) or off (0).
|
||||
|
||||
## Syntax
|
||||
|
||||
> keyStatus%% = [_CAPSLOCK (function)](_CAPSLOCK-(function))
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_NUMLOCK (function)](_NUMLOCK-(function)), [_SCROLLLOCK (function)](_SCROLLLOCK-(function))
|
||||
* [_CAPSLOCK](_CAPSLOCK) (statement), [_NUMLOCK](_NUMLOCK) (statement), [_SCROLLLOCK](_SCROLLLOCK) (statement)
|
15
wiki/_CAPSLOCK.md
Normal file
15
wiki/_CAPSLOCK.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
The [_CAPSLOCK](_CAPSLOCK) statement sets the state of the Caps Lock key.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CAPSLOCK](_CAPSLOCK) {ON|OFF|_TOGGLE}
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CAPSLOCK (function)](_CAPSLOCK-(function)), [_NUMLOCK (function)](_NUMLOCK-(function)), [_SCROLLLOCK (function)](_SCROLLLOCK-(function))
|
||||
* [_NUMLOCK](_NUMLOCK) (statement), [_SCROLLLOCK](_SCROLLLOCK) (statement)
|
37
wiki/_CEIL.md
Normal file
37
wiki/_CEIL.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
The [_CEIL](_CEIL) function rounds a numeric value up to the next whole number or [INTEGER](INTEGER) value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result = [_CEIL](_CEIL)(expression)
|
||||
|
||||
* [_CEIL](_CEIL) returns he smallest integral value that is greater than the numerical expression (as a floating-point value).
|
||||
* This means that [_CEIL](_CEIL) rounds up for both positive and negative numbers.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Displaying the rounding behavior of [INT](INT), [CINT](CINT) and [FIX](FIX) vs [_CEIL](_CEIL).
|
||||
|
||||
```vb
|
||||
|
||||
PRINT INT(2.5), CINT(2.5), FIX(2.5), _CEIL(2.5)
|
||||
PRINT INT(-2.5), CINT(-2.5), FIX(-2.5), _CEIL(-2.5)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
2 2 2 3
|
||||
-3 -2 -2 -2
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [INT](INT), [FIX](FIX)
|
||||
* [CINT](CINT), [CLNG](CLNG),
|
||||
* [CSNG](CSNG), [CDBL](CDBL)
|
||||
* [_ROUND](_ROUND)
|
60
wiki/_CINP.md
Normal file
60
wiki/_CINP.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
The [_CINP](_CINP) function returns keyboard key press codes from a [$CONSOLE]($CONSOLE) window. Windows-only.
|
||||
|
||||
## Syntax
|
||||
|
||||
> keycode& = [_CINP](_CINP)
|
||||
|
||||
## Description
|
||||
|
||||
* Return values are the same as the ones for [INP](INP) when used to read keyboard input. See table below.
|
||||
* **Negative** [LONG](LONG) values returned indicate that a key was released or a lock function key has been turned off.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
```text
|
||||
|
||||
' **Extended Keyboard Press Scancodes**
|
||||
'
|
||||
**' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SysReq ScrL Pause**
|
||||
' 1 59 60 61 62 63 64 65 66 67 68 87 88 0 70 29
|
||||
' **`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSpc Insert Home PgUp NumL / * -**
|
||||
' 41 2 3 4 5 6 7 8 9 10 11 12 13 14 82 71 73 69 53 55 74
|
||||
' **Tab Q W E R T Y U I O P [{ ]} \| Delete End PgDn 7/Home 8/▲ 9/PU + **
|
||||
' 15 16 17 18 19 20 21 22 23 24 25 26 27 43 83 79 81 71 72 73 78
|
||||
' **CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-► E**
|
||||
' 58 30 31 32 33 34 35 36 37 38 39 40 28 75 76 77 **n**
|
||||
' **Shift Z X C V B N M ,< .> /? Shift ▲ 1/End 2/▼ 3/PD t**
|
||||
' 42 44 45 46 47 48 49 50 51 52 53 54 72 79 80 81 **e**
|
||||
' **Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0/Insert ./Del r**
|
||||
' 29 91 56 57 56 92 93 29 75 80 77 82 83 28
|
||||
'
|
||||
|
||||
```
|
||||
|
||||
## Example(s)
|
||||
|
||||
Reading individual key strokes from a console window (Windows).
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE:ONLY
|
||||
_DEST _CONSOLE: _SOURCE _CONSOLE
|
||||
|
||||
PRINT "Press any key, and I'll give you the scan code for it. <ESC> quits the demo."
|
||||
PRINT
|
||||
PRINT
|
||||
DO
|
||||
x = _CONSOLEINPUT
|
||||
IF x = 1 THEN 'read only keyboard input ( = 1)
|
||||
c = _CINP
|
||||
PRINT c;
|
||||
END IF
|
||||
LOOP UNTIL c = 1
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [_CONSOLE](_CONSOLE)
|
||||
* [_CONSOLEINPUT](_CONSOLEINPUT)
|
||||
* [_MOUSEX](_MOUSEX), [_MOUSEY](_MOUSEY), [_MOUSEBUTTON](_MOUSEBUTTON), [_MOUSEWHEEL](_MOUSEWHEEL)
|
21
wiki/_CLEARCOLOR-(function).md
Normal file
21
wiki/_CLEARCOLOR-(function).md
Normal file
|
@ -0,0 +1,21 @@
|
|||
The [_CLEARCOLOR (function)](_CLEARCOLOR-(function)) function returns the current transparent color of an image or page.
|
||||
|
||||
## Syntax
|
||||
|
||||
> *result&* = [_CLEARCOLOR (function)](_CLEARCOLOR-(function)) [Source_Handle&]
|
||||
|
||||
## Description
|
||||
|
||||
* If Source_Handle& is omitted, it is assumed to be the current [_DEST](_DEST) write page.
|
||||
* If Source_Handle& is an invalid handle value(-1), then an [ERROR Codes](ERROR-Codes) is returned.
|
||||
* In color modes using a palette, the index of the current transparent color value is returned, or -1 if no transparent color is set.
|
||||
* In 32-bit color modes, zero is returned.
|
||||
* Returns the color that currently is transparent, or if no color is transparent -1 without error.
|
||||
* A [_CLEARCOLOR](_CLEARCOLOR) statement can set the transparent color of an image or screen.
|
||||
* **NOTE: Default 32 bit backgrounds are clear black or [_RGBA](_RGBA)(0, 0, 0, 0). Use [CLS](CLS) to make the black opaque.**
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLEARCOLOR](_CLEARCOLOR) (sets a clear color)
|
||||
* [_SETALPHA](_SETALPHA) (sets color transparency)
|
||||
* [Images](Images)
|
99
wiki/_CLEARCOLOR.md
Normal file
99
wiki/_CLEARCOLOR.md
Normal file
|
@ -0,0 +1,99 @@
|
|||
The [_CLEARCOLOR](_CLEARCOLOR) statement sets a specific color to be treated as transparent when an image is later put (via [_PUTIMAGE](_PUTIMAGE)) onto another image.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CLEARCOLOR](_CLEARCOLOR) {color&|_NONE}[, Dest_Handle&]
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* In color modes using a palette, color& is the palette index of the new transparent color value or _NONE designates no clear colors.
|
||||
* If color& is not a valid palette index, an [ERROR Codes](ERROR-Codes) error will occur.
|
||||
* In 32-bit color modes, color& is the [_LONG](_LONG) color value of the new transparent color.
|
||||
* If Dest_Handle& is omitted, the destination is assumed to be the current write page. Zero can designate the current program screen.
|
||||
|
||||
## Description
|
||||
|
||||
* If Dest_Handle& is an invalid handle, then an [ERROR Codes](ERROR-Codes) error is returned. Check for bad handle values of -1 first.
|
||||
* In 32-bit color modes, it simply sets the Alpha to 0 for all pixels matching the specified color.
|
||||
* In the second syntax, transparency is disabled for color modes using a palette.
|
||||
* **Note:** [_SETALPHA](_SETALPHA) can affect any _CLEARCOLOR alpha setting within the color range set.
|
||||
* **NOTE: 32 bit [_NEWIMAGE](_NEWIMAGE) screen page backgrounds are transparent black or [_ALPHA](_ALPHA) 0. Use [_DONTBLEND](_DONTBLEND) or [CLS](CLS) for opaque.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Using _CLEARCOLOR to "mask" the background color of an image.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 13
|
||||
img& = _LOADIMAGE("qb64_trans.png")
|
||||
_PUTIMAGE , img&, 0 'place actual image with background
|
||||
K$ = INPUT$(1)
|
||||
CLS , _RGB(255, 0, 0) 'clear screen with red background
|
||||
_CLEARCOLOR _RGB(255, 255, 255), img&
|
||||
_PUTIMAGE , img&, 0 'place image without white background
|
||||
PRINT _CLEARCOLOR(img&) 'displays closest clear color attribute
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
Using a _CLEARCOLOR transparency with images created on a [_NEWIMAGE](_NEWIMAGE) page. Does not require an image file.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(512, 384, 32) ' screen uses handle value
|
||||
CIRCLE(50, 50), 50, _RGB(128, 0, 0) ' create a red ball image
|
||||
PAINT(50, 50), _RGB(255, 0, 0), _RGB(128, 0, 0)
|
||||
redball = _NEWIMAGE(101, 101, 32) ' create a new image page
|
||||
_PUTIMAGE , 0, redball,(0, 0)-(101, 101) ' put screen page 0 image onto redball page
|
||||
_CLEARCOLOR _RGB(0, 0, 0), redball ' makes black become see-through
|
||||
CLS, _RGB(0, 0, 255) ' erase original ball and create a blue background
|
||||
DO
|
||||
_PUTIMAGE (RND * 512, RND * 384), redball
|
||||
SLEEP 1 ' one second delay
|
||||
LOOP UNTIL INKEY$ <> ""
|
||||
|
||||
```
|
||||
|
||||
Fading an image with a _CLEARCOLOR background using a new page image to prevent [_SETALPHA](_SETALPHA) changes.
|
||||
|
||||
```vb
|
||||
|
||||
mainscreen = _NEWIMAGE(640, 480, 32) ' Main Screen (viewable)
|
||||
SCREEN mainscreen
|
||||
_SCREENMOVE _MIDDLE
|
||||
Image1& = _LOADIMAGE("qb64_trans.png") '<<<<<< any image with one background color to clear
|
||||
|
||||
IF Image1& < -1 THEN 'check loaded image handle value before using!
|
||||
_SOURCE Image1&
|
||||
clr~& = POINT(0, 0) 'get background color from image source
|
||||
_CLEARCOLOR clr~&, Image1& 'clear background color of loaded image
|
||||
NewImage1& = _NEWIMAGE(_WIDTH(Image1&), _HEIGHT(Image1&), 32) 'new image page
|
||||
_PUTIMAGE , Image1&, NewImage1& 'put image without background color on new page
|
||||
_FREEIMAGE Image1& 'free loaded image from memory
|
||||
END IF
|
||||
_DEST mainscreen:
|
||||
|
||||
a& = 0: d = 1
|
||||
DO
|
||||
_LIMIT 10 'regulate speed of fades
|
||||
CLS
|
||||
a& = a& + d
|
||||
IF a& = 255 THEN d = -d 'reverse fade
|
||||
_SETALPHA a&, , NewImage1& 'sets alpha level of all colors to fade image page in/out
|
||||
_PUTIMAGE (0, 342), NewImage1&
|
||||
LOCATE 1, 1: PRINT "Alpha: "; a&
|
||||
_DISPLAY
|
||||
LOOP UNTIL a& = 0
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* If the _CLEARCOLOR background was not put onto a separate page, [_SETALPHA](_SETALPHA) would display it also.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLEARCOLOR (function)](_CLEARCOLOR-(function))
|
||||
* [_SETALPHA](_SETALPHA) (sets transparency level)
|
||||
* [_ALPHA](_ALPHA), [_ALPHA32](_ALPHA32) (read functions)
|
||||
* [Images](Images), [Creating Sprite Masks](Creating-Sprite-Masks)
|
48
wiki/_CLIP.md
Normal file
48
wiki/_CLIP.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
The [_CLIP](_CLIP) option is used in a QB64 graphics [PUT (graphics statement)](PUT-(graphics-statement)) to allow placement of an image partially off of the screen.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [PUT (graphics statement)](PUT-(graphics-statement)) [[STEP]([STEP)](column, row), image_array(start)[, [[_CLIP]]] [{XOR|PSET|AND|OR|PRESET}][, omitcolor]
|
||||
|
||||
## Description
|
||||
|
||||
* _CLIP should be placed immediately before the PUT action if used. XOR is default when not used.
|
||||
* The offscreen portions of the image will be the omit color.
|
||||
* [GET (graphics statement)](GET-(graphics-statement)) can get portions of the images off screen in **QB64**.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Placing an image partially or fully offscreen.
|
||||
|
||||
```vb
|
||||
|
||||
DIM mypic(500)
|
||||
SCREEN 13
|
||||
|
||||
CLS
|
||||
CIRCLE (10,10),10
|
||||
GET (0,0)-(20,20), mypic(0)
|
||||
|
||||
PRINT "This program puts an image off screen."
|
||||
PRINT "Select which option you'd like to try."
|
||||
PRINT "1 will produce an illegal function call."
|
||||
PRINT "1 is putting without _CLIP."
|
||||
PRINT "2 is putting with _CLIP PSET."
|
||||
PRINT "3 is putting with _CLIP XOR."
|
||||
PRINT "4 is putting with _CLIP PSET, 4."
|
||||
|
||||
INPUT sel
|
||||
IF sel = 1 THEN PUT (-10, 10), mypic(0), PSET ' this causes an illegal function call
|
||||
IF sel = 2 THEN PUT (-10, 10), mypic(0), _CLIP PSET ' allows graphic to be drawn off-screen
|
||||
IF sel = 3 THEN PUT (-10, 10), mypic(0), _CLIP ' uses the default PUT XOR operation
|
||||
IF sel = 4 THEN PUT (-10, 10), mypic(0), _CLIP PSET, 4 ' doesn't draw red pixels
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [PUT (graphics statement)](PUT-(graphics-statement))
|
||||
* [GET (graphics statement)](GET-(graphics-statement))
|
||||
* [STEP](STEP)
|
45
wiki/_CLIPBOARD$-(statement).md
Normal file
45
wiki/_CLIPBOARD$-(statement).md
Normal file
|
@ -0,0 +1,45 @@
|
|||
The [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement)) statement copies the specified [STRING](STRING) value into the operating system's clipboard.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement)) = string_expression$
|
||||
|
||||
## Description
|
||||
|
||||
* string_expression$ is the string value to be sent to the clipboard.
|
||||
* The string value will replace everything previously in the clipboard.
|
||||
* Assemble long text into one string variable value before using this statement.
|
||||
* Add CHR$(13) + CHR$(10) CRLF characters to move to a new clipboard line.
|
||||
* When copying text files, end line CRLF characters 13 and 10 do not have to be added.
|
||||
* Numerical values can be converted to strings using [STR$](STR$), [_MK$](_MK$), [MKI$](MKI$), [MKL$](MKL$), [MKS$](MKS$), [MKD$](MKD$), [HEX$](HEX$) or [OCT$](OCT$).
|
||||
* The clipboard can be used to copy, paste and communicate between running programs.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Set 2 lines of text in the clipboard using a carriage return to end text lines
|
||||
|
||||
```vb
|
||||
|
||||
DIM CrLf AS STRING * 2 'define as 2 byte STRING
|
||||
CrLf = CHR$(13) + CHR$(10) 'carriage return & line feed
|
||||
|
||||
_CLIPBOARD$ = "This is line 1" + CrLf + "This is line 2"
|
||||
PRINT _CLIPBOARD$ 'display what is in the clipboard
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
This is line 1
|
||||
|
||||
This is line 2
|
||||
|
||||
```
|
||||
|
||||
> *Note:* The text in the clipboard could also be sent to a file using [PRINT (file statement)](PRINT-(file-statement)) [_CLIPBOARD$](_CLIPBOARD$).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLIPBOARD$](_CLIPBOARD$) (function)
|
||||
* [_CLIPBOARDIMAGE (function)](_CLIPBOARDIMAGE-(function)), [_CLIPBOARDIMAGE](_CLIPBOARDIMAGE) (statement)
|
||||
* [CHR$](CHR$), [ASCII](ASCII) (code table)
|
150
wiki/_CLIPBOARD$.md
Normal file
150
wiki/_CLIPBOARD$.md
Normal file
|
@ -0,0 +1,150 @@
|
|||
The [_CLIPBOARD$](_CLIPBOARD$) function returns the current operating system's clipboard contents as a [STRING](STRING).
|
||||
|
||||
## Syntax
|
||||
|
||||
> result$ = [_CLIPBOARD$](_CLIPBOARD$)
|
||||
|
||||
## Description
|
||||
|
||||
* Text returned can contain the entire contents of a copied file or web page or text from a previous [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement)) statement.
|
||||
* The string returned can also contain formatting like CRLF ([CHR$](CHR$)(13) + [CHR$](CHR$)(10)) end of line characters.
|
||||
* The clipboard can be used to copy, paste and communicate between running programs.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Passing a string value between two running programs no matter where they are located.
|
||||
|
||||
> *Program1:*
|
||||
|
||||
```vb
|
||||
|
||||
PRINT "Start Program2 to read your text entries! Empty entry quits!"
|
||||
_CLIPBOARD$ = "Entry program started!" 'set clipboard initially
|
||||
|
||||
DO
|
||||
LINE INPUT "Enter some text to send to other program: ", text$
|
||||
IF text$ = "" THEN EXIT DO
|
||||
_CLIPBOARD$ = text$
|
||||
LOOP
|
||||
|
||||
SYSTEM
|
||||
|
||||
```
|
||||
|
||||
> *Program2:*
|
||||
|
||||
```vb
|
||||
|
||||
PRINT "Enter text in Program1 and this program will read it. Esc key quits!"
|
||||
|
||||
DO: _LIMIT 100
|
||||
text$ = _CLIPBOARD$ 'function returns clipboard contents
|
||||
IF LEN(text$) THEN
|
||||
PRINT text$
|
||||
_CLIPBOARD$ = "" 'clear clipboard after a read
|
||||
END IF
|
||||
LOOP UNTIL INKEY$ = CHR$(27)
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* Compile and run both programs at once to see the interaction. You could also run them on different paths.
|
||||
|
||||
A minimized program that pops up when Ctrl + Shift is entered anytime in **Windows** and adds clipboard text to be Pasted:
|
||||
|
||||
```vb
|
||||
|
||||
'"ClippyBoard" program uses GetKeyState Win API to monitor a specific key combination.
|
||||
'This demo will maximize the window and focus on program when Shift+A is pressed.
|
||||
|
||||
DECLARE DYNAMIC LIBRARY "user32"
|
||||
FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process handle by title
|
||||
FUNCTION GetKeyState% (BYVAL nVirtKey AS LONG) 'Windows virtual key presses
|
||||
FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
|
||||
FUNCTION GetForegroundWindow%& 'find currently focused process handle
|
||||
FUNCTION SetForegroundWindow& (BYVAL hwnd AS _OFFSET) 'set foreground window process(focus)
|
||||
END DECLARE
|
||||
|
||||
title$ = "Clippy Clipboard (Ctrl+Shift)" 'title of program window
|
||||
_TITLE title$ 'set program title
|
||||
hwnd%& = FindWindowA(0, title$ + CHR$(0)) 'find this program's process handle
|
||||
|
||||
SCREEN 13
|
||||
_SCREENMOVE _MIDDLE
|
||||
|
||||
COLOR 10: PRINT
|
||||
PRINT " Press Ctrl+Shift to see clipboard menu."
|
||||
|
||||
_DELAY 4
|
||||
x& = ShowWindow&(hwnd%&, 2) 'minimize
|
||||
|
||||
DO: _LIMIT 30 'save CPU usage while waiting for key press
|
||||
|
||||
IF GetKeyState(16) < 0 AND GetKeyState(17) < 0 THEN '<==== Shift+A
|
||||
FGwin%& = GetForegroundWindow%& 'get current process in focus
|
||||
y& = ShowWindow&(hwnd%&, 1) 'maximize minimized program
|
||||
|
||||
IF FGwin%& <> hwnd%& THEN z& = SetForegroundWindow&(hwnd%&) 'set focus when necessary
|
||||
_DELAY 1
|
||||
GetKey
|
||||
x& = ShowWindow&(hwnd%&, 2) 'minimize after letter key entry
|
||||
COLOR 10: PRINT
|
||||
PRINT " Press Ctrl+Shift to see clipboard menu."
|
||||
END IF
|
||||
LOOP
|
||||
|
||||
SUB GetKey
|
||||
CLS
|
||||
COLOR 12: PRINT: PRINT _CLIPBOARD$
|
||||
DO: LOOP UNTIL INKEY$ = ""
|
||||
_DELAY 1
|
||||
CLS
|
||||
COLOR 11: PRINT "Select a letter clipboard option:"
|
||||
PRINT
|
||||
PRINT "A = Address"
|
||||
PRINT "C = Cell phone"
|
||||
PRINT "E = Email"
|
||||
PRINT "F = First Name"
|
||||
PRINT "H = Home phone"
|
||||
PRINT "L = Last Name"
|
||||
PRINT "N = Name"
|
||||
PRINT "M = MAC address"
|
||||
PRINT "P = Password"
|
||||
PRINT "W = Work name"
|
||||
PRINT "X = QUIT!"
|
||||
PRINT "Z = Zip code"
|
||||
COLOR 14: PRINT
|
||||
PRINT "Another letter will skip or X = EXIT!"
|
||||
|
||||
K$ = UCASE$(INPUT$(1))
|
||||
|
||||
SELECT CASE K$ 'The following text should be your personal user info:
|
||||
CASE "A": _CLIPBOARD$ = "my address"
|
||||
CASE "C": _CLIPBOARD$ = "cell number"
|
||||
CASE "E": _CLIPBOARD$ = "myemail"
|
||||
CASE "F": _CLIPBOARD$ = "formal name"
|
||||
CASE "H": _CLIPBOARD$ = "home number"
|
||||
CASE "L": _CLIPBOARD$ = "lastname"
|
||||
CASE "M": _CLIPBOARD$ = "modempassword"
|
||||
CASE "N": _CLIPBOARD$ = "name"
|
||||
CASE "P": _CLIPBOARD$ = "password"
|
||||
CASE "X": END
|
||||
CASE "Z": _CLIPBOARD$ = "zipcode"
|
||||
END SELECT
|
||||
CLS
|
||||
PRINT
|
||||
PRINT
|
||||
COLOR 14: PRINT _CLIPBOARD$
|
||||
BEEP
|
||||
_DELAY 2
|
||||
END SUB
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* The program will run minimized until Ctrl + Shift is entered and will pop up to ask for a letter choice that contains the text you want in the clipboard. More letter choices can be added. Text can be pasted into a web page or entry box and the program will minimize until it is needed later. The program uses very little resources!
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement))
|
||||
* [_CLIPBOARDIMAGE (function)](_CLIPBOARDIMAGE-(function)), [_CLIPBOARDIMAGE](_CLIPBOARDIMAGE) (statement)
|
50
wiki/_CLIPBOARDIMAGE-(function).md
Normal file
50
wiki/_CLIPBOARDIMAGE-(function).md
Normal file
|
@ -0,0 +1,50 @@
|
|||
The [_CLIPBOARDIMAGE (function)](_CLIPBOARDIMAGE-(function)) function pastes an image from the clipboard into a new 32-bit image in memory.
|
||||
|
||||
## Syntax
|
||||
|
||||
> newImageHandle& = [_CLIPBOARDIMAGE (function)](_CLIPBOARDIMAGE-(function))
|
||||
|
||||
## Description
|
||||
|
||||
* When the paste operation is successful, newImageHandle& will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted.
|
||||
* Use [_FREEIMAGE](_FREEIMAGE) to free the memory used by newImageHandle& when it's no longer needed by your program.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170906/64 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Monitoring the clipboard for new images copied from other programs:
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(800, 600, 32)
|
||||
DO
|
||||
CLS
|
||||
COLOR _RGB32(177, 177, 177)
|
||||
PRINT "Monitoring clipboard..."
|
||||
IF img& < -1 THEN _FREEIMAGE img&
|
||||
img& = _CLIPBOARDIMAGE
|
||||
IF img& < -1 THEN
|
||||
PRINT "Image found:"
|
||||
COLOR _RGB32(255, 255, 255)
|
||||
PRINT "Width :"; _WIDTH(img&)
|
||||
PRINT "Height:"; _HEIGHT(img&)
|
||||
w = _WIDTH / 2 - _WIDTH(img&) / 2
|
||||
IF w < 0 THEN w = 0
|
||||
_PUTIMAGE (w, CSRLIN * _FONTHEIGHT), img&
|
||||
ELSE
|
||||
PRINT "No image found."
|
||||
END IF
|
||||
_DISPLAY
|
||||
_LIMIT 10
|
||||
LOOP
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLIPBOARDIMAGE](_CLIPBOARDIMAGE) (statement - used to copy an image to the clipboard)
|
||||
* [_CLIPBOARD$](_CLIPBOARD$), [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement)) (used to copy/paste text)
|
55
wiki/_CLIPBOARDIMAGE.md
Normal file
55
wiki/_CLIPBOARDIMAGE.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
The [_CLIPBOARDIMAGE](_CLIPBOARDIMAGE) statement copies a valid QB64 image to the clipboard.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CLIPBOARDIMAGE](_CLIPBOARDIMAGE) = existingImageHandle&
|
||||
|
||||
## Description
|
||||
|
||||
* existingImageHandle& is a valid handle to a graphic QB64 image in memory, created with [_NEWIMAGE](_NEWIMAGE), [_LOADIMAGE](_LOADIMAGE) or [_COPYIMAGE](_COPYIMAGE).
|
||||
* You can pass [_SOURCE](_SOURCE), [_DEST](_DEST) or [_DISPLAY](_DISPLAY) to copy the current source, destination or active display pages, as long as they are valid graphic images.
|
||||
* SCREEN 0 handles (created either with [_NEWIMAGE](_NEWIMAGE) or passed using _DEST while in a text screen) are not valid and will create an [ERROR Codes](ERROR-Codes) or [ERROR Codes](ERROR-Codes) error.
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170906/64 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Create a sample image and copy it to the clipboard:
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(800, 600, 32)
|
||||
|
||||
'Create image in memory:
|
||||
canvas& = _NEWIMAGE(300, 200, 32)
|
||||
_DEST canvas&
|
||||
|
||||
'Draw some random rectangles:
|
||||
RANDOMIZE TIMER
|
||||
FOR i = 1 TO 100
|
||||
LINE (-100 + RND * _WIDTH, -100 + RND * _HEIGHT)-STEP(RND * 150, RND * 150), _RGB(RND * 255, RND * 255, RND * 255), BF
|
||||
NEXT
|
||||
LINE (0, 0)-(_WIDTH - 1, _HEIGHT - 1), _RGB(255, 255, 255), B
|
||||
COLOR _RGB(0, 0, 0), _RGB(255, 255, 255)
|
||||
m$ = " Hello, world! "
|
||||
_PRINTSTRING (_WIDTH / 2 - _PRINTWIDTH(m$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2), m$
|
||||
|
||||
'Show the image:
|
||||
_DEST 0
|
||||
_PUTIMAGE (_WIDTH / 2 - _WIDTH(canvas&) / 2, _HEIGHT / 2 - _HEIGHT(canvas&) / 2), canvas&
|
||||
PRINT "Image generated."
|
||||
|
||||
'Copy to the clipboard:
|
||||
_CLIPBOARDIMAGE = canvas&
|
||||
|
||||
PRINT "Image copied to clipboard."
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CLIPBOARDIMAGE (function)](_CLIPBOARDIMAGE-(function)) (function - used to paste an image from the clipboard)
|
||||
* [_CLIPBOARD$](_CLIPBOARD$), [_CLIPBOARD$ (statement)](_CLIPBOARD$-(statement)) (used to copy/paste text)
|
31
wiki/_COMMANDCOUNT.md
Normal file
31
wiki/_COMMANDCOUNT.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
The [_COMMANDCOUNT](_COMMANDCOUNT) function returns the number or arguments passed from the command line to the [COMMAND$](COMMAND$) function.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result& = [_COMMANDCOUNT](_COMMANDCOUNT)
|
||||
|
||||
## Description
|
||||
|
||||
* The function returns the number of arguments passed from the command line to a program when it's executed.
|
||||
* Arguments are spaced as separate numerical or text values. Spaced text inside of quotes is considered as one argument.
|
||||
* In C, this function would generally be regarded as 'argc' when the main program is defined as the following: **int main(int argc, char *argv[])**
|
||||
|
||||
## Example(s)
|
||||
|
||||
The code below gets the number of parameters passed to our program from the command line with _COMMANDCOUNT:
|
||||
|
||||
```vb
|
||||
|
||||
limit = _COMMANDCOUNT
|
||||
FOR i = 1 TO limit
|
||||
PRINT COMMAND$(i)
|
||||
NEXT
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* If we start *ThisProgram.exe* from the command window with **ThisProgram -l "loadfile.txt" -s "savefile.txt"**, the _COMMANDCOUNT would be 4, "-l", "loadfile.txt", "-s", "savefile.txt" command arguments passed to the program, which we could then read separately with COMMAND$(n).
|
||||
|
||||
## See Also
|
||||
|
||||
* [COMMAND$](COMMAND$)
|
||||
* [SHELL](SHELL)
|
22
wiki/_CONNECTED.md
Normal file
22
wiki/_CONNECTED.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
The [_CONNECTED](_CONNECTED) function returns the status of a TCP/IP connection handle.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result& = [_CONNECTED](_CONNECTED)(connectionHandle&)
|
||||
|
||||
## Description
|
||||
|
||||
* The handle can come from the [_OPENHOST](_OPENHOST), [OPENCLIENT](OPENCLIENT) or [_OPENCONNECTION](_OPENCONNECTION) QB64 TCP/IP functions.
|
||||
* Returns -1 if still connected or 0 if connection has ended/failed.
|
||||
* Do not rely solely on this function to check for ending communication.
|
||||
* Use "time-out" checking as well and [CLOSE](CLOSE) any suspect connections.
|
||||
* If this function indicates the handle is not connected, any unread messages can still be read using [GET (TCP/IP statement)](GET-(TCP-IP-statement)).
|
||||
* Even if this function indicates the handle is not connected, it is important to [CLOSE](CLOSE) the connection anyway or important resources cannot be reallocated.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_OPENCONNECTION](_OPENCONNECTION)
|
||||
* [_OPENHOST](_OPENHOST)
|
||||
* [_OPENCLIENT](_OPENCLIENT)
|
||||
* [_CONNECTIONADDRESS$](_CONNECTIONADDRESS$)
|
||||
* [Downloading Files](Downloading-Files)
|
1
wiki/_CONNECTIONADDRESS$.md
Normal file
1
wiki/_CONNECTIONADDRESS$.md
Normal file
|
@ -0,0 +1 @@
|
|||
See [_CONNECTIONADDRESS](_CONNECTIONADDRESS).
|
44
wiki/_CONNECTIONADDRESS.md
Normal file
44
wiki/_CONNECTIONADDRESS.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
The [_CONNECTIONADDRESS](_CONNECTIONADDRESS) function returns a connected user's [STRING](STRING) IP address value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result$ = [_CONNECTIONADDRESS](_CONNECTIONADDRESS)](connectionHandle&)
|
||||
|
||||
## Description
|
||||
|
||||
* The handle can come from the [_OPENHOST](_OPENHOST), [OPENCLIENT](OPENCLIENT) or [_OPENCONNECTION](_OPENCONNECTION) QB64 TCP/IP functions.
|
||||
* For **[_OPENHOST](_OPENHOST)s**: It may return "TCP/IP:8080:213.23.32.5" where 8080 is the port it is listening on and 213.23.32.5 is the global IP address which any computer connected to the internet could use to locate your computer. If a connection to the internet is unavailable or your firewall blocks it, it returns your 'local IP' address (127.0.0.1). You might like to store this address somewhere where other computers can find it and connect to your host. Dynamic IPs which can change will need to be updated.
|
||||
* For **[_OPENCLIENT](_OPENCLIENT)s**: It may return "TCP/IP:8080:213.23.32.5" where 8080 is the port it used to connect to the listening host and 213.23.32.5 is the IP address of the host name it resolved.
|
||||
* For **[_OPENCONNECTION](_OPENCONNECTION)s** (from clients): It may return "TCP/IP:8080:34.232.321.25" where 8080 was the host listening port it connected to and 34.232.321.25 is the IP address of the client that connected. This is very useful because the host can log the IP address of clients for future reference (or banning, for example).
|
||||
* The $ symbol is optional for compatibility with older versions.
|
||||
|
||||
## Example(s)
|
||||
|
||||
A Host logging new chat clients in a Chat program. See the [_OPENHOST](_OPENHOST) example for the rest of the code used.
|
||||
|
||||
```vb
|
||||
|
||||
f = FREEFILE
|
||||
OPEN "ChatLog.dat" FOR APPEND AS #f ' code at start of host section before DO loop.
|
||||
|
||||
newclient = _OPENCONNECTION(host) ' receive any new client connection handles
|
||||
IF newclient THEN
|
||||
numclients = numclients + 1 ' increment index
|
||||
Users(numclients) = newclient ' place handle into array
|
||||
IP$ = _CONNECTIONADDRESS(newclient)
|
||||
PRINT IP$ + " has joined." ' displayed to Host only
|
||||
PRINT #f, IP$, numclients ' print info to a log file
|
||||
PRINT #Users(numclients),"Welcome!" ' from Host to new clients only
|
||||
END IF
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* The function returns the new client's IP address to the IP$ variable. Prints the IP and the original login position to a log file. The information can later be used by the host for reference if necessary. The host could set up a ban list too.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_OPENCONNECTION](_OPENCONNECTION)
|
||||
* [_OPENHOST](_OPENHOST)
|
||||
* [_OPENCLIENT](_OPENCLIENT)
|
||||
* [_CONNECTED](_CONNECTED)
|
||||
* [WGET](WGET) (HTTP and FTP file transfer)
|
64
wiki/_CONSOLE.md
Normal file
64
wiki/_CONSOLE.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
The [_CONSOLE](_CONSOLE) statement can be used to turn a console window ON/OFF.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CONSOLE](_CONSOLE) {OFF|ON}
|
||||
> _DEST [_CONSOLE](_CONSOLE)
|
||||
|
||||
* [_CONSOLE](_CONSOLE) OFF or ON must be used after the [$CONSOLE]($CONSOLE) [Metacommand](Metacommand) has established that a console window is desired.
|
||||
* [_CONSOLE](_CONSOLE) OFF turns the console window off once a console has been established using [$CONSOLE]($CONSOLE):ON or ONLY.
|
||||
* [_CONSOLE](_CONSOLE) ON should only be used after the console window has been turned OFF previously.
|
||||
* [_DEST](_DEST) [_CONSOLE](_CONSOLE) can be used to send screen output to the console window using QB64 commands such as [PRINT](PRINT).
|
||||
* [_SCREENHIDE](_SCREENHIDE) or [_SCREENSHOW](_SCREENSHOW) can be used to hide or display the main program window.
|
||||
* The [$SCREENHIDE]($SCREENHIDE) [Metacommand](Metacommand) can hide the main program window throughout a program when only the console is used.
|
||||
* **Note:** Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
|
||||
* To copy console text output, right click the title bar and select *Edit* for *Mark* to highlight and repeat to *Copy*.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Hiding and displaying a console window. Use [_DELAY](_DELAY) to place console in front of main program window.
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE
|
||||
_CONSOLE OFF 'close original console
|
||||
_DELAY 2
|
||||
_CONSOLE ON 'place console above program window
|
||||
|
||||
_DEST _CONSOLE
|
||||
INPUT "Enter your name: ", nme$ 'get program input
|
||||
_CONSOLE OFF 'close console
|
||||
|
||||
_DEST 0 'destination program window
|
||||
PRINT nme$
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* The [_DEST](_DEST) must be changed with [_DEST](_DEST) [_CONSOLE](_CONSOLE) to get [INPUT](INPUT) from the [$CONSOLE]($CONSOLE) screen.
|
||||
|
||||
[_CONSOLETITLE](_CONSOLETITLE) can be used to create a console title, but it must be redone every time the console window is restored once turned off:
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE
|
||||
|
||||
_CONSOLETITLE "firstone"
|
||||
_DELAY 10
|
||||
|
||||
_CONSOLE OFF
|
||||
_DELAY 10
|
||||
|
||||
_CONSOLE ON
|
||||
_CONSOLETITLE "secondone"
|
||||
|
||||
```
|
||||
|
||||
> *Note:* Some versions of Windows may display the program path or Administrator: prefix in console title bars.
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [_CONSOLETITLE](_CONSOLETITLE)
|
||||
* [$SCREENHIDE]($SCREENHIDE), [$SCREENSHOW]($SCREENSHOW) (QB64 [Metacommand](Metacommand)s)
|
||||
* [_SCREENHIDE](_SCREENHIDE), [_SCREENSHOW](_SCREENSHOW)
|
||||
* [_DEST](_DEST)
|
42
wiki/_CONSOLEINPUT.md
Normal file
42
wiki/_CONSOLEINPUT.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
The [_CONSOLEINPUT](_CONSOLEINPUT) function is used to monitor any new mouse or keyboard input coming from a $CONSOLE window. It must be called in order for [_CINP](_CINP) to return valid values. Windows-only.
|
||||
|
||||
## Syntax
|
||||
|
||||
> infoExists%% = [_CONSOLEINPUT](_CONSOLEINPUT)
|
||||
|
||||
## Description
|
||||
|
||||
* Returns 1 if new keyboard information is available, 2 if mouse information is available, otherwise it returns 0.
|
||||
* Must be called before reading any of the other mouse functions and before reading [_CINP](_CINP).
|
||||
* To clear all previous input data, read [_CONSOLEINPUT](_CONSOLEINPUT) in a loop until it returns 0.
|
||||
* To capture mouse input, turn off Quick Edit in the settings of command prompt and use [_SOURCE](_SOURCE) [_CONSOLE](_CONSOLE).
|
||||
* [Keywords currently not supported](Keywords-currently-not-supported-by-QB64).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Reading individual key strokes from a console window (Windows).
|
||||
|
||||
```vb
|
||||
|
||||
$CONSOLE:ONLY
|
||||
_DEST _CONSOLE: _SOURCE _CONSOLE
|
||||
|
||||
PRINT "Press any key, and I'll give you the scan code for it. <ESC> quits the demo."
|
||||
PRINT
|
||||
PRINT
|
||||
DO
|
||||
x = _CONSOLEINPUT
|
||||
IF x = 1 THEN 'read only keyboard input ( = 1)
|
||||
c = _CINP
|
||||
PRINT c;
|
||||
END IF
|
||||
LOOP UNTIL c = 1
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [_CONSOLE](_CONSOLE)
|
||||
* [_CINP](_CINP), [Keyboard scancodes](Keyboard-scancodes)
|
||||
* [_MOUSEX](_MOUSEX), [_MOUSEY](_MOUSEY), [_MOUSEBUTTON](_MOUSEBUTTON), [_MOUSEWHEEL](_MOUSEWHEEL)
|
34
wiki/_CONSOLETITLE.md
Normal file
34
wiki/_CONSOLETITLE.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
The [_CONSOLETITLE](_CONSOLETITLE) statement sets the console window's title-bar text.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CONSOLETITLE](_CONSOLETITLE) text$
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* *text$* can be any literal or variable [STRING](STRING) value.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Hiding the main program window while displaying the console window with a title.
|
||||
|
||||
```vb
|
||||
|
||||
$SCREENHIDE
|
||||
_DELAY 4
|
||||
$CONSOLE
|
||||
_CONSOLETITLE "Error Log"
|
||||
|
||||
_DEST _CONSOLE
|
||||
PRINT "Errors go here! (fyi, this line is not an error)"
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* You can also use [SHELL](SHELL) "title consoletitle" to set the title of the console window. However, the recommended practice is to use [_CONSOLETITLE](_CONSOLETITLE).
|
||||
|
||||
## See Also
|
||||
|
||||
* [$CONSOLE]($CONSOLE), [_CONSOLE](_CONSOLE)
|
||||
* [$SCREENHIDE]($SCREENHIDE), [$SCREENSHOW]($SCREENSHOW)
|
||||
* [_SCREENHIDE](_SCREENHIDE), [_SCREENSHOW](_SCREENSHOW)
|
33
wiki/_CONTINUE.md
Normal file
33
wiki/_CONTINUE.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
The [_CONTINUE](_CONTINUE) statement is used in a [DO...LOOP](DO...LOOP), [WHILE...WEND](WHILE...WEND) or [FOR...NEXT](FOR...NEXT) block to skip the remaining lines of code in a block (without exiting it) and start the next iteration. It works as a shortcut to a [GOTO](GOTO), but without the need for a [line numbers](line-numbers).
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CONTINUE](_CONTINUE)
|
||||
|
||||
## Availability
|
||||
|
||||
* Build 20170628/55 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
FOR i = 1 TO 10
|
||||
IF i = 5 THEN _CONTINUE
|
||||
PRINT i;
|
||||
NEXT
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
1 2 3 4 6 7 8 9 10
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [DO...LOOP](DO...LOOP)
|
||||
* [WHILE...WEND](WHILE...WEND)
|
||||
* [FOR...NEXT](FOR...NEXT)
|
||||
* [GOTO](GOTO)
|
18
wiki/_CONTROLCHR-(function).md
Normal file
18
wiki/_CONTROLCHR-(function).md
Normal file
|
@ -0,0 +1,18 @@
|
|||
The [_CONTROLCHR (function)](_CONTROLCHR-(function)) function returns the current state of the [_CONTROLCHR](_CONTROLCHR) statement as -1 when OFF and 0 when ON.
|
||||
|
||||
## Syntax
|
||||
|
||||
> status% = [_CONTROLCHR (function)](_CONTROLCHR-(function))
|
||||
|
||||
## Description
|
||||
|
||||
* The function requires no parameters.
|
||||
* Default return is 0 when the _CONTROLCHR statement has never been used previous to a function read.
|
||||
* When the statement has been use to turn OFF control characters, the characters can be printed as text without screen formatting.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CONTROLCHR](_CONTROLCHR)
|
||||
* [CHR$](CHR$), [ASC](ASC)
|
||||
* [INKEY$](INKEY$), [_KEYHIT](_KEYHIT)
|
||||
* [ASCII](ASCII) (codes)
|
48
wiki/_CONTROLCHR.md
Normal file
48
wiki/_CONTROLCHR.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
The [_CONTROLCHR](_CONTROLCHR) statement can be used to turn OFF control character attributes and allow them to be printed.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_CONTROLCHR](_CONTROLCHR) {OFF|ON}
|
||||
|
||||
## Description
|
||||
|
||||
* The [OFF](OFF) clause allows control characters 0 to 31 to be printed and not format printing as normal text characters.
|
||||
* For example: **PRINT CHR$(13)** 'will not move the cursor to the next line and **PRINT CHR$(9)** 'will not tab.
|
||||
* The default [ON](ON) statement allows [ASCII](ASCII) to be used as control commands where some will not print or will format prints.
|
||||
* **Note:** File prints may be affected also when using Carriage Return or Line Feed/Form Feed formatting.
|
||||
* The QB64 IDE may allow Alt + number pad character entries, but they must be inside of [STRING](STRING) values. Otherwise the IDE may not recognize them.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Printing the 255 [ASCII](ASCII) characters in [SCREEN](SCREEN) 0 with 32 colors.
|
||||
|
||||
```vb
|
||||
|
||||
DIM i AS _UNSIGNED _BYTE
|
||||
WIDTH 40, 25
|
||||
CLS
|
||||
_CONTROLCHR OFF
|
||||
i = 0
|
||||
DO
|
||||
PRINT CHR$(i);
|
||||
i = i + 1
|
||||
IF (i AND &HF) = 0 THEN PRINT
|
||||
LOOP WHILE i
|
||||
LOCATE 1, 20
|
||||
DO
|
||||
COLOR i AND &HF OR (i AND &H80) \ &H8, (i AND &H70) \ &H10
|
||||
PRINT CHR$(i);
|
||||
i = i + 1
|
||||
IF (i AND &HF) = 0 THEN LOCATE 1 + i \ &H10, 20
|
||||
LOOP WHILE i
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CONTROLCHR (function)](_CONTROLCHR-(function))
|
||||
* [CHR$](CHR$), [ASC](ASC)
|
||||
* [INKEY$](INKEY$), [_KEYHIT](_KEYHIT)
|
||||
* [ASCII](ASCII) (codes)
|
||||
* [ASCII](ASCII)
|
75
wiki/_COPYIMAGE.md
Normal file
75
wiki/_COPYIMAGE.md
Normal file
|
@ -0,0 +1,75 @@
|
|||
The [_COPYIMAGE](_COPYIMAGE) function creates an identical designated image in memory with a different negative [LONG](LONG) handle value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> newhandle& = [_COPYIMAGE](_COPYIMAGE)[(imageHandle&[, mode%)]]
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* The [LONG](LONG) *newhandle&* value returned will be different than the source handle value supplied.
|
||||
* If *imageHandle&* parameter is omitted or zero is designated, the current software [_DEST](_DEST) screen or image is copied.
|
||||
* If 1 is designated instead of an *imageHandle&*, it designates the last OpenGL hardware surface to copy.
|
||||
* *Mode* 32 can be used to convert 256 color images to 32 bit colors.
|
||||
* *Mode* 33 images are hardware accelerated in **version 1.000 and up**, and are created using [_LOADIMAGE](_LOADIMAGE) or [_COPYIMAGE](_COPYIMAGE).
|
||||
|
||||
## Description
|
||||
|
||||
* The function copies any image or screen handle to a new and unique negative [LONG](LONG) handle value.
|
||||
* Valid copy handles are less than -1. Invalid handles return -1 or 0 if it was never created.
|
||||
* Every attribute of the passed image or program screen is copied to a new handle value in memory.
|
||||
* **32 bit screen surface backgrounds (black) have zero [_ALPHA](_ALPHA) so that they are transparent when placed over other surfaces.**
|
||||
|
||||
> Use [CLS](CLS) or [_DONTBLEND](_DONTBLEND) to make a new surface background [_ALPHA](_ALPHA) 255 or opaque.
|
||||
|
||||
* **Images are not deallocated when the [SUB](SUB) or [FUNCTION](FUNCTION) they are created in ends. Free them with [_FREEIMAGE](_FREEIMAGE).**
|
||||
* **It is important to free discarded images with [_FREEIMAGE](_FREEIMAGE) to prevent PC memory allocation errors!**
|
||||
* **Do not try to free image handles currently being used as the active [SCREEN](SCREEN). Change screen modes first.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Restoring a Legacy SCREEN using the _COPYIMAGE return value.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 13
|
||||
CIRCLE (160, 100), 100, 40
|
||||
DO: SLEEP: LOOP UNTIL INKEY$ <> ""
|
||||
|
||||
'backup screen before changing SCREEN mode
|
||||
oldmode& = _COPYIMAGE(0) 'the 0 value designates the current destination SCREEN
|
||||
|
||||
s& = _NEWIMAGE(800, 600, 32)
|
||||
SCREEN s&
|
||||
LINE (100, 100)-(500, 500), _RGB(0, 255, 255), BF
|
||||
DO: SLEEP: LOOP UNTIL INKEY$ <> ""
|
||||
|
||||
SCREEN oldmode& 'restore original screen
|
||||
IF s& < -1 THEN _FREEIMAGE s&
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
> *Note:* Only free valid handle values with [_FREEIMAGE](_FREEIMAGE) AFTER a new [SCREEN](SCREEN) mode is being used by the program.
|
||||
|
||||
Program that copies desktop to a hardware image to form a 3D triangle:
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
my_hardware_handle = _COPYIMAGE(_SCREENIMAGE, 33) 'take a screenshot and use it as our texture
|
||||
_MAPTRIANGLE (0, 0)-(500, 0)-(250, 500), my_hardware_handle TO_
|
||||
(-1, 0, -1)-(1, 0, -1)-(0, 5, -10), , _SMOOTH
|
||||
_DISPLAY
|
||||
DO: _LIMIT 30: LOOP UNTIL INKEY$ <> ""
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LOADIMAGE](_LOADIMAGE), [_NEWIMAGE](_NEWIMAGE)
|
||||
* [_PUTIMAGE](_PUTIMAGE), [_MAPTRIANGLE](_MAPTRIANGLE)
|
||||
* [_SOURCE](_SOURCE), [_DEST](_DEST)
|
||||
* [_FREEIMAGE](_FREEIMAGE)
|
||||
* [FILELIST$ (function)](FILELIST$-(function)) (Demo of _COPYIMAGE)
|
||||
* [_DISPLAYORDER](_DISPLAYORDER)
|
||||
* [Hardware images](Hardware-images)
|
26
wiki/_COPYPALETTE.md
Normal file
26
wiki/_COPYPALETTE.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
The [_COPYPALETTE](_COPYPALETTE) statement copies the color palette intensities from one 4 or 8 BPP image to another image or a [_NEWIMAGE](_NEWIMAGE) screen page using 256 or less colors.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_COPYPALETTE](_COPYPALETTE) [sourceImageHandle&[, destinationImageHandle&]]
|
||||
|
||||
## Description
|
||||
|
||||
* Palette Intensity settings are **not** used by 24/32 bit images. Use only with 4 or 8 BPP images.
|
||||
* [_PIXELSIZE](_PIXELSIZE) function returns 1 to indicate that _COPYPALETTE can be used. 4 indicates 24/32 bit images.
|
||||
* If sourceImageHandle& is omitted, it is assumed to be the current read page.
|
||||
* If destinationImageHandle& is omitted, it is assumed to be the current write page.
|
||||
* If either of the images specified by sourceImageHandle& or destinationImageHandle& do not use a palette, an [ERROR Codes](ERROR-Codes) error is returned.
|
||||
* If either sourceImageHandle& or destinationImageHandle& is an invalid handle, an [ERROR Codes](ERROR-Codes) error is returned.
|
||||
* When loading 4 or 8 BPP image files, it is necessary to adopt the color palette of the image or it may not have the correct colors!
|
||||
|
||||
## Example(s)
|
||||
|
||||
* See the example in [SAVEIMAGE](SAVEIMAGE).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LOADIMAGE](_LOADIMAGE)
|
||||
* [_PIXELSIZE](_PIXELSIZE)
|
||||
* [_PALETTECOLOR](_PALETTECOLOR), [_PALETTECOLOR (function)](_PALETTECOLOR-(function))
|
||||
* [PALETTE](PALETTE), [Images](Images)
|
58
wiki/_CV.md
Normal file
58
wiki/_CV.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
The [_CV](_CV) function is used to convert [_MK$](_MK$), [ASCII](ASCII), [STRING](STRING) values to numerical values.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result = [_CV](_CV)(numericalType, MKstringValue$)
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* numericalType is any number type: [INTEGER](INTEGER), [LONG](LONG), [SINGLE](SINGLE), [DOUBLE](DOUBLE), [_INTEGER64](_INTEGER64), [_FLOAT](_FLOAT), [_BYTE](_BYTE) or [_OFFSET](_OFFSET).
|
||||
* Integer, Long, Byte and Bit values can be signed or [_UNSIGNED](_UNSIGNED).
|
||||
* The MKstringvalue$ parameter must be a string value generated by [_MK$](_MK$)
|
||||
|
||||
## Description
|
||||
|
||||
* The MKstringvalue$ value type must match the numerical type parameter used.
|
||||
* [_MK$](_MK$) [STRING](STRING) values consist of [ASCII](ASCII) characters in the same byte length as the number value type.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Using the _MK$ and _CV functions:
|
||||
|
||||
```vb
|
||||
|
||||
DIM i64 AS _INTEGER64
|
||||
DIM i64str AS STRING
|
||||
|
||||
i64 = 2 ^ 61
|
||||
i64str = _MK$(_INTEGER64, i64)
|
||||
|
||||
PRINT "I64:"; i64
|
||||
PRINT "_MK$: "; i64str
|
||||
|
||||
i64 = _CV(_INTEGER64, i64str)
|
||||
PRINT "_CV:"; i64
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
I64: 2305843009213693952
|
||||
_MK$:
|
||||
_CV: 2305843009213693952
|
||||
|
||||
```
|
||||
|
||||
> The _MK$ string result may not print anything to the screen, as in the example above, unless [_CONTROLCHR](_CONTROLCHR) is set to OFF.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_MK$](_MK$) (QB64 string conversion function)
|
||||
* [MKI$](MKI$), [CVI](CVI), [INTEGER](INTEGER)
|
||||
* [MKL$](MKL$), [CVL](CVL), [LONG](LONG)
|
||||
* [MKS$](MKS$), [CVS](CVS), [SINGLE](SINGLE)
|
||||
* [MKD$](MKD$), [CVD](CVD), [DOUBLE](DOUBLE)
|
||||
* [MKSMBF$](MKSMBF$), [CVSMBF](CVSMBF) (Microsoft Binary Format)
|
||||
* [MKDMBF$](MKDMBF$), [CVDMBF](CVDMBF) (Microsoft Binary Format)
|
||||
* [PDS (7.1) Procedures](PDS-(7.1)-Procedures)
|
||||
* [_CONTROLCHR](_CONTROLCHR)
|
51
wiki/_CWD$.md
Normal file
51
wiki/_CWD$.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
The [_CWD$](_CWD$) function returns the current working directory path as a string value without a trailing path separator.
|
||||
|
||||
## Syntax
|
||||
|
||||
> workingDirectory$ = [_CWD$](_CWD$)
|
||||
|
||||
## Description
|
||||
|
||||
* By default, the initial working directory path is usually the same as the directory of the executable file run.
|
||||
* The current working directory can be changed with the [CHDIR](CHDIR) or [SHELL](SHELL) command; CHDIR sets it, _CWD$ returns it.
|
||||
* Path returns will change only when the working path has changed. When in C:\ and run QB64\cwd.exe, it will still return C:\
|
||||
* The current working directory string can be used in [OPEN](OPEN) statements and [SHELL](SHELL) commands that deal with files.
|
||||
* Works in Windows, macOS and Linux. [_OS$](_OS$) can be used by a program to predict the proper slash separations in different OS's.
|
||||
|
||||
## Error(s)
|
||||
|
||||
* If an error occurs while obtaining the working directory from the operating system, [ERROR Codes](ERROR-Codes) 51 (Internal Error) will be generated.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Get the current working directory, and move around the file system:
|
||||
|
||||
```vb
|
||||
|
||||
startdir$ = _CWD$
|
||||
PRINT "We started at "; startdir$
|
||||
MKDIR "a_temporary_dir"
|
||||
CHDIR "a_temporary_dir"
|
||||
PRINT "We are now in "; _CWD$
|
||||
CHDIR startdir$
|
||||
PRINT "And now we're back in "; _CWD$
|
||||
RMDIR "a_temporary_dir"
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
We started at C:\QB64
|
||||
We are now in C:\QB64\a_temporary_dir
|
||||
And now we're back in C:\QB64
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [CHDIR](CHDIR) (Change the current working directory)
|
||||
* [RMDIR](RMDIR) (Remove a directory in the file system)
|
||||
* [KILL](KILL) (Delete a file in the file system)
|
||||
* [MKDIR](MKDIR) (Create a directory in the file system)
|
||||
* [_OS$](_OS$) (returns current OS to program)
|
||||
* [_STARTDIR$](_STARTDIR$) (returns path the user called program from)
|
34
wiki/_D2G.md
Normal file
34
wiki/_D2G.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
The [_D2G](_D2G) function converts a **degree** value into a **gradian** value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result = [_D2G](_D2G)(num)
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Coverting Degrees into Gradians.
|
||||
|
||||
```vb
|
||||
|
||||
INPUT "Give me an angle in Degrees ", D
|
||||
R = _D2G(D)
|
||||
PRINT "That angle in Gradians is "; R
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Give me an angle in Degrees 60
|
||||
That angle in Gradient is 66.66666
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2R](_D2R)
|
||||
* [_G2D](_G2D), [_G2R](_G2R)
|
||||
* [_R2D](_R2D), [_R2G](_R2G)
|
34
wiki/_D2R.md
Normal file
34
wiki/_D2R.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
The [_D2R](_D2R) function converts a **degree** value into a **radian** value.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result = [_D2R](_D2R)(num)
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Coverting Degrees into Radians.
|
||||
|
||||
```vb
|
||||
|
||||
INPUT "Give me an angle in Degrees ", D
|
||||
R = _D2R(D)
|
||||
PRINT "That angle in Radians is "; R
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Give me an angle in Degrees 60
|
||||
That angle in Radians is 1.047198
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_D2G](_D2G), [_D2R](_D2R)
|
||||
* [_G2D](_G2D), [_G2R](_G2R)
|
||||
* [_R2D](_R2D), [_R2G](_R2G)
|
33
wiki/_DEFAULTCOLOR.md
Normal file
33
wiki/_DEFAULTCOLOR.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
The [_DEFAULTCOLOR](_DEFAULTCOLOR) function returns the current default text color for an image handle or page.
|
||||
|
||||
## Syntax
|
||||
|
||||
> result& = [_DEFAULTCOLOR](_DEFAULTCOLOR) [(imageHandle&)]
|
||||
|
||||
## Description
|
||||
|
||||
* If imageHandle& is omitted, it is assumed to be the current write page or image designated by [_DEST](_DEST).
|
||||
* If imageHandle& is an invalid handle, an [ERROR Codes](ERROR-Codes) error occurs. Check handle values first.
|
||||
* Default foreground colors are: [SCREEN](SCREEN) 0 = 7, [SCREEN](SCREEN) 1 and 10 = 3, [SCREEN](SCREEN) 2 and 11 = 1. All other [SCREEN](SCREEN)s = 15.
|
||||
|
||||
## Example(s)
|
||||
|
||||
The default color is the color assigned to the text foreground. The [SCREEN](SCREEN) 12 default is [COLOR](COLOR) 15.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 12
|
||||
OUT &H3C8, 0: OUT &H3C9, 63: OUT &H3C9, 63: OUT &H3C9, 63 'assign background RGB intensities
|
||||
OUT &H3C8, 8: OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 0 'assign RGB intensities to COLOR 8
|
||||
_PRINTMODE _KEEPBACKGROUND
|
||||
COLOR 8 'assign color 8 to text foreground
|
||||
PRINT "The default color is attribute"; _DEFAULTCOLOR
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [COLOR](COLOR)
|
||||
* [_DEST](_DEST)
|
||||
* [Images](Images)
|
||||
* [Windows Libraries](Windows-Libraries)
|
52
wiki/_DEFINE.md
Normal file
52
wiki/_DEFINE.md
Normal file
|
@ -0,0 +1,52 @@
|
|||
[_DEFINE](_DEFINE) defines a set of variable names according to their first character as a specified data type.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DEFINE](_DEFINE) letter[-range, ...] [AS](AS) [_UNSIGNED] data[Variable Types](Variable-Types)
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* Variable start *letter range* is in the form firstletter-endingletter (like A-C) or just a single letter.
|
||||
* *Data types*: [INTEGER](INTEGER), [SINGLE](SINGLE), [DOUBLE](DOUBLE), [LONG](LONG), [STRING](STRING), [_BIT](_BIT), [_BYTE](_BYTE), [_INTEGER64](_INTEGER64), [_FLOAT](_FLOAT), [_OFFSET](_OFFSET), [_MEM](_MEM)
|
||||
* Can also use the [_UNSIGNED](_UNSIGNED) definition for positive whole [INTEGER](INTEGER) type numerical values.
|
||||
|
||||
## Description
|
||||
|
||||
* **When a variable has not been defined or has no type suffix, the value defaults to a [SINGLE](SINGLE) precision floating point value.**
|
||||
* _DEFINE sets the [Variable Types](Variable-Types) of all variable names with the starting letter(s) or letter ranges when encountered in the progression of the program (even in conditional statement blocks not executed and subsequent [SUB](SUB) procedures).
|
||||
* **NOTE: Many QBasic keyword variable names CAN be used with a [STRING](STRING) suffix ($)! You cannot use them without the suffix, use a numerical suffix or use [DIM](DIM), [REDIM](REDIM), [_DEFINE](_DEFINE), [BYVAL](BYVAL) or [TYPE](TYPE) variable [AS](AS) statements.**
|
||||
* **QBasic's IDE** added DEF statements before any [SUB](SUB) or [FUNCTION](FUNCTION). **QB64** (like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a [ERROR Codes](ERROR-Codes) warning or adding the proper DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures.
|
||||
* May also affect [$INCLUDE]($INCLUDE) procedures.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Defining variables that start with the letters A, B, C or F as unsigned integers, including the *Add2* [FUNCTION](FUNCTION).
|
||||
|
||||
```vb
|
||||
|
||||
_DEFINE A-C, F AS _UNSIGNED INTEGER
|
||||
|
||||
PRINT Add2(-1.1, -2.2)
|
||||
|
||||
END
|
||||
|
||||
FUNCTION Add2 (one, two)
|
||||
Add2 = one + two
|
||||
END FUNCTION
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
65533
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* Unsigned integers can only return positive values while ordinary [INTEGER](INTEGER) can also return negative values.
|
||||
|
||||
## See Also
|
||||
|
||||
* [DEFSTR](DEFSTR), [DEFLNG](DEFLNG), [DEFINT](DEFINT), [DEFSNG](DEFSNG), [DEFDBL](DEFDBL)
|
||||
* [DIM](DIM), [REDIM](REDIM)
|
||||
* [COMMON](COMMON), [SHARED](SHARED)
|
||||
* [_UNSIGNED](_UNSIGNED)
|
50
wiki/_DEFLATE$.md
Normal file
50
wiki/_DEFLATE$.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
The [_DEFLATE$](_DEFLATE$) function compresses a [STRING](STRING).
|
||||
|
||||
## Syntax
|
||||
|
||||
> result$ = [_DEFLATE$](_DEFLATE$)(stringToCompress$)
|
||||
|
||||
## Description
|
||||
|
||||
* result$ will contain the compressed version of stringToCompress$.
|
||||
* To decompress the resulting string, use [_INFLATE$](_INFLATE$).
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.4 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Compressing a long string of text.
|
||||
|
||||
```vb
|
||||
|
||||
a$ = "The quick brown fox jumps over the lazy dog. "
|
||||
PRINT "Original string (a$): "; a$
|
||||
FOR i = 1 TO 15
|
||||
a$ = a$ + a$
|
||||
NEXT
|
||||
|
||||
PRINT "After concatenating it into itself several times, LEN(a$) ="; LEN(a$)
|
||||
|
||||
b$ = _DEFLATE$(a$)
|
||||
PRINT "After using _DEFLATE$ to compress it, LEN ="; LEN(b$)
|
||||
PRINT USING "(compressed size is #.###% of the original)"; ((LEN(b$) * 100) / LEN(a$))
|
||||
c$ = _INFLATE$(b$)
|
||||
PRINT "After using _INFLATE$ to decompress it, LEN ="; LEN(c$)
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Original string (a$): The quick brown fox jumps over the lazy dog
|
||||
After concatenating it into itself several times, LEN(a$) = 1474560
|
||||
After using _DEFLATE$ to compress it, LEN = 4335
|
||||
(compressed size is 0.295% of the original)
|
||||
After using _INFLATE$ to decompress it, LEN = 1474560
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_INFLATE$](_INFLATE$)
|
20
wiki/_DELAY.md
Normal file
20
wiki/_DELAY.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
The [_DELAY](_DELAY) statement suspends program execution for the specified number of seconds.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DELAY](_DELAY) seconds!
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* seconds! is the time to wait, accurate to nearest millisecond (.001).
|
||||
|
||||
## Description
|
||||
|
||||
* While waiting, CPU cycles are relinquished to other applications.
|
||||
* Delays are not affected by midnight timer corrections.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_LIMIT](_LIMIT)
|
||||
* [TIMER](TIMER)
|
||||
* [ON TIMER(n)](ON-TIMER(n))
|
21
wiki/_DEPTHBUFFER.md
Normal file
21
wiki/_DEPTHBUFFER.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
The [_DEPTHBUFFER](_DEPTHBUFFER) statement turns depth buffering ON or OFF, LOCKs or _CLEARS the buffer.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DEPTHBUFFER](_DEPTHBUFFER) {ON|OFF|LOCK|_CLEAR}[,handle&]
|
||||
|
||||
## Description
|
||||
|
||||
* Depth buffers store the distance of each pixel on an image/surface. When 3D drawing occurs new pixels are only drawn if they are closer than the existing pixels. After all content is drawn, it results in a scene which looks correct because content which is closer hides content which is further away.
|
||||
* Depth buffers are automatically created for any hardware image or surface which is the target/destination of a 3D command (such as the 3D version of [_MAPTRIANGLE](_MAPTRIANGLE)).
|
||||
* The buffering can be turned ON, OFF or LOCKed. The default state is ON.
|
||||
* [_DEPTHBUFFER](_DEPTHBUFFER) _CLEAR can be used to reset/erase the depth buffer, meaning that future drawing will not be blocked by existing/previously buffered depth content.
|
||||
* Whenever _DISPLAY is called the primary surface's depth buffer is automatically _CLEARed, so unless you are drawing onto a hardware image you may never need to use this option.
|
||||
* LOCKing the depth buffer makes it read only. New content cannot be drawn unless it is closer than existing content, but when that new content is drawn it will not update the depth buffer.
|
||||
* Turning OFF or LOCKing the depth buffer is typically performed when semi-transparent content is being drawn.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_MAPTRIANGLE](_MAPTRIANGLE)
|
||||
* [_PUTIMAGE](_PUTIMAGE)
|
||||
* [_DISPLAY](_DISPLAY)
|
32
wiki/_DESKTOPHEIGHT.md
Normal file
32
wiki/_DESKTOPHEIGHT.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
The [_DESKTOPHEIGHT](_DESKTOPHEIGHT) function returns the height of the users current desktop.
|
||||
|
||||
## Syntax
|
||||
|
||||
> y& = [_DESKTOPHEIGHT](_DESKTOPHEIGHT)
|
||||
|
||||
## Description
|
||||
|
||||
* No parameters are needed for this function.
|
||||
* This returns the height of the user's desktop, not the size of any screen or window which might be open on that desktop.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
s& = _NEWIMAGE(800, 600, 256)
|
||||
SCREEN s&
|
||||
PRINT _DESKTOPWIDTH, _DESKTOPHEIGHT
|
||||
PRINT _WIDTH, _HEIGHT
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* This will print the size of the user desktop (for example *1920, 1080* for a standard hdmi monitor), and then the size of the current [SCREEN](SCREEN) (800, 600).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_HEIGHT](_HEIGHT), [_DESKTOPWIDTH](_DESKTOPWIDTH)
|
||||
* [_WIDTH](_WIDTH), [_SCREENIMAGE](_SCREENIMAGE)
|
32
wiki/_DESKTOPWIDTH.md
Normal file
32
wiki/_DESKTOPWIDTH.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
The [_DESKTOPWIDTH](_DESKTOPWIDTH) function returns the width of the users current desktop.
|
||||
|
||||
## Syntax
|
||||
|
||||
> x& = [_DESKTOPWIDTH](_DESKTOPWIDTH)
|
||||
|
||||
## Description
|
||||
|
||||
* No parameters are needed for this function.
|
||||
* This returns the width of the user's desktop, not the size of any screen or window which might be open on that desktop.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
s& = _NEWIMAGE(800, 600, 256)
|
||||
SCREEN s&
|
||||
PRINT _DESKTOPWIDTH, _DESKTOPHEIGHT
|
||||
PRINT _WIDTH, _HEIGHT
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* This will print the size of the user desktop (for example *1920, 1080* for a standard hdmi monitor), and then the size of the current [SCREEN](SCREEN) (800, 600).
|
||||
|
||||
## See Also
|
||||
|
||||
* [_HEIGHT](_HEIGHT), [_DESKTOPHEIGHT](_DESKTOPHEIGHT)
|
||||
* [_WIDTH](_WIDTH), [_SCREENIMAGE](_SCREENIMAGE)
|
18
wiki/_DEST-(function).md
Normal file
18
wiki/_DEST-(function).md
Normal file
|
@ -0,0 +1,18 @@
|
|||
The [_DEST](_DEST) function returns the handle value of the current write page (the image used for drawing).
|
||||
|
||||
## Syntax
|
||||
|
||||
> result& = [_DEST](_DEST)
|
||||
|
||||
## Description
|
||||
|
||||
* The current write page is where all drawing occurs by default.
|
||||
* The value returned is the same as the latest [SCREEN](SCREEN)'s handle when creating custom screen modes using [_NEWIMAGE](_NEWIMAGE).
|
||||
* Keep the _NEWIMAGE handle values when you move to another SCREEN mode so that you can return to that screen later. You can go to another screen mode and return without having to redo the screen.
|
||||
* [_DEST](_DEST) return values do not change in legacy screen modes. The value will not help restore them.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEST](_DEST)
|
||||
* [_SOURCE (function)](_SOURCE-(function))
|
||||
* [SCREEN](SCREEN)
|
113
wiki/_DEST.md
Normal file
113
wiki/_DEST.md
Normal file
|
@ -0,0 +1,113 @@
|
|||
The [_DEST](_DEST) statement sets the current write image or page. All graphic and print changes will be done to this image.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DEST](_DEST) imageHandle&
|
||||
|
||||
## Description
|
||||
|
||||
* imageHandle& is the handle of the image that will act as the current write page.
|
||||
* **_DEST 0** refers to the present program [SCREEN](SCREEN). You can use 0 to refer to the present program [SCREEN](SCREEN).
|
||||
* [_DEST](_DEST) [_CONSOLE](_CONSOLE) can set the destination to send information to a console window using [PRINT](PRINT) or [INPUT](INPUT).
|
||||
* If imageHandle& is an invalid handle, an [ERROR Codes](ERROR-Codes) error occurs. Always check for valid handle values first (imageHandle& < -1).
|
||||
* *Note:* Use [_SOURCE](_SOURCE) when you need to read a page or image with [POINT](POINT), [GET (graphics statement)](GET-(graphics-statement)) or the [SCREEN (function)](SCREEN-(function)) function.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Placing a center point and a circle using [_CLEARCOLOR](_CLEARCOLOR) to eliminate the background color black.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 13 'program screen can use 256 colors
|
||||
a& = _NEWIMAGE(320,200,13) 'create 2 screen page handles a& and b&
|
||||
b& = _NEWIMAGE(320,200,13)
|
||||
_DEST a& 'set destination image to handle a&
|
||||
PSET (100, 100), 15 'draw a dot on the current destination handle a&
|
||||
_DEST b& 'set destination image to handle b&
|
||||
CIRCLE (100, 100), 50, 15 'draw a circle on the current destination handle b&
|
||||
_CLEARCOLOR 0 'make page b color 0 (black) transparent
|
||||
_PUTIMAGE , b&, a& 'put circle on image b to image a& (a PSET dot)
|
||||
_PUTIMAGE , a&, 0 'put what is on image a& to the screen (handle 0)
|
||||
|
||||
```
|
||||
|
||||
Demonstrates how [PRINT](PRINT) text can be stretched using [_PUTIMAGE](_PUTIMAGE) with [_DEST](_DEST) pages.
|
||||
|
||||
```vb
|
||||
|
||||
DIM a(10) AS LONG
|
||||
DIM b AS LONG
|
||||
|
||||
REM Sets up a newimage for B then sets the screen to that.
|
||||
b = _NEWIMAGE(640, 480, 32)
|
||||
SCREEN b
|
||||
|
||||
REM Make pages 48 pixels tall. If the image is not at least that it wont work
|
||||
a(1) = _NEWIMAGE(240, 48, 32)
|
||||
a(2) = _NEWIMAGE(240, 48, 32)
|
||||
a(3) = _NEWIMAGE(98, 48, 32)
|
||||
|
||||
xa = 100
|
||||
ya = 120
|
||||
xm = 4
|
||||
ym = 4
|
||||
|
||||
REM Some fun things for the bouncing text.
|
||||
st$(0) = "doo"
|
||||
st$(1) = "rey"
|
||||
st$(2) = "mee"
|
||||
st$(3) = "faa"
|
||||
st$(4) = "soo"
|
||||
st$(5) = "laa"
|
||||
st$(6) = "tee"
|
||||
|
||||
sta$(0) = "This is a demo"
|
||||
sta$(1) = "showing how to use"
|
||||
sta$(2) = "the _DEST command"
|
||||
sta$(3) = "with PRINT"
|
||||
sta$(4) = "and _PUTIMAGE"
|
||||
|
||||
REM prints to a(3) image then switches back to the default 0
|
||||
_DEST a(3): f = INT(RND * 6): PRINT st$(3): _DEST 0
|
||||
|
||||
DO
|
||||
REM prints to a(1) and a(2) then switches bac to 0
|
||||
_DEST a(1)
|
||||
CLS
|
||||
PRINT sta(r)
|
||||
_DEST a(2)
|
||||
CLS
|
||||
PRINT sta(r + 1)
|
||||
_DEST 0 'destination zero is the main program page
|
||||
|
||||
REM a loop to putimage the images in a(1) and a(2) in a way to make it look like its rolling
|
||||
FOR yat = 150 TO 380 STEP 4
|
||||
CLS
|
||||
_PUTIMAGE (0, yat)-(640, 380), a(1)
|
||||
_PUTIMAGE (0, 150)-(640, yat), a(2)
|
||||
GOSUB bounce
|
||||
_DISPLAY
|
||||
_LIMIT 20
|
||||
NEXT yat
|
||||
|
||||
r = r + 1
|
||||
IF r = 4 THEN r = 0
|
||||
LOOP UNTIL INKEY$ <> ""
|
||||
END
|
||||
|
||||
bounce:
|
||||
IF xa > 600 OR xa < 20 THEN xm = xm * -1: _DEST a(3): f = INT(RND * 6): CLS: _CLEARCOLOR 0: PRINT st$(f): _DEST 0
|
||||
IF ya > 400 OR ya < 20 THEN ym = ym * -1: _DEST a(3): f = INT(RND * 7): CLS: _CLEARCOLOR 0: PRINT st$(f): _DEST 0
|
||||
_PUTIMAGE (xa, ya)-(xa + 150, ya + 80), a(3)
|
||||
xa = xa + xm
|
||||
ya = ya + ym
|
||||
RETURN
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEST (function)](_DEST-(function))
|
||||
* [_SOURCE](_SOURCE)
|
||||
* [_PUTIMAGE](_PUTIMAGE)
|
||||
* [_CONSOLE](_CONSOLE)
|
73
wiki/_DEVICE$.md
Normal file
73
wiki/_DEVICE$.md
Normal file
|
@ -0,0 +1,73 @@
|
|||
The **_DEVICE$** function returns a [STRING](STRING) value holding the controller type, name and input types of the input devices on a computer.
|
||||
|
||||
## Syntax
|
||||
|
||||
> device$ = _DEVICE$(device_number)
|
||||
|
||||
* The **[_DEVICES](_DEVICES) function must be read first to get the number of devices and to enable [_DEVICE$](_DEVICE$) and [_DEVICEINPUT](_DEVICEINPUT).**
|
||||
* The device_number parameter indicates the number of the controller device to be read.
|
||||
* Returns the [STRING](STRING) control type, name of the device and input types each can use included in brackets:
|
||||
* Control type:
|
||||
* [KEYBOARD] always listed as first device when keyboard(s) available. Only one keyboard will show.
|
||||
* [MOUSE]] always listed as second device when keyboard(s) and mouse(mice) are available. Only one mouse will show.
|
||||
* [CONTROLLER] subsequent devices are listed as controllers which include joysticks and game pads.
|
||||
* When [CONTROLLER] is returned it may also give the [STRING](STRING) [NAME] [device description](NAME] [device description) of the controller.
|
||||
* Returns the type of input after the device name as one or more of the following types:
|
||||
* [[BUTTON](BUTTON)] indicates there are button types of input. [_LASTBUTTON](_LASTBUTTON) can return the number of buttons available.
|
||||
* [[AXIS](AXIS)] indicates there are stick types of input. [_LASTAXIS](_LASTAXIS) can return the number of axis available.
|
||||
* [[WHEEL](WHEEL)] indicates that a scrolling input can be read. [_LASTWHEEL](_LASTWHEEL) can return the number of wheels available.
|
||||
|
||||
* **Device numbers above the number of [_DEVICES](_DEVICES) found will return an OS error.**
|
||||
* Devices found include keyboard, mouse, joysticks, game pads and multiple stick game controllers.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Checking for the system's input devices and the number of buttons available.
|
||||
|
||||
```vb
|
||||
|
||||
devices = _DEVICES 'MUST be read in order for other 2 device functions to work!
|
||||
PRINT "Number of input devices found ="; devices
|
||||
FOR i = 1 TO devices
|
||||
PRINT _DEVICE$(i)
|
||||
PRINT "Buttons:"; _LASTBUTTON(i); "Axis:"; _LASTAXIS(i); "Wheels:"; _LASTWHEEL(i)
|
||||
NEXT
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Number of input devices found = 3
|
||||
[KEYBOARD][BUTTON]
|
||||
Buttons: 512 Axis: 0 Wheels: 0
|
||||
[MOUSE][BUTTON][AXIS][WHEEL]
|
||||
Buttons: 3 Axis: 2 Wheels: 3
|
||||
[CONTROLLER][NAME][Microsoft Sidewinder Precision Pro (USB)](NAME][Microsoft Sidewinder Precision Pro (USB))[BUTTON][AXIS]
|
||||
Buttons: 9 Axis: 6 Wheels: 0
|
||||
|
||||
```
|
||||
|
||||
> Note: The [STRIG](STRIG)/[STICK](STICK) commands won't read from the keyboard or mouse device the above example lists. They will only work on controllers.
|
||||
|
||||
Finding the number of mouse buttons available in QB64. This could also be used for other devices.
|
||||
|
||||
```vb
|
||||
|
||||
FOR d = 1 TO _DEVICES 'number of input devices found
|
||||
dev$ = _DEVICE$(d)
|
||||
IF INSTR(dev$, "[MOUSE]") THEN buttons = _LASTBUTTON(d): EXIT FOR
|
||||
NEXT
|
||||
PRINT buttons; "mouse buttons available"
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEVICES](_DEVICES), [_DEVICEINPUT](_DEVICEINPUT)
|
||||
* [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS), [_LASTWHEEL](_LASTWHEEL)
|
||||
* [_BUTTON](_BUTTON), [_BUTTONCHANGE](_BUTTONCHANGE)
|
||||
* [_AXIS](_AXIS), [_WHEEL](_WHEEL)
|
||||
* [_MOUSEBUTTON](_MOUSEBUTTON)
|
||||
* [STRIG](STRIG), [STICK](STICK)
|
||||
* [ON STRIG(n)](ON-STRIG(n)), [STRIG(n)](STRIG(n))
|
||||
* [Controller Devices](Controller-Devices)
|
117
wiki/_DEVICEINPUT.md
Normal file
117
wiki/_DEVICEINPUT.md
Normal file
|
@ -0,0 +1,117 @@
|
|||
The **_DEVICEINPUT** function returns the device number when a controller device button, wheel or axis event occurs.
|
||||
|
||||
## Syntax
|
||||
|
||||
> device% = [_DEVICEINPUT](_DEVICEINPUT)
|
||||
> device_active% = [_DEVICEINPUT](_DEVICEINPUT)(device_number%)
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* Use the _DEVICEINPUT device% [INTEGER](INTEGER) returned to find the number of the controller device being used.
|
||||
* A literal specific device_number% parameter can be used to return -1 if active or 0 if inactive. EX: **WHILE _DEVICEINPUT(2)**
|
||||
|
||||
## Description
|
||||
|
||||
* Use [_DEVICES](_DEVICES) to find the number of controller devices available BEFORE using this function.
|
||||
* [_DEVICE$](_DEVICE$) can be used to list the device names and control types using valid [_DEVICES](_DEVICES) numbers.
|
||||
* When a device button is pressed or a scroll wheel or axis is moved, the device number will be returned.
|
||||
* Devices are numbered as 1 for keyboard and 2 for mouse. Other controller devices will be numbered 3 or higher if installed.
|
||||
* [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS), or [_LASTWHEEL](_LASTWHEEL) will indicate the number of functions available with the specified *device* number.
|
||||
* User input events can be monitored reading valid numbered [_AXIS](_AXIS), [_BUTTON](_BUTTON), [_BUTTONCHANGE](_BUTTONCHANGE) or [_WHEEL](_WHEEL) functions.
|
||||
* *Note:* [ON...GOSUB](ON...GOSUB) keyboard, mouse, gamecontrol can be used to control the devices 1,2 and 3, etc.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Checking device controller interfaces and finding out what devices are being used.
|
||||
|
||||
```vb
|
||||
|
||||
FOR i = 1 TO _DEVICES
|
||||
PRINT STR$(i) + ") " + _DEVICE$(i)
|
||||
PRINT "Button:"; _LASTBUTTON(i); ",Axis:"; _LASTAXIS(i); ",Wheel:"; _LASTWHEEL(i)
|
||||
NEXT
|
||||
|
||||
PRINT
|
||||
DO
|
||||
x = _DEVICEINPUT
|
||||
IF x THEN PRINT "Device ="; x;
|
||||
LOOP UNTIL INKEY$ = CHR$(27) 'escape key exit
|
||||
|
||||
END
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
[KEYBOARD][BUTTON]
|
||||
Buttons: 512 Axis: 0 Wheels: 0
|
||||
[MOUSE][BUTTON][AXIS][WHEEL]
|
||||
Buttons: 3 Axis: 2 Wheels: 3
|
||||
[CONTROLLER][NAME][Microsoft Sidewinder Precision Pro (USB)](NAME][Microsoft Sidewinder Precision Pro (USB))[BUTTON][AXIS]
|
||||
Buttons: 9 Axis: 6 Wheels: 0
|
||||
|
||||
Device = 2 Device = 2
|
||||
|
||||
```
|
||||
|
||||
> *Note:* Mouse events must be within the program screen area. Keyboard presses are registered only when program is in focus.
|
||||
|
||||
Why does a mouse have 3 wheels? Relative x and y movements can be read using the first 2 [_WHEEL](_WHEEL) reads.
|
||||
|
||||
```vb
|
||||
|
||||
ignore = _MOUSEMOVEMENTX 'dummy call to put mouse into relative movement mode
|
||||
|
||||
PRINT "Move your mouse and/or your mouse wheel (ESC to exit)"
|
||||
|
||||
d = _DEVICES ' always read number of devices to enable device input
|
||||
DO: _LIMIT 30 'main loop
|
||||
DO WHILE _DEVICEINPUT(2) 'loop only runs during a device 2 mouse event
|
||||
PRINT _WHEEL(1), _WHEEL(2), _WHEEL(3)
|
||||
LOOP
|
||||
LOOP UNTIL INKEY$ = CHR$(27)
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* Referencing the [_MOUSEMOVEMENTX](_MOUSEMOVEMENTX) function hides the mouse and sets the mouse to a relative movement mode which can be read by [_WHEEL](_WHEEL). [_DEVICEINPUT](_DEVICEINPUT)(2) returns -1 (true) only when the mouse is moved, scrolled or clicked.
|
||||
|
||||
Using [ON...GOSUB](ON...GOSUB) with the [_DEVICEINPUT](_DEVICEINPUT) number to add keyboard, mouse and game controller event procedures.
|
||||
|
||||
```vb
|
||||
|
||||
n = _DEVICES 'required when reading devices
|
||||
PRINT "Number of devices found ="; n
|
||||
FOR i = 1 TO n
|
||||
PRINT i; _DEVICE$(i) ' 1 = keyboard, 2 = mouse, 3 = other controller, etc.
|
||||
NEXT
|
||||
PRINT
|
||||
|
||||
DO: device = _DEVICEINPUT
|
||||
ON device GOSUB keyboard, mouse, controller 'must be inside program loop
|
||||
LOOP UNTIL INKEY$ = CHR$(27)
|
||||
END
|
||||
|
||||
keyboard:
|
||||
PRINT device; "Keyboard";
|
||||
RETURN
|
||||
|
||||
mouse:
|
||||
PRINT device; "Mouse ";
|
||||
RETURN
|
||||
|
||||
controller:
|
||||
PRINT device; "Game control ";
|
||||
RETURN
|
||||
|
||||
```
|
||||
|
||||
> *Note:* [ON...GOSUB](ON...GOSUB) and [ON...GOTO](ON...GOTO) events require numerical values to match the order of line labels listed in the event used inside loops.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEVICES](_DEVICES), [_DEVICE$](_DEVICE$)
|
||||
* [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS), [_LASTWHEEL](_LASTWHEEL)
|
||||
* [_BUTTON](_BUTTON), [_AXIS](_AXIS), [_WHEEL](_WHEEL)
|
||||
* [STRIG](STRIG), [STICK](STICK)
|
||||
* [ON...GOSUB](ON...GOSUB) (numerical events)
|
||||
* [Controller Devices](Controller-Devices)
|
49
wiki/_DEVICES.md
Normal file
49
wiki/_DEVICES.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
The [_DEVICES](_DEVICES) function returns the number of INPUT devices on your computer including keyboard, mouse and game devices.
|
||||
|
||||
## Syntax
|
||||
|
||||
> device_count% = [_DEVICES](_DEVICES)
|
||||
|
||||
## Description
|
||||
|
||||
* Returns the number of devices that can be listed separately with the [_DEVICE$](_DEVICE$) function by the device number.
|
||||
* Devices include keyboard, mouse, joysticks, game pads and multiple stick game controllers.
|
||||
* **Note: This function must be read before trying to use the [_DEVICE$](_DEVICE$), [_DEVICEINPUT](_DEVICEINPUT) or _LAST control functions.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Checking for the system's input devices.
|
||||
|
||||
```vb
|
||||
|
||||
devices = _DEVICES 'MUST be read in order for other 2 device functions to work!
|
||||
PRINT "Number of input devices found ="; devices
|
||||
FOR i = 1 TO devices
|
||||
PRINT _DEVICE$(i)
|
||||
PRINT "Buttons:"; _LASTBUTTON(i)
|
||||
NEXT
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
Number of input devices found = 2
|
||||
[KEYBOARD][BUTTON]
|
||||
Buttons: 512
|
||||
[MOUSE][BUTTON][AXIS][WHEEL]
|
||||
Buttons: 3
|
||||
|
||||
```
|
||||
|
||||
> Note: The [STRIG](STRIG)/[STICK](STICK) commands won't read from the keyboard or mouse device the above example lists.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DEVICE$](_DEVICE$), [_DEVICEINPUT](_DEVICEINPUT)
|
||||
* [_LASTBUTTON](_LASTBUTTON), [_LASTAXIS](_LASTAXIS), [_LASTWHEEL](_LASTWHEEL)
|
||||
* [_BUTTON](_BUTTON), [_BUTTONCHANGE](_BUTTONCHANGE)
|
||||
* [_AXIS](_AXIS), [_WHEEL](_WHEEL)
|
||||
* [_MOUSEINPUT](_MOUSEINPUT), [_MOUSEX](_MOUSEX), [_MOUSEBUTTON](_MOUSEBUTTON)
|
||||
* [STRIG](STRIG), [STICK](STICK)
|
||||
* [ON STRIG(n)](ON-STRIG(n)), [STRIG(n)](STRIG(n))
|
||||
* [Controller Devices](Controller-Devices)
|
56
wiki/_DIR$.md
Normal file
56
wiki/_DIR$.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
The [_DIR$](_DIR$) function returns common paths in **Windows** only such as My Documents, My Pictures, My Music, Desktop.
|
||||
|
||||
## Syntax
|
||||
|
||||
> d$ = [_DIR$](_DIR$)("folderspecification")
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* *folderspecification* may be "desktop", "download", "documents", "music", "video", "pictures", "appdata", "program data", "local data", "program files", "program files (x86)", "temp".
|
||||
* Some variation is accepted for the folder specification:
|
||||
* MY DOCUMENTS, TEXT, DOCUMENT, DOCUMENTS, DOWNLOAD, DOWNLOADS
|
||||
* MY MUSIC, MUSIC, AUDIO, SOUND, SOUNDS
|
||||
* MY PICTURES, PICTURE, PICTURES, IMAGE, IMAGES, PHOTO, PHOTOS, DCIM, CAMERA, CAMERA ROLL
|
||||
* MY VIDEOS, VIDEO, VIDEOS, MOVIE, MOVIES,
|
||||
* DATA, APPDATA, APPLICATION DATA, PROGRAM DATA, LOCAL DATA, LOCALAPPDATA, LOCAL APPLICATION DATA, LOCAL PROGRAM DATA
|
||||
|
||||
## Description
|
||||
|
||||
* The path returned ends with a backslash (Windows).
|
||||
* A nonexistent folder specification usually defaults to the Desktop folder path.
|
||||
* In Linux and macOS the function always returns **"./"**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Displaying default paths in Windows only.
|
||||
|
||||
```vb
|
||||
|
||||
PRINT "DESKTOP=" + _DIR$("desktop")
|
||||
PRINT "DOWNLOADS=" + _DIR$("download")
|
||||
PRINT "DOCUMENTS=" + _DIR$("my documents")
|
||||
PRINT "PICTURES=" + _DIR$("pictures")
|
||||
PRINT "MUSIC=" + _DIR$("music")
|
||||
PRINT "VIDEO=" + _DIR$("video")
|
||||
PRINT "APPLICATION DATA=" + _DIR$("data")
|
||||
PRINT "LOCAL APPLICATION DATA=" + _DIR$("local application data")
|
||||
|
||||
```
|
||||
|
||||
```text
|
||||
|
||||
DESKTOP=C:\Documents and Settings\Administrator\Desktop\
|
||||
DOWNLOADS=C:\Documents and Settings\Administrator\Downloads\
|
||||
DOCUMENTS=C:\Documents and Settings\Administrator\My Documents\
|
||||
PICTURES=C:\Documents and Settings\Administrator\My Documents\My Pictures\
|
||||
MUSIC=C:\Documents and Settings\Administrator\My Documents\My Music\
|
||||
VIDEO=C:\Documents and Settings\Administrator\My Documents\My Videos\
|
||||
APPLICATION DATA=C:\Documents and Settings\Administrator\Application Data\
|
||||
LOCAL APPLICATION DATA=C:\Documents and Settings\Administrator\Local Settings\Application Data\
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_CWD$](_CWD$)
|
||||
* [_STARTDIR$](_STARTDIR$)
|
32
wiki/_DIREXISTS.md
Normal file
32
wiki/_DIREXISTS.md
Normal file
|
@ -0,0 +1,32 @@
|
|||
The [_DIREXISTS](_DIREXISTS) function determines if a designated file path or folder exists and returns true (-1) or false (0).
|
||||
|
||||
## Syntax
|
||||
|
||||
> dirExists% = [_DIREXISTS](_DIREXISTS)(filepath$)
|
||||
|
||||
## Description
|
||||
|
||||
* The filepath$ parameter can be a literal or variable [STRING](STRING) path value.
|
||||
* The function returns -1 when a path or folder exists and 0 when it does not.
|
||||
* The function reads the system information directly without using a [SHELL](SHELL) procedure.
|
||||
* The function will use the appropriate Operating System path separators. [_OS$](_OS$) can determine the operating system.
|
||||
* **This function does not guarantee that a path can be accessed, only that it exists.**
|
||||
* **NOTE: Checking if a folder exists in a CD drive may cause the tray to open automatically to request a disk when empty.**
|
||||
|
||||
## Example(s)
|
||||
|
||||
Checks if a folder exists before proceeding.
|
||||
|
||||
```vb
|
||||
|
||||
IF _DIREXISTS("internal\temp") THEN
|
||||
PRINT "Folder found."
|
||||
END IF
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_FILEEXISTS](_FILEEXISTS)
|
||||
* [SHELL](SHELL)
|
||||
* [_OS$](_OS$)
|
50
wiki/_DISPLAY-(function).md
Normal file
50
wiki/_DISPLAY-(function).md
Normal file
|
@ -0,0 +1,50 @@
|
|||
The [_DISPLAY](_DISPLAY) function returns the handle of the current image that is displayed on the screen.
|
||||
|
||||
## Syntax
|
||||
|
||||
> currentImage& = [_DISPLAY](_DISPLAY)
|
||||
|
||||
## Description
|
||||
|
||||
* Returns the current image handle value that is being displayed. Returns 0 if in the default [SCREEN](SCREEN) image.
|
||||
* Not to be confused with the [_DISPLAY](_DISPLAY) statement that displays the screen when not using [_AUTODISPLAY](_AUTODISPLAY).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Creating a mouse cursor using a page number that **you create** in memory without setting up page flipping.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32) 'any graphics mode should work without setting up pages
|
||||
_MOUSEHIDE
|
||||
SetupCursor
|
||||
PRINT "Hello World!"
|
||||
DO: _LIMIT 30
|
||||
DO WHILE _MOUSEINPUT: LOOP 'main loop must contain _MOUSEINPUT
|
||||
' other program code
|
||||
LOOP
|
||||
|
||||
SUB SetupCursor
|
||||
ON TIMER(0.02) UpdateCursor
|
||||
TIMER ON
|
||||
END SUB
|
||||
|
||||
SUB UpdateCursor
|
||||
PCOPY _DISPLAY, 100 'any page number as desination with the _DISPLAY function as source
|
||||
PSET (_MOUSEX, _MOUSEY), _RGB(0, 255, 0)
|
||||
DRAW "ND10F10L3F5L4H5L3"
|
||||
_DISPLAY 'statement shows image
|
||||
PCOPY 100, _DISPLAY 'with the function return as destination page
|
||||
END SUB
|
||||
|
||||
```
|
||||
|
||||
*Note:* Works with the **_DISPLAY function** return as the other page. If mouse reads are not crucial, put the [_MOUSEINPUT](_MOUSEINPUT) loop inside of the UpdateCursor SUB.
|
||||
|
||||
## See Also
|
||||
|
||||
* [SCREEN](SCREEN)
|
||||
* [PCOPY](PCOPY)
|
||||
* [_DISPLAY](_DISPLAY) (statement)
|
||||
* [_AUTODISPLAY](_AUTODISPLAY) (default mode)
|
||||
* [_DISPLAYORDER](_DISPLAYORDER) (statement)
|
82
wiki/_DISPLAY.md
Normal file
82
wiki/_DISPLAY.md
Normal file
|
@ -0,0 +1,82 @@
|
|||
The [_DISPLAY](_DISPLAY) statement turns off the automatic display while only displaying the screen changes when called.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DISPLAY](_DISPLAY)
|
||||
|
||||
## Description
|
||||
|
||||
* **_DISPLAY** turns off the auto refresh screen default [_AUTODISPLAY](_AUTODISPLAY) behavior. Prevents screen flickering.
|
||||
* Call _DISPLAY each time the screen graphics are to be displayed. Place call after the image has been changed.
|
||||
* Re-enable automatic display refreshing by calling [_AUTODISPLAY](_AUTODISPLAY). If it isn't re-enabled, things may not be displayed later.
|
||||
* _DISPLAY tells **QB64** to render all of the hardware [_PUTIMAGE](_PUTIMAGE) commands loaded into the buffer previously.
|
||||
* The [_AUTODISPLAY (function)](_AUTODISPLAY-(function)) can be used to detect the current display behavior.
|
||||
* **QB64** can set the graphic rendering order of _SOFTWARE, _HARDWARE, and _GLRENDER with [_DISPLAYORDER](_DISPLAYORDER).
|
||||
|
||||
## Example(s)
|
||||
|
||||
Displaying a circle bouncing around the screen.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN 12
|
||||
x = 21: y =31 'start position
|
||||
dx = 3: dy = 3 'number of pixel moves per loop
|
||||
DO
|
||||
_LIMIT 100 ' set to 100 frames per second
|
||||
x = x + dx: y = y + dy
|
||||
IF x < 0 OR x > 640 THEN dx = -dx 'limit columns and reverse column direction each side
|
||||
IF y < 0 OR y > 480 THEN dy = -dy 'limit rows and reverse row direction top or bottom
|
||||
IF px <> x OR py <> y THEN FOR d = 1 to 20: CIRCLE (px, py), d, 0: NEXT 'erase
|
||||
FOR c = 1 TO 20: CIRCLE (x, y), c, 6: NEXT 'draw new circle at new position
|
||||
px = x: py = y 'save older coordinates to erase older circle next loop
|
||||
_DISPLAY 'after new circle is set, show it
|
||||
LOOP UNTIL INKEY$ = CHR$(27)
|
||||
|
||||
```
|
||||
|
||||
> *Explanation:* The loop is set with [_LIMIT](_LIMIT) to 100 frames per second to limit CPU usage and the speed of the ball. Each loop a circle is drawn while the previous one is erased when the coordinates change. _DISPLAY only shows the new circle position once each loop. The **_DISPLAY** routine eliminates the need for setting [SCREEN (statement)](SCREEN-(statement)) swap pages, [CLS](CLS) and [PCOPY](PCOPY). _DISPLAY keeps the image off of the screen until the changes have all completed. Drawing 40 circles every loop helps slow down the ball.
|
||||
|
||||
[_DISPLAY](_DISPLAY) must be used to render hardware images placed with [_PUTIMAGE](_PUTIMAGE) (**version 1.000 and up**).
|
||||
|
||||
```vb
|
||||
|
||||
CONST MenuHeight = 200
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
'SLEEP 1
|
||||
LOCATE 20
|
||||
DO
|
||||
_LIMIT 30
|
||||
DisplayMenu
|
||||
k = _KEYHIT
|
||||
IF k <> 0 THEN PRINT k,
|
||||
LOOP UNTIL k = 32 OR k = 27
|
||||
|
||||
SUB DisplayMenu
|
||||
STATIC init, MS_HW AS LONG
|
||||
IF NOT init THEN
|
||||
init = -1
|
||||
MS = _NEWIMAGE(640, MenuHeight, 32) 'MenuScreen image
|
||||
D = _DEST: _DEST MS
|
||||
CLS , &HFFAAAAAA 'background color gray
|
||||
_PRINTSTRING (20, 2), "Menu Test" 'image text
|
||||
MS_HW = _COPYIMAGE(MS, 33) 'create the MenuScreen_HardWare image
|
||||
_FREEIMAGE MS
|
||||
_DEST D
|
||||
END IF
|
||||
_PUTIMAGE (0, 0)-(640, MenuHeight), MS_HW
|
||||
_DISPLAY
|
||||
END SUB
|
||||
|
||||
```
|
||||
|
||||
> *Notes:* When _DISPLAY is commented out, the hardware Menu Test screen portion will blink and key codes may be seen underneath.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DISPLAY (function)](_DISPLAY-(function))
|
||||
* [_DISPLAYORDER](_DISPLAYORDER)
|
||||
* [_AUTODISPLAY](_AUTODISPLAY), [_AUTODISPLAY (function)](_AUTODISPLAY-(function))
|
||||
* [_PUTIMAGE](_PUTIMAGE)
|
||||
* [PCOPY](PCOPY)
|
36
wiki/_DISPLAYORDER.md
Normal file
36
wiki/_DISPLAYORDER.md
Normal file
|
@ -0,0 +1,36 @@
|
|||
The [_DISPLAYORDER](_DISPLAYORDER) statement defines the order to render software, hardware and custom-OpenGL-code.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DISPLAYORDER](_DISPLAYORDER) [{_SOFTWARE|_HARDWARE|_HARDWARE1|_GLRENDER}][, ...][, ...][, ...][, ...]
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* _SOFTWARE refers to software created surfaces or [SCREEN](SCREEN)s.
|
||||
* _HARDWARE and _HARDWARE1 refer to surfaces created by OpenGL hardware acceleration.
|
||||
* _GLRENDER refers to OpenGL code rendering order
|
||||
|
||||
## Description
|
||||
|
||||
* The default on program start is: _DISPLAYORDER _SOFTWARE, _HARDWARE, _GLRENDER, _HARDWARE1
|
||||
* Any content or combination order is allowed, except listing the same content twice consecutively.
|
||||
* Simply using [_DISPLAYORDER](_DISPLAYORDER) _HARDWARE will render hardware surfaces only.
|
||||
* Use an [underscore](underscore) to continue a code line on a new text row in the IDE.
|
||||
* After _DISPLAYORDER has been used, it must be used to make any changes, even to default.
|
||||
|
||||
## Error(s)
|
||||
|
||||
* If a rendering content is not listed it will not be rendered except when using the startup default.
|
||||
* Rendering the same content twice consecutively in a combination is not allowed.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.000 and up.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_DISPLAY](_DISPLAY)
|
||||
* [_PUTIMAGE](_PUTIMAGE)
|
||||
* [_LOADIMAGE](_LOADIMAGE)
|
||||
* [_COPYIMAGE](_COPYIMAGE)
|
||||
* [Hardware images](Hardware-images)
|
103
wiki/_DONTBLEND.md
Normal file
103
wiki/_DONTBLEND.md
Normal file
|
@ -0,0 +1,103 @@
|
|||
The [_DONTBLEND](_DONTBLEND) statement turns off 32 bit alpha blending for the current image or screen mode where [_BLEND](_BLEND) is default.
|
||||
|
||||
## Syntax
|
||||
|
||||
> [_DONTBLEND](_DONTBLEND) [imageHandle&]
|
||||
|
||||
## Parameter(s)
|
||||
|
||||
* If imageHandle& is omitted, it is assumed to be the current [_DEST](_DEST)ination write page.
|
||||
|
||||
## Description
|
||||
|
||||
* If imageHandle& is not valid, an [ERROR Codes](ERROR-Codes) error will occur.
|
||||
* [_DONTBLEND](_DONTBLEND) is faster than the default [_BLEND](_BLEND). **You may want to disable it**, unless you really need to use it in 32 bit.
|
||||
* **32 bit screen surface backgrounds (black) have zero [_ALPHA](_ALPHA) so that they are transparent when placed over other surfaces.**
|
||||
* Use [CLS](CLS) to make a new surface background [_ALPHA](_ALPHA) 255 or opaque.
|
||||
* Both [_SOURCE](_SOURCE) and [_DEST](_DEST) must have [_BLEND](_BLEND) enabled, or else colors will NOT blend.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Use _DONTBLEND when you want the 32 bit screen surface to be opaque so that it covers up other backgrounds. [CLS](CLS) works too.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(1280, 720, 32)
|
||||
'CLS
|
||||
_DONTBLEND '<<< comment out to see the difference
|
||||
|
||||
LINE (100, 100)-(500, 500), _RGB32(255, 255, 0), BF
|
||||
|
||||
b& = SaveBackground&
|
||||
|
||||
PRINT "This is just test junk"
|
||||
PRINT
|
||||
PRINT "Hit any key and the text should disappear, leaving us our pretty yellow box."
|
||||
SLEEP
|
||||
RestoreBackground b&
|
||||
|
||||
END
|
||||
|
||||
FUNCTION SaveBackground&
|
||||
SaveBackground& = _COPYIMAGE(0)
|
||||
END FUNCTION
|
||||
|
||||
SUB RestoreBackground (Image AS LONG)
|
||||
_PUTIMAGE , Image, 0
|
||||
END SUB
|
||||
|
||||
```
|
||||
|
||||
Turning off blending to create transparency.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(640, 480, 32)
|
||||
alphaSprite& = _NEWIMAGE(64, 64, 32)
|
||||
|
||||
_DONTBLEND alphaSprite& ' turn off alpha-blending
|
||||
|
||||
'Create a simple sprite with transparency
|
||||
_DEST alphaSprite&
|
||||
FOR y = 0 TO 63
|
||||
FOR x = 0 TO 63
|
||||
alpha = SQR((x - 32) ^ 2 + (y - 32) ^ 2) / 32
|
||||
IF alpha < 0 THEN alpha = 0
|
||||
alpha = (1 - alpha * alpha) 'parabolic curve
|
||||
PSET (x, y), _RGBA32(255, 255, 255, alpha * 255)
|
||||
NEXT
|
||||
NEXT
|
||||
|
||||
'Make a simple background texture
|
||||
_DEST 0
|
||||
FOR y = 1 TO 479
|
||||
FOR x = 0 TO 639
|
||||
PSET (x, y), _RGB32(x AND 255, y AND 255, (x XOR y) AND 255)
|
||||
NEXT
|
||||
NEXT
|
||||
|
||||
'Store background so we can show moveable objects on it
|
||||
background& = _COPYIMAGE
|
||||
|
||||
'Treat my alpha values as transparency
|
||||
_BLEND alphaSprite&
|
||||
|
||||
ph = 0
|
||||
DO: _LIMIT 60
|
||||
x = 320 - 250 * COS(ph) - (_WIDTH(alphaSprite&) \ 2)
|
||||
y = 240 - 150 * COS(ph * 1.3) - (_HEIGHT(alphaSprite&) \ 2)
|
||||
ph = ph + 0.03
|
||||
_PUTIMAGE , background&, 0
|
||||
_PUTIMAGE (x, y), alphaSprite&, 0
|
||||
_DISPLAY
|
||||
LOOP UNTIL LEN(INKEY$)
|
||||
|
||||
```
|
||||
|
||||
*Explanation:* To make the alpha image, turn alpha blending off. Otherwise PSET blends the pixel to instead of making the sprite transparent.
|
||||
|
||||
## See Also
|
||||
|
||||
* [_BLEND](_BLEND)
|
||||
* [_BLEND (function)](_BLEND-(function))
|
||||
* [Images](Images)
|
41
wiki/_DONTWAIT.md
Normal file
41
wiki/_DONTWAIT.md
Normal file
|
@ -0,0 +1,41 @@
|
|||
[_DONTWAIT](_DONTWAIT) is used with the [SHELL](SHELL) statement in **QB64** to specify that the program shouldn't wait until the external command/program is finished (which it otherwise does by default).
|
||||
|
||||
## Syntax
|
||||
|
||||
> [SHELL](SHELL) [_DONTWAIT] [commandLine$]
|
||||
|
||||
## Description
|
||||
|
||||
*Runs the command/program specified in commandline$ and lets the calling program continue at the same time in its current screen format.
|
||||
*Especially useful when CMD /C or START is used in a SHELL command line to run another program.
|
||||
* **QB64** automatically uses CMD /C or COMMAND /C when using SHELL.
|
||||
* **QB64** program screens will not get distorted or minimized like QBasic fullscreen modes would.
|
||||
|
||||
## Example(s)
|
||||
|
||||
```vb
|
||||
|
||||
SHELL _DONTWAIT "notepad " + filename$
|
||||
|
||||
FOR x = 1 TO 5
|
||||
_LIMIT 1
|
||||
PRINT x
|
||||
NEXT
|
||||
|
||||
```
|
||||
|
||||
(opens up notepad at the same time as counting to 5)
|
||||
|
||||
```text
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [SHELL](SHELL), [_HIDE](_HIDE)
|
65
wiki/_DROPPEDFILE.md
Normal file
65
wiki/_DROPPEDFILE.md
Normal file
|
@ -0,0 +1,65 @@
|
|||
The [_DROPPEDFILE](_DROPPEDFILE) function returns the list of items (files or folders) dropped in a program's window after [_ACCEPTFILEDROP](_ACCEPTFILEDROP) is enabled.
|
||||
|
||||
## Syntax
|
||||
|
||||
*Syntax 1*
|
||||
|
||||
> nextItem$ = [_DROPPEDFILE](_DROPPEDFILE)
|
||||
|
||||
*Syntax 2*
|
||||
|
||||
> nextItem$ = [_DROPPEDFILE](_DROPPEDFILE)(index&)
|
||||
|
||||
## Description
|
||||
|
||||
* After [_ACCEPTFILEDROP](_ACCEPTFILEDROP) is enabled, once [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES) is greater than 0 the list of dropped items will be available for retrieval with [_DROPPEDFILE](_DROPPEDFILE)
|
||||
* When using [_DROPPEDFILE](_DROPPEDFILE) to read the list sequentially (without specifying an *index&*), an empty string ("") indicates the list is over and then [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES) gets reset to 0.
|
||||
* When using [_DROPPEDFILE](_DROPPEDFILE) with an index (which goes from 1 to [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES)), you must call [_FINISHDROP](_FINISHDROP) after you finish working with the list.
|
||||
* Because it returns a string, [_DROPPEDFILE](_DROPPEDFILE) also accepts being followed by a string suffix ([_DROPPEDFILE](_DROPPEDFILE)**$**)
|
||||
* **[Keywords currently not supported](Keywords-currently-not-supported-by-QB64)**.
|
||||
|
||||
## Availability
|
||||
|
||||
* Version 1.3 and up.
|
||||
|
||||
## Example(s)
|
||||
|
||||
Accepting files dragged from a folder and processing the list received by specifying an index.
|
||||
|
||||
```vb
|
||||
|
||||
SCREEN _NEWIMAGE(128, 25, 0)
|
||||
|
||||
_ACCEPTFILEDROP 'enables drag/drop functionality
|
||||
PRINT "Drag files from a folder and drop them in this window..."
|
||||
|
||||
DO
|
||||
IF _TOTALDROPPEDFILES THEN
|
||||
FOR i = 1 TO _TOTALDROPPEDFILES
|
||||
a$ = _DROPPEDFILE(i)
|
||||
COLOR 15
|
||||
PRINT i,
|
||||
IF _FILEEXISTS(a$) THEN
|
||||
COLOR 2: PRINT "file",
|
||||
ELSE
|
||||
IF _DIREXISTS(a$) THEN
|
||||
COLOR 3: PRINT "folder",
|
||||
ELSE
|
||||
COLOR 4: PRINT "not found", 'highly unlikely, but who knows?
|
||||
END IF
|
||||
END IF
|
||||
COLOR 15
|
||||
PRINT a$
|
||||
NEXT
|
||||
_FINISHDROP
|
||||
END IF
|
||||
|
||||
_LIMIT 30
|
||||
LOOP
|
||||
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
* [_ACCEPTFILEDROP](_ACCEPTFILEDROP), [_TOTALDROPPEDFILES](_TOTALDROPPEDFILES), [_FINISHDROP](_FINISHDROP)
|
||||
* [_FILEEXISTS](_FILEEXISTS), [_DIREXISTS](_DIREXISTS)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue