1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00

Step 12: Implement automatic help file update

- changes to update code (ignore static _GL pages as mentioned at Discord https://discord.com/channels/975381912350752819/975389657212805160/1007683254792507412 )
- dist script changes
- update internal/help to contain static _GL pages only
This commit is contained in:
Roland Heyder 2022-08-12 22:53:02 +02:00
parent a56ff3e28e
commit 756eb6ac68
649 changed files with 976 additions and 36026 deletions

View file

@ -19,6 +19,13 @@ case "$buildPlatform" in
;;
esac
# populate internal/help
# 1. create dir / 2. download vital Wiki pages
# 3. include static pages from repository
mkdir -p $DIST_ROOT/internal/help
./qb64pe -u
cp -rp ./internal/help $DIST_ROOT/internal/
mkdir -p $DIST_ROOT
mkdir -p $DIST_ROOT/internal
mkdir -p $DIST_ROOT/internal/c
@ -32,7 +39,6 @@ cp ./qb64pe.1 $DIST_ROOT
cp ./Makefile $DIST_ROOT
cp -rp ./internal/source $DIST_ROOT/internal/
cp -rp ./internal/help $DIST_ROOT/internal/
cp -rp ./internal/support $DIST_ROOT/internal/
cp -rp ./internal/temp $DIST_ROOT/internal/
cp ./internal/config.ini $DIST_ROOT/internal/

View file

@ -1,56 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:36:10}}
The '''$ASSERTS''' [[metacommand]] enables debug tests with the [[_ASSERT]] macro.
{{PageSyntax}}
: '''$ASSERTS'''
: '''$ASSERTS:CONSOLE'''
{{PageDescription}}
* This metacommand does not require a comment ''[[Apostrophe|']]'' or [[REM]] before it. There is no space between the metacommand name, the colon and the CONSOLE parameter.
* If this metacommand is used in a program and any of the set [[_ASSERT]] checkpoints will fail, then the program will stop with an '''{{Text|_ASSERT failed|red}}''' error.
* Detailed error messages passed to the [[_ASSERT]] statement will be displayed in the console window, but only if '''$ASSERTS:CONSOLE''' is used.
;Note: This metacommand is the main switch to enable debug tests during development. Later just remove this metacommand to compile the program without debugging code, all the [[_ASSERT]] statements may remain in the code for later debugging sessions, they are simply ignored without this metacommand.
{{PageAvailability}}
* '''QB64 v1.4 and up''' (QB64 Team)
* '''QB64-PE v0.5 and up''' (QB64 Phoenix Edition)
{{PageExamples}}
;Example:Adding test checks for parameter inputs in a function.
{{CodeStart}}
{{Cl|$ASSERTS|$ASSERTS:CONSOLE}}
{{Cl|DO}}
a = {{Cl|INT}}({{Cl|RND}} * 10)
b$ = myFunc$(a)
{{Cl|PRINT}} a, , b$
{{Cl|_LIMIT}} 3
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_KEYHIT}}
{{Cl|FUNCTION}} myFunc$ (value {{Cl|AS}} {{Cl|SINGLE}})
{{Cl|_ASSERT}} value > 0, "Value cannot be zero"
{{Cl|_ASSERT}} value <= 10, "Value cannot exceed 10"
{{Cl|IF}} value > 1 {{Cl|THEN}} plural$ = "s"
myFunc$ = {{Cl|STRING$}}(value, "*") + {{Cl|STR$}}(value) + " star" + plural$ + " :-)"
{{Cl|END}} {{Cl|FUNCTION}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[Metacommand]]
* [[_ASSERT]]
* [[$CHECKING]]
* [[Relational Operations]]
* [[ERROR Codes]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,30 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:36:34}}
The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
{{PageSyntax}}
: [[$CHECKING]]:{ON|OFF}
{{PageDescription}}
* 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]]:ON action is only required when checking has been turned OFF previously.
* When [[$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)]] events and errors that may have occured in the last function call. Disabling error checking with the [[$CHECKING]]:OFF directive prevents the compiler from adding the extra code sections.
* Setting [[$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.
{{PageSeeAlso}}
* [[ON TIMER(n)]]
* [[ON ERROR]]
* [[Metacommand]]
* [[ERROR Codes]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,61 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:36:45}}
[[$COLOR]] is a metacommand that adds named color [[CONST|constants]] in a program.
{{PageSyntax}}
: [[$COLOR]]:0
: [[$COLOR]]:32
{{PageDescription}}
* [[$COLOR]]:0 adds [[CONST|constants]] for colors 0-15. The actual constant names can be found in the file '''source/utilities/color0.bi'''.
* [[$COLOR]]:32 adds [[CONST|constants]] for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file '''source/utilities/color32.bi'''.
* [[$COLOR]] is a shorthand to manually using [[$INCLUDE]] pointing to the files listed above.
* Prior to QBPE v0.5 ({{Text|ü|red}}), [[$COLOR]] was not compatible with [[$NOPREFIX]].
* Since QBPE v0.5, [[$COLOR]] can now be used with [[$NOPREFIX]], with a few notable differences to three conflicting colors -- Red, Green, Blue.
:Red would conflict with [[_RED]], Green would conflict with [[_GREEN]], and Blue would conflict with [[_BLUE]], once the underscore was removed from those commands with [[$NOPREFIX]].
:
:To prevent these conflicts, the [[COLOR]] values have had '''NP_''' prepended to the front of them, to distinguish them from the non-prefixed command names. All other color names remain the same, with only the three colors in conflict having to use '''NP_''' (for '''N'''o '''P'''refix) in front of them.
({{Text|ü|red}}) QBPE = QB64 Phoenix Edition
{{PageExamples}}
;Example 1:Adding named color constants for SCREEN 0.
{{CodeStart}}
{{Cl|$COLOR}}:0
{{Cl|COLOR}} BrightWhite, Red
{{Cl|PRINT}} "Bright white on red."
{{CodeEnd}}
{{OutputStartBG4}}
{{Text|Bright white on red.|#fcfcfc}}
{{OutputEnd}}
;Example 2:Adding named color constants for 32-bit modes.
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32)
{{Cl|$COLOR}}:32
{{Cl|COLOR}} CrayolaGold, DarkCyan
{{Cl|PRINT}} "CrayolaGold on DarkCyan."
{{CodeEnd}}
;Example 3:Adding named color constants for 32-bit modes (with $NOPREFIX in effect).
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32)
{{Cl|$COLOR}}:32
{{Cl|$NOPREFIX}}
{{Cl|COLOR}} NP_Red, White 'notice the NP_ in front of Red?
'This is to distinguish the color from the command with $NOPREFIX.
{{Cl|PRINT}} "Red on White."
{{CodeEnd}}
{{PageSeeAlso}}
* [[COLOR]], [[SCREEN]]
* [[_NEWIMAGE]], [[$INCLUDE]]
* [[Metacommand]]
{{PageNavigation}}

View file

@ -1,79 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:36:50}}
The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throughout a QB64 program module.
{{PageSyntax}}
: [[$CONSOLE]][:ONLY]
* [[_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]] [[_CONSOLE]] may be used to send screen output to the console window.
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window.
* [[_DELAY]] or [[SLEEP]] can be used to allow the console window to be set in front of the main program window.
* '''QB64 [[Metacommand]]s are not commented out with ' or REM, unlike QuickBASIC metacommands'''
* Change the title of the [[$CONSOLE]] windows created using [[_CONSOLETITLE]]
* '''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''
{{PageExamples}}
''Example 1:'' Hiding and displaying a console window. Use [[_DELAY]] to place console in front of main program window.
{{CodeStart}}
{{Cl|$CONSOLE}}
{{Cl|_DELAY}} 4
{{Cl|_CONSOLE}} OFF
{{Cl|_DELAY}} 4
{{Cl|_CONSOLE}} ON
{{Cl|_DEST}} {{Cl|_CONSOLE}}
{{Cl|PRINT}} "Close this console window or click main window and press a key!"
{{CodeEnd}}
''Example 2:'' How to use a Console window to copy screen output using the ''Edit'' menu by right clicking the console title bar.
{{CodeStart}}
{{Cl|$CONSOLE}}
{{Cl|_DEST}} {{Cl|_CONSOLE}}
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
hx$ = {{Cl|HEX$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{CodeEnd}}
{{OutputStart}}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
{{OutputEnd}}
: ''Console:'' Right click and select ''Edit'' > ''Select All'' (mouse highlight after) then hit Enter or select ''Edit'' > ''Copy'' to the clipboard.
{{TextStart}}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
{{TextEnd}}
:''Copied text:'' The above text was copied after ''Select All'' was selected and the smaller area was re-highlighted with the mouse.
{{PageSeeAlso}}
* [[_CLIPBOARD$]] (function), [[_CLIPBOARD$ (statement)]]
* [[_CONSOLE]]
* [[$SCREENHIDE]], [[$SCREENSHOW]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[C_Libraries#Console_Window|C Console Library]]
{{PageNavigation}}

View file

@ -1,45 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:05}}
'''$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.
{{PageSyntax}}
:[[$DEBUG]]
{{PageDescription}}
* '''$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).
{{PageSeeAlso}}
* [[Metacommand]]s
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,50 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:02}}
The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (resizable) arrays.
{{PageSyntax}}
:{[[REM]] | [[apostrophe|']] } [[$DYNAMIC]]
{{PageDescription}}
* QBasic [[Metacommand|metacommands]] require [[REM]] or [[Apostrophe|apostrophe]] (') before them and are normally placed at the start of the main module.
* Dynamic arrays can be resized using [[REDIM]]. The array's type cannot be changed.
* All data in the array will be lost when [[REDIM]]ensioned except when [[_PRESERVE]] is used.
* [[REDIM]] [[_PRESERVE]] can preserve and may move the previous array data when the array boundaries change.
* [[_PRESERVE]] allows the [[UBOUND|upper]] and [[LBOUND|lower]] boundaries of an array to be changed. The number of dimensions cannot change.
* [[$DYNAMIC]] arrays must be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used as the arrays are removed completely.
{{PageExamples}}
''Example:'' [[REDIM]]ing a $DYNAMIC array using [[_PRESERVE]] to retain previous array values.
{{CodeStart}}
{{Cl|REM}} {{Cl|$DYNAMIC}} 'create dynamic arrays only
{{Cl|DIM}} array(10) 'create array with 11 elements
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 10
array(i) = i: {{Cl|PRINT}} array(i); 'set and display element values
{{Cl|NEXT}}
{{Cl|PRINT}}
{{Cl|REDIM}} {{Cl|_PRESERVE}} array(10 {{Cl|TO}} 20)
{{Cl|FOR...NEXT|FOR}} i = 10 {{Cl|TO}} 20
{{Cl|PRINT}} array(i);
{{Cl|NEXT}}
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
{{OutputEnd}}
{{PageSeeAlso}}
* [[$STATIC]], [[$INCLUDE]]
* [[DIM]], [[REDIM]], [[_DEFINE]]
* [[STATIC]]
* [[ERASE]], [[CLEAR]]
* [[Arrays]], [[Metacommand]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,5 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:34}}
See page [[$IF]]
[[Category:Final]]

View file

@ -1,5 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:33}}
See page [[$IF]]
[[Category:Final]]

View file

@ -1,5 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:35}}
See page [[$IF]]
[[Category:Final]]

View file

@ -1,37 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:38}}
The '''$ERROR''' [[metacommand]] triggers a compilation error.
{{PageSyntax}}
: '''$ERROR''' {{Parameter|message}}
{{PageDescription}}
* This metacommand does not require a comment ''[[Apostrophe|']]'' or [[REM]] before it.
* {{Parameter|message}} is any text. Quotation marks are not required.
* When QB64 tries to compile an '''$ERROR''' metacommand a compilation error is triggered and {{Parameter|message}} is shown to the user. This is useful in [[$IF]] blocks.
{{PageDescription}}
* 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]].
* An '''$ERROR''' directive not inside an conditional [[$IF]] (or [[$ELSEIF]]) block is useless because the program will '''never''' compile in that case.
{{PageExamples}}
{{CodeStart}}
{{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN
{{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above
{{Cl|$END IF}}
{{CodeEnd}}
;Output (IDE Status Area):Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements).
{{PageSeeAlso}}
* [[Metacommand]]
* [[$IF]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,37 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:41}}
'''$EXEICON''' pre-compiler metacommand embeds a designated icon file into the compiled EXE file to be viewed in Windows Explorer.
{{PageSyntax}}
: [[$EXEICON]]:'{{Parameter|iconfile.ico}}'
{{PageParameters}}
* '{{Parameter|iconfile.ico}}' is a valid [https://en.wikipedia.org/wiki/ICO_(file_format) ICO file]
{{PageDescription}}
* Calling [[_ICON]] without an {{Parameter|imageHandle&}} uses the embeded icon, if available.
** Starting with '''build 20170906/64''', the window will automatically use the icon embedded by [[$EXEICON]], without having to call _ICON.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
{{PageExamples}}
''Example:'' Embeds a designated icon file into the compiled EXE which can be viewed in Windows Explorer folders.
{{CodeStart}}
{{Cl|$EXEICON}}:'mush.ico'
{{Cl|_ICON}}
{{CodeEnd}}{{small|Code and command by Fellippe Heitor}}
{{PageSeeAlso}}
* [[_ICON]]
* [[_TITLE]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,89 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:38:06}}
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
{{PageSyntax}}
:[[$IF]] variable = expression THEN
:.
:[[$ELSEIF]] variable = expression THEN
:.
:[[$ELSE]]
:.
:[[$END IF]]
{{PageDescription}}
* $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]] denotes the end of a valid precompiler $IF block.
* [[$ELSEIF]] must follow a valid $IF or $ELSEIF statement.
* If [[$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.
{{PageExamples}}
''Example 1:''
{{CodeStart}}
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
{{Cl|$ELSEIF}} ScreenMode = 32 THEN
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|$END IF}}
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
''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]] and $IF statements let the programmer control the code that actually gets compiled, while excluding the other blocks completely.
''Example 2:''
{{CodeStart}}
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
{{Cl|CONST}} Slash = "/"
{{Cl|$END IF}}
{{Cl|PRINT}} "The proper slash for your operating system is "; Slash
{{CodeEnd}}
''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.
''Example 3:''
{{CodeStart}}
{{Cl|$IF}} VERSION < 1.5 THEN
{{Cl|$ERROR}} Requires QB64 version 1.5 or greater
{{Cl|$END IF}}
{{CodeEnd}}
''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.
{{PageSeeAlso}}
* [[$LET]]
* [[$ERROR]]
* [[Metacommand]]s
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,46 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:37}}
[[$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.
{{PageSyntax}}
: {[[REM]] | [[apostrophe|']] } [[$INCLUDE]]''':''' '{{Parameter|sourceFile}}'
{{PageDescription}}
* QBasic [[Metacommand|metacommands]] must be commented with [[REM]] or an apostrophe.
* The {{Parameter|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]], [[CONST]], [[SHARED]] arrays or [[DATA]] at the '''beginning''' of the main program code.
* $INCLUDE [[SUB]]s or [[FUNCTION]]s at the bottom of the main program code '''after any SUB procedures.'''
** '''Note:''' [[TYPE]] definitions, [[DATA]] and [[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.''
{{PageExamples}}
{{CodeStart}}''' '$INCLUDE:''' 'QB.BI'{{CodeEnd}}
===More examples===
* [[SelectScreen]] (member-contributed $INCLUDE demo)
* [[FILELIST$]] (member-contributed file search function)
* [[SAVEIMAGE]] (SUB program that creates bitmaps)
{{PageSeeAlso}}
* [[INTERRUPT]], [[INTERRUPTX]]
* [[TYPE]], [[DIM]]
* [[Metacommand]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,37 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:38:18}}
[[$LET]] is a precompiler command, which helps to include and/or exclude sections of code in a program based on OS/bit-size or other predefined conditions.
{{PageSyntax}}
: [[$LET]] variable = expression
{{PageDescription}}
* Unlike [[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.
{{PageExamples}}
* See example 1 in [[$IF]].
{{PageSeeAlso}}
* [[$IF]]
* [[$ELSE]]
* [[$ELSEIF]]
* [[$END IF]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,32 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:39:01}}
The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be used without the leading underscore (_).
{{PageSyntax}}
:[[$NOPREFIX]]
{{PageDescription}}
* 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]] allows you to reduce typing by not having to use underscores in modern keywords.
* '''SUB _GL''' still must be prefixed.
* When [[$NOPREFIX]] is used, QB64 keywords can be used both with or without the leading underscore, so that both [[_DISPLAY]] and [[_DISPLAY|DISPLAY]] are valid in the same program, for example.
* [[$NOPREFIX]] must be the first non-comment and non-whitespace line in a program.
** Since QB64 2.0 respectively QBPE 0.5 [[$NOPREFIX]] can be placed anywhere in a program.
{{PageAvailability}}
* '''QB64 1.4 and up''' (QB64 Team)
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
{{PageSeeAlso}}
* [[Keyword Reference - Alphabetical]]
* [[Metacommand]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,119 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:39:36}}
The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can be resized by the user.
{{PageSyntax}}
: [[$RESIZE]]:{ON|OFF|STRETCH|SMOOTH}
{{PageDescription}}
* $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.
{{PageAvailability}}
* '''QB64 1.0 and up''' (QB64 Team)
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
{{PageExamples}}
''Example:'' Resizing a program screen when the user changes it without clearing the entire screen image:
{{CodeStart}}
{{Cl|$RESIZE}}:ON
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(160, 140, 32)
{{Cl|_DELAY}} 0.1
{{Cl|_SCREENMOVE}} 20, 20
{{Cl|_DISPLAY}}
' CLEAR _RESIZE FLAG BY READING IT ONCE
temp& = {{Cl|_RESIZE (function)|_RESIZE}}
DO
{{Cl|_LIMIT}} 60
{{Cl|IF...THEN|IF}} CheckResize({{Cl|_SOURCE}}) = -1 {{Cl|THEN}}
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|CIRCLE}} ({{Cl|RND}} * {{Cl|_WIDTH (function)|_WIDTH}}(0) - 1, {{Cl|RND}} * {{Cl|_HEIGHT}}(0) - 1), {{Cl|RND}} * 100 + 5, {{Cl|_RGB32}}({{Cl|RND}} * 255, {{Cl|RND}} * 255, {{Cl|RND}} * 255)
{{Cl|NEXT}}
{{Cl|ELSE}}
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 200
{{Cl|PSET}} ({{Cl|RND}} * {{Cl|_WIDTH (function)|_WIDTH}}(0) - 1, {{Cl|RND}} * {{Cl|_HEIGHT}}(0) - 1), {{Cl|_RGB32}}({{Cl|RND}} * 255, {{Cl|RND}} * 255, {{Cl|RND}} * 255)
{{Cl|NEXT}}
{{Cl|END IF}}
{{Cl|_DISPLAY}}
k& = {{Cl|_KEYHIT}}
{{Cl|LOOP}} {{Cl|UNTIL}} k& = 27 {{Cl|OR (boolean)|OR}} k& = 32
{{Cl|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. *
' * *
' *************************************************************************************************
{{Cl|FUNCTION}} CheckResize (CurrentScreen {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}})
' *** Define local variable for temporary screen
{{Cl|DIM}} TempScreen {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}}
CheckResize = 0
' *** Check to see if the user resized the window. If so, change the SCREEN image to the correct size.
{{Cl|IF...THEN|IF}} {{Cl|_RESIZE (function)|_RESIZE}} {{Cl|THEN}}
' *** First, create a copy of the current {{Cl|SCREEN}} image.
TempScreen = {{Cl|_COPYIMAGE}}(CurrentScreen, 32)
' *** Set the {{Cl|SCREEN}} to the copied image, releasing the current SCREEN image.
{{Cl|SCREEN}} TempScreen
' *** Remove ({{Cl|TIMER (statement)|FREE}}) the original {{Cl|SCREEN}} image.
{{Cl|_FREEIMAGE}} CurrentScreen
' *** Create a new "original" {{Cl|SCREEN}} image.
CurrentScreen = {{Cl|_NEWIMAGE}}({{Cl|_RESIZEWIDTH}}, {{Cl|_RESIZEHEIGHT}}, 32)
' *** Set the {{Cl|SCREEN}} to the new "original" image, releasing the copied {{Cl|SCREEN}} image.
{{Cl|SCREEN}} CurrentScreen
' {{Cl|DRAW}} PREVIOUS {{Cl|SCREEN}} ON THE NEW ONE
{{Cl|_PUTIMAGE}} (0, 0), TempScreen, CurrentScreen
{{Cl|_DISPLAY}}
' *** Remove ({{Cl|TIMER (statement)|FREE}}) the copied {{Cl|SCREEN}} image.
{{Cl|_FREEIMAGE}} TempScreen
' *** Tell the caller there was a resize
CheckResize = -1
{{Cl|END IF}}
{{Cl|END FUNCTION}}
{{CodeEnd}}{{small|Code by waltersmind}}
{{PageSeeAlso}}
* [[_RESIZE]], [[_RESIZE (function)]]
* [[_RESIZEWIDTH]], [[_RESIZEHEIGHT]] {{text|(functions return the requested dimensions)}}
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,41 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:39:49}}
The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main program window throughout a program.
{{PageSyntax}}
: [[$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]] statement must be used before [[_SCREENSHOW]] can be used in sections of a program.
* '''QB64 [[Metacommand|metacommand]]s cannot be commented out with [[apostrophe]] or [[REM]]'''.
{{PageExamples}}
''Example:'' Hiding a program when displaying a message box in Windows.
{{CodeStart}}
{{Cl|$SCREENHIDE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "user32"
{{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hWnd%&, {{Cl|BYVAL}} lpText%&, {{Cl|BYVAL}} lpCaption%&, {{Cl|BYVAL}} uType~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "kernel32"
{{Cl|SUB}} ExitProcess ({{Cl|BYVAL}} uExitCode~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DIM}} s0 {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} s1 {{Cl|AS}} {{Cl|STRING}}
s0 = "Text" + {{Cl|CHR$}}(0)
s1 = "Caption" + {{Cl|CHR$}}(0)
ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET (function)|_OFFSET}}(s1), 0)
{{CodeEnd}}{{small|Code by Michael Calkins}}
{{PageSeeAlso}}
* [[$CONSOLE]], [[$SCREENSHOW]]
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[_CONSOLE]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,25 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:39:56}}
The [[$SCREENSHOW]] [[Metacommand|metacommand]] can be used to display the main program window throughout the program.
{{PageSyntax}}
: $SCREENSHOW
{{PageDescription}}
* 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]] or [[_SCREENHIDE]] have been used in another program module.
* If [[$SCREENHIDE]] and then [[$SCREENSHOW]] are used in the same program module the window will not be hidden.
* '''QB64 [[Metacommand|metacommand]]s cannot be commented out with [[apostrophe]] or [[REM]].'''
{{PageSeeAlso}}
* [[$CONSOLE]], [[$SCREENHIDE]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[_CONSOLE]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,40 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:45:04}}
The [[$STATIC]] [[Metacommand|metacommand]] allows the creation of static (unresizable) arrays.
{{PageSyntax}}
:{[[REM]] | [[apostrophe|']] } [[$STATIC]]
{{PageDescription}}
* QBasic [[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]].
* A [[REDIM]] statement has no effect on [[$STATIC]] arrays except perhaps a [[ERROR Codes|duplicate definition error]] at the [[REDIM]] statement.
* The array's type cannot be changed once [[DIM]] and a literal value sets the dimensions and element size.
* [[$STATIC]] defined program [[arrays]] cannot be [[REDIM|re-sized]] or use [[_PRESERVE]].
{{PageExamples}}
''Example:'' When a variable is used, the array can be resized despite $STATIC. The array becomes [[$DYNAMIC]].
{{CodeStart}}
'{{Cl|$STATIC}}
{{Cl|INPUT}} "Enter array size: ", size
{{Cl|DIM}} array(size) 'using an actual number instead of the variable will create an error!
{{Cl|REDIM}} array(2 * size)
{{Cl|PRINT}} {{Cl|UBOUND}}(array)
{{CodeEnd}}
: ''Note:'' [[DIM]] using a literal numerical size will create a Duplicate definition error.
{{PageSeeAlso}}
* [[$DYNAMIC]], [[STATIC]]
* [[Arrays]], [[Metacommand]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,45 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:46}}
The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resulting executable for identification purposes across the OS. Windows-only.
{{PageSyntax}}
: [[$VERSIONINFO]]:{{Parameter|key}}={{Parameter|value}}
{{PageParameters}}
* Text ''keys'' can be: '''Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Web'''
* Numeric {{Parameter|keys}} can be:'''FILEVERSION#''' and '''PRODUCTVERSION#'''
**When provided, the numerical keys '''FILEVERSION#''' and '''PRODUCTVERSION#''' will also provide values to the text keys '''FileVersion''' and '''ProductVersion,''' if the text versions are not provided separately. (QBPE 0.6 and up (QB64 Phoenix Edition))
{{PageDescription}}
* 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_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
{{PageAvailability}}
* '''QB64 1.2 and up''' (QB64 Team)
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
{{PageExamples}}
''Example:'' Adding metadata to a Windows exe compiled with QB64:
{{CodeStart}}
{{Cl|$VERSIONINFO}}:CompanyName=Your company name goes here
{{Cl|$VERSIONINFO}}:FILEVERSION#=1,0,0,0
{{Cl|$VERSIONINFO}}:PRODUCTVERSION#=1,0,0,0
{{CodeEnd}}
{{PageSeeAlso}}
* [[$EXEICON]]
* [[_ICON]]
* [https://msdn.microsoft.com/library/windows/desktop/aa381058(v=vs.85).aspx VERSIONINFO resource (MSDN)]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,31 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:48}}
The ({{Text|now deprecated|red}}) '''$VIRTUALKEYBOARD''' [[metacommand]] did turn the virtual keyboard ON or OFF.
{{PageSyntax}}
: '''$VIRTUALKEYBOARD:ON'''
: '''$VIRTUALKEYBOARD:OFF'''
{{PageDescription}}
* This metacommand did not require a comment ''[[Apostrophe|']]'' or [[REM]] before it. There was no space between the metacommand name, the colon and the ON/OFF parameter.
* It placed a virtual keyboard on screen, which could be used in touch-enabled devices like Windows tablets.
* {{Text|Deprecated|red}}, in all current versions of QB64 it just generates a warning now, but has no other effect anymore.
{{PageExamples}}
{{CodeStart}}
{{Cl|$VIRTUALKEYBOARD|$VIRTUALKEYBOARD:ON}}
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27)
{{CodeEnd}}
{{PageSeeAlso}}
* [[Metacommand]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,59 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:02}}
The [[&B]] prefix denotes that an integer value is expressed in a Binary base 2 format. Every 8 digits represent a [[_BYTE]].
{{PageSyntax}}
: {{Parameter|a&}} = [[&B]]10010110
{{PageDescription}}
* The base 2 numbering system uses binary digit values of 0 and 1 only.
* 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]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
:* [[_BYTE]]: 8 binary digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255.
:* [[INTEGER]]: 16 binary digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535.
:* [[LONG]]: 32 binary digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295.
:* [[_INTEGER64]]: 64 binary digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
:* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615.
* The maximum binary value for each numerical type is the maximum number of digits listed above, each valued at '''1'''.
* Convert binary to [[LONG]] values by appending the values with the suffix '''&'''. Example: [[&B]]1000000000000000 = -32768: [[&B]]1000000000000000'''&''' = 32768
* To convert binary strings returned from [[_BIN$]] with [[VAL]] you need to prefix the string with [[&B]] (for example, if the string is "1101" you should do {{InlineCode}}{{Cl|VAL}}("&B1101"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&B" + binvalue$){{InlineCodeEnd}}.
{{PageExamples}}
;Example 1:The maximum binary values of decimal value -1 in each numerical type are:
{{CodeStart}}
c&& = -1: d& = -1: e% = -1: f%% = -1
bi$ = {{Cl|_BIN$}}(f%%)
{{Cl|PRINT}} "Max binary {{Cl|_BYTE}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$)
bi$ = {{Cl|_BIN$}}(e%)
{{Cl|PRINT}} "Max binary {{Cl|INTEGER}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$)
bi$ = {{Cl|_BIN$}}(d&)
{{Cl|PRINT}} "Max binary {{Cl|LONG}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$)
bi$ = {{Cl|_BIN$}}(c&&)
{{Cl|PRINT}} "Max binary {{Cl|_INTEGER64}} = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits ="; {{Cl|VAL}}("{{Cl|&B}}" + bi$)
bi$ = {{Cl|_BIN$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits"
bi$ = {{Cl|_BIN$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; bi$; " with"; {{Cl|LEN}}(bi$); "digits"
{{CodeEnd}}
{{OutputStart}}
Max binary _BYTE = 11111111 with 8 digits = 255
Max binary INTEGER = 1111111111111111 with 16 digits = 65535
Max binary LONG = 11111111111111111111111111111111 with 32 digits = 4294967295
Max binary _INTEGER64 = 1111111111111111111111111111111111111111111111111111111111111111 with 64 digits =-1
Max _INTEGER64 value = 111111111111111111111111111111111111111111111111111111111111111 with 63 digits
Min _INTEGER64 value = 1000000000000000000000000000000000000000000000000000000000000000 with 64 digits
{{OutputEnd}}
{{PageSeeAlso}}
* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]]
* [[&H]] (hexadecimal), [[&O]] (octal), [[VAL]]
* [[Base Comparisons]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,96 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:05}}
The [[&H]] prefix denotes that an integer value is expressed in a Hexadecimal base 16 format. Every 2 digits represent a [[_BYTE]].
{{PageSyntax}}
: {{Parameter|a&}} = [[&H]]C0DEBA5E
{{PageDescription}}
* The base 16 numbering system uses hexadecimal digit values of 0 to F, where '''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]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
:* [[_BYTE]]: 2 hex digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255.
:* [[INTEGER]]: 4 hex digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535.
:* [[LONG]]: 8 hex digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295.
:* [[_INTEGER64]]: 16 hex digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
:* [[_UNSIGNED]] [[_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 the suffix '''&'''. Example: [[&H]]8000 = -32768: [[&H]]8000'''&''' = 32768
* [[LONG]] 32 bit [[_RGB]] values can be made using hexadecimal values from '''&HFF{{Text|00|red}}{{Text|00|green}}{{Text|00|blue}}''' to '''&HFF{{Text|FF|red}}{{Text|FF|green}}{{Text|FF|blue}}''' with full [[_ALPHA]] only.
* [[LONG]] 32 bit [[_RGBA]] values can be made using hexadecimal values from '''&H00{{Text|00|red}}{{Text|00|green}}{{Text|00|blue}}''' to '''&HFF{{Text|FF|red}}{{Text|FF|green}}{{Text|FF|blue}}''' with any [[_ALPHA]].
* Hexadecimal '''0x''' is often used to prefix [[HEX$]] port addresses in documentation. Replace '''0x''' with [[&H]] in QB64 or QBasic.
* To convert hexadecimal strings returned from [[HEX$]] with [[VAL]] you need to prefix the string with [[&H]] (for example, if the string is "FF" you should do {{InlineCode}}{{Cl|VAL}}("&HFF"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&H" + hexvalue$){{InlineCodeEnd}}.
{{PageExamples}}
;Example 1:The maximum hexadecimal values of decimal value -1 in each numerical type are:
{{CodeStart}}
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
hx$ = {{Cl|HEX$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{CodeEnd}}
{{OutputStart}}
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
{{OutputEnd}}
;Example 2:Converting a decimal number to a binary string value using [[HEX$]].
{{CodeStart}}
{{Cl|FUNCTION}} BIN$ (n&)
h$ = {{Cl|HEX$}}(n&) 'get hexadecimal string value
{{Cl|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(h$) 'scan the HEX$ digits
{{Cl|SELECT CASE}} {{Cl|MID$}}(h$, i, 1) 'read each HEX$ digit
{{Cl|CASE}} "0": b$ = b$ + "0000"
{{Cl|CASE}} "1": b$ = b$ + "0001"
{{Cl|CASE}} "2": b$ = b$ + "0010"
{{Cl|CASE}} "3": b$ = b$ + "0011"
{{Cl|CASE}} "4": b$ = b$ + "0100"
{{Cl|CASE}} "5": b$ = b$ + "0101"
{{Cl|CASE}} "6": b$ = b$ + "0110"
{{Cl|CASE}} "7": b$ = b$ + "0111"
{{Cl|CASE}} "8": b$ = b$ + "1000"
{{Cl|CASE}} "9": b$ = b$ + "1001"
{{Cl|CASE}} "A": b$ = b$ + "1010"
{{Cl|CASE}} "B": b$ = b$ + "1011"
{{Cl|CASE}} "C": b$ = b$ + "1100"
{{Cl|CASE}} "D": b$ = b$ + "1101"
{{Cl|CASE}} "E": b$ = b$ + "1110"
{{Cl|CASE}} "F": b$ = b$ + "1111"
{{Cl|END SELECT}}
{{Cl|NEXT}} i
b$ = {{Cl|RIGHT$}}(b$, {{Cl|LEN}}(b$) - {{Cl|INSTR}}(b$, "1") + 1) 'eliminate leading zeroes
{{Cl|IF}} {{Cl|VAL}}(b$) {{Cl|THEN}} BIN$ = b$ {{Cl|ELSE}} BIN$ = "0" 'return zero if n& = 0
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by CodeGuy}}
;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]] and everything from that point is kept removing the leading "0"'s.
;Note: Since QB64 2.1 (QB64 Team) respectively QBPE 0.5 (QB64 Phoenix Edition) the built-in [[_BIN$]] function should be used instead.
{{PageSeeAlso}}
* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]]
* [[&B]] (binary), [[&O]] (octal), [[VAL]]
* [[Base Comparisons]]
* [[HEX$ 32 Bit Values]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,60 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:03}}
The [[&O]] prefix denotes that an integer value is expressed in a Octal base 8 format.
{{PageSyntax}}
: {{Parameter|a&}} = [[&O]]377
{{PageDescription}}
* The base 8 numbering system uses octal digit values of 0 to 7 only.
* 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]], [[LONG]] integer, or [[_INTEGER64]] value so use those type of variables when converting directly as shown above in the Syntax. The program [[ERROR Codes|"overflow"]] error limits are listed as:
:* [[_BYTE]]: 3 octal digits or a decimal value range from -128 to 127. [[_UNSIGNED]]: 0 to 255.
:* [[INTEGER]]: 6 octal digits or a decimal value range from -32,768 to 32,767. [[_UNSIGNED]]: 0 to 65535.
:* [[LONG]]: 11 octal digits or a decimal value range from -2,147,483,648 to 2,147,483,647. [[_UNSIGNED]]: 0 to 4294967295.
:* [[_INTEGER64]]: 22 octal digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
:* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615.
* The maximum octal value for each numerical type is the maximum number of digits listed above, each valued at '''7''' (except the first digit).
** If the maximum number of digits is used, then the first digit (usually the highest significant position) may not be maxed out to '''7''', but only up to '''3''' ([[_BYTE]] and [[LONG]]) and up to '''1''' ([[INTEGER]] and [[_INTEGER64]]).
* Convert octal to [[LONG]] values by appending the values with the suffix '''&'''. Example: [[&O]]100000 = -32768: [[&O]]100000'''&''' = 32768
* To convert octal strings returned from [[OCT$]] with [[VAL]] you need to prefix the string with [[&O]] (for example, if the string is "377" you should do {{InlineCode}}{{Cl|VAL}}("&O377"){{InlineCodeEnd}} or {{InlineCode}}{{Cl|VAL}}("&O" + octvalue$){{InlineCodeEnd}}.
{{PageExamples}}
;Example 1:The maximum octal values of decimal value -1 in each numerical type are:
{{CodeStart}}
c&& = -1: d& = -1: e% = -1: f%% = -1
oc$ = {{Cl|OCT$}}(f%%)
{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(e%)
{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(d&)
{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(c&&)
{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits"
oc$ = {{Cl|OCT$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits"
{{CodeEnd}}
{{OutputStart}}
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
Max _INTEGER64 value = 777777777777777777777 with 21 digits
Min _INTEGER64 value = 1000000000000000000000 with 22 digits
{{OutputEnd}}
{{PageSeeAlso}}
* [[_BIN$]], [[HEX$]], [[OCT$]], [[STR$]]
* [[&B]] (binary), [[&H]] (hexadecimal), [[VAL]]
* [[Base Comparisons]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,23 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:07}}
The [[*]] mathematical operator performs the multiplication of two values.
{{PageSyntax}}
: {{Parameter|return_value}} = {{Parameter|number1}} [[*]] {{Parameter|number2}}
{{PageDescription}}
* Multiplication can use any two literal or variable numerical type values.
* Multiplication of two negative numbers returns a positive result. One negative number will always return a negative value.
* Return values may exceed certain numerical variable type limits creating an [[ERROR Codes|"Overflow" error.]]
* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations.
{{PageSeeAlso}}
* [[Mathematical Operations]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,30 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:00}}
The '''+''' plus mathematical operator performs addition on two numerical values or [[concatenation|concatenate]] [[STRING]] values.
''Syntax:'' return_value = number1 + number2
{{PageDescription}}
* A [[+]] sign also can indicate a positive numerical value, but it is not required.
* Numbers used can be any literal or variable numerical value type.
* Adding one negative value will actually perform subtraction on the other value.
* Adding two negative values will make the return value more negative.
* Addition and subtraction are the last operations performed in QBasic's normal order of operations.
* The [[+|plus(+)]] operator can also be used to add ([[concatenation|concatenate]]) literal or variable [[STRING]] values.
* [[PRINT]] can also use + operations on string values ONLY! Numerical values will need to be converted to strings first or be included using [[semicolon]]s or [[comma]]s instead.
''See also:''
[[-|- minus]] (subtraction or [[negation]] operator)
[[Mathematical Operations]]
{{PageNavigation}}

View file

@ -1,24 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:08}}
The [[/]] mathematical operator performs decimal point division on a numerical value.
{{PageSyntax}}
: {{Parameter|return_value}} = {{Parameter|number}} [[/]] {{Parameter|divisor}}
{{PageDescription}}
* Number value can be any literal or variable numerical type.
* Return values can be any literal or variable numerical type, but [[SINGLE]] or [[DOUBLE]] type decimal point returns are likely.
* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision.
* Use the [[\|\ integer division]] operator to guarantee [[INTEGER]] or [[LONG]] return values.
* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations.
{{PageSeeAlso}}
* [[Mathematical Operations]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,44 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:09}}
The [[\]] mathematical operator performs [[INTEGER]] division on a numerical value.
{{PageSyntax}}
: {{Parameter|return_value}} = {{Parameter|number}} [[\]] {{Parameter|divisor}}
{{PageDescription}}
* Number value can be any literal or variable numerical type.
* '''Divisor (second value) must not be a value of 0 to .5'''. This will create a [[ERROR Codes|"Division by zero" error!]] due to [[CINT]] rounding.
* Return values will be [[INTEGER]] or [[LONG]] value types only.
* Rounding is done to the closest EVEN [[INTEGER|integer]] or [[LONG|long integer]] value.
* Use the [[/|/ normal division]] operator for [[SINGLE]] or [[DOUBLE]] floating decimal point return values.
* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations.
{{PageExamples}}
;Example:Displays how floating decimal point values are rounded to the closest even [[INTEGER|integer]] value.
{{CodeStart}}
{{Cl|PRINT}} 0.5 \ 1
{{Cl|PRINT}} 1.5 \ 1
{{Cl|PRINT}} 2.5 \ 1
{{Cl|PRINT}} 3.5 \ 1
{{Cl|PRINT}} 4.5 \ 1
{{Cl|PRINT}} 5.5 \ 1
{{CodeEnd}}
{{OutputStart}}0
2
2
4
4
6
{{OutputEnd}}
{{PageSeeAlso}}
* [[Mathematical Operations]]
{{PageNavigation}}
[[Category:Final]]

View file

@ -1,29 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:54:06}}
The '''-''' mathematical operator performs subtraction on two numerical values or [[negation|negates]] a single value.
''Syntax:'' return_value = number1 - number2
{{PageDescription}}
* 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|negated]] 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]] values.
''See also:''
[[+|+ positive]] (addition operator)
[[Mathematical Operations]]
{{PageNavigation}}

View file

@ -1,41 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:54}}
The [[ABS]] function returns the unsigned numerical value of a variable or literal value.
{{PageSyntax}}
:{{Parameter|positive}} = [[ABS]]({{Parameter|numericalValue}})
{{PageDescription}}
* [[ABS]] always returns positive numerical values. The value can be any numerical type.
* Often used to keep a value positive when necessary in a program.
* Use [[SGN]] to determine a value's sign when necessary.
* '''QB64''' allows programs to return only positive [[_UNSIGNED]] variable values using a [[DIM]] or [[_DEFINE]] statement.
{{PageExamples}}
''Example:'' Finding the absolute value of positive and negative numerical values.
{{CodeStart}}
a = -6
b = -7
c = 8
{{Cl|IF...THEN|IF}} a < 0 {{Cl|THEN}} a = {{Cl|ABS}}(a)
b = {{Cl|ABS}}(b)
c = {{Cl|ABS}}(c)
{{Cl|PRINT}} a, b, c
{{CodeEnd}}
{{OutputStart}} 6 7 8
{{OutputEnd}}
{{PageSeeAlso}}
* [[SGN]], [[DIM]]
* [[_UNSIGNED]]
* [[_DEFINE]]
* [[Mathematical Operations]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,163 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:56}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
{{PageDescription}}
* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time.
* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.'''
* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below)
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3).
* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''.
: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system.
* [[OPEN COM]] can also be used for serial port access in '''QB64'''.
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
==Details==
===File ACCESS and LOCK Permissions===
* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network.
* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network.
* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records.
* If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.
===File Access Modes===
* FOR mode can be:
** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]].
** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.'''
** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.'''
** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode.
** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes)
** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number.
====GW-BASIC modes====
* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following:
** "A" = '''APPEND'''.
** "B" = '''BINARY'''.
** "I" = '''INPUT'''.
** "O" = '''OUTPUT'''.
** "R" = '''RANDOM'''.
{{PageExamples}}
''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK.
{{CodeStart}}
file$ = "Hello,~1.mp3" 'example call below
{{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors%
{{Cl|FUNCTION}} CheckName% (Filename$)
'{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call!
{{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}}
L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension
{{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}}
CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character"
code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes
{{Cl|SELECT CASE}} code% 'check for errors and highlight in red
'{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors'''
{{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors'''
{{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12
{{Cl|END SELECT}}
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}}
{{CodeEnd}}
''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64.
{{OutputStart}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}}
f% = {{Cl|FREEFILE}} 'should always be 1 at program start
{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f%
g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g%
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT
{{CodeEnd}}{{small|code by Steve McNeill}}
: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name.
''Example 3:'' Showcasing different file modes.
{{CodeStart}}
{{Cl|CLS}}
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted."
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted."
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1)
{{Cl|INPUT (file statement)|INPUT}} #1, a$
{{Cl|PRINT}} a$
{{Cl|LOOP}}
{{Cl|CLOSE}} #1
{{Cl|KILL}} "test.tst"
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
If test.tst didn't exist:
A new file was created named test.tst and then deleted.
If test.tst did exist:
It was overwritten with this and deleted.
{{OutputEnd}}
:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten.
{{PageSeeAlso}}
* [[PRINT (file statement)]], [[INPUT (file statement)]]
* [[GET]], [[PUT]], [[WRITE (file statement)]]
* [[INPUT$]], [[LINE INPUT (file statement)]]
* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]]
* [[SEEK (statement)]], [[SEEK]]
* [[OPEN COM]], [[LEN]], [[RESET]]
* [[FIELD]], [[TYPE]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}}
* [[_SNDOPEN]], [[_LOADIMAGE]]
{{PageNavigation}}

View file

@ -1,3 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:57}}
See page [[DECLARE LIBRARY]]

View file

@ -1,65 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:59}}
The [[AND (boolean)|AND]] conditonal operator is used to include another evaluation in an [[IF...THEN]] or [[Boolean]] statement.
{{PageSyntax}}
: IF {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}}
{{PageDescription}}
* If {{Parameter|condition}} [[AND (boolean)|AND]] {{Parameter|condition2}} are true then the evaluation returns true (-1).
* {{Parameter|condition}} and {{Parameter|condition2}} can also contain their own AND evaluations.
* Both the IF evaluation and the AND evaluation must be true for the statement to be true.
* Statements can use parenthesis to clarify an evaluation.
* [[AND (boolean)]] and [[OR (boolean)]] cannot be used to combine command line operations.
* Not to be confused with the [[AND]] and [[OR]] numerical operations.
{{RelationalTable}}
{{PageExamples}}
''Example:'' Using AND in an IF statement.
{{CodeStart}}
a% = 100
b% = 50
{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% < 200 {{Cl|THEN}} {{Cl|PRINT}} "True"
{{CodeEnd}}
{{OutputStart}}
True
{{OutputEnd}}
''Explanation:'' Both condition evaluations must be true for the code to be executed.
''Example:'' Using a AND a more complex way.
{{CodeStart}}
a% = 100
b% = 50
c% = 25
d% = 50
e% = 100
{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% < d% {{Cl|AND (boolean)|AND}} d% < e%) {{Cl|THEN}}
{{Cl|PRINT}} "True"
{{Cl|ELSE}}
{{Cl|PRINT}} "False"
{{Cl|END IF}}
{{CodeEnd}}
{{OutputStart}}
True
{{OutputEnd}}
''Explanation:'' The evaluations in the paranteses are evaluated first then the evaluation ''of'' the paranteses takes place, since all evaluations return True the IF...THEN evaluation returns True. If any of the evaluations returned False then the IF...THEN evaluation would also return False.
{{PageSeeAlso}}
* [[AND]], [[OR]] {{text|(logical operators)}}
* [[OR (boolean)]], [[XOR (boolean)]]
* [[IF...THEN]]
{{PageNavigation}}

View file

@ -1,78 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:58}}
The logical [[AND]] numerical operator compares two values in respect of their bits. If both bits at a certain position in both values are set, then that bit position is set in the result.
{{PageSyntax}}
:{{Parameter|result}} = {{Parameter|firstvalue}} AND {{Parameter|secondvalue}}
{{PageDescription}}
* [[AND]] compares the bits of the {{Parameter|firstvalue}} against the bits of the {{Parameter|secondvalue}}, the result is stored in the {{Parameter|result}} variable.
* If both bits are on (1) then the result is on (1).
* All other conditions return 0 (bit is off).
* AND is often used to see if a bit is on by comparing a value to an exponent of 2.
* Can turn off a bit by subtracting the bit on value from 255 and using that value to AND a byte value.
{{LogicalTruthTable}}
{{PageExamples}}
''Example 1:''
{{WhiteStart}}
101
AND
011
-----
001
{{WhiteEnd}}
:The 101 bit pattern equals 5 and the 011 bit pattern equals 3, it returns the bit pattern 001 which equals 1. Only the Least Significant Bits (LSB) match. So decimal values 5 AND 3 = 1.
''Example 2:''
{{WhiteStart}}
11111011
AND
11101111
----------
11101011
{{WhiteEnd}}
:Both bits have to be set for the resulting bit to be set. You can use the [[AND]] operator to get one byte of a two byte integer this way:
::firstbyte = twobyteint AND 255
:Since 255 is 11111111 in binary, it will represent the first byte completely when compared with AND.
:To find the second (HI) byte's decimal value of two byte [[INTEGER]]s use: secondbyte = twobyteint \ 256
''Example 3:'' Finding the binary bits on in an [[INTEGER]] value.
{{CodeStart}}
DO
{{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN {{Cl|EXIT DO}}
{{Cl|FOR...NEXT|FOR}} exponent = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} (INTvalue& {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|NEXT}}
PRINT " "
LOOP UNTIL INTvalue& = 0 'zero entry quits
{{CodeEnd}}
:Example output for 6055.
{{OutputStart}}
0001011110100111
{{OutputEnd}}
::''Note:'' The value of 32767 sets 15 bits. -1 sets all 16 bits. Negative values will all have the highest bit set. Use [[LONG]] variables for input values to prevent overflow errors.
{{PageSeeAlso}}
* [[OR]], [[XOR]], [[NOT]] {{text|(logical operators)}}
* [[AND (boolean)]]
* [[Binary]], [[Boolean]]
{{PageNavigation}}

View file

@ -1,163 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:03}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
{{PageDescription}}
* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time.
* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.'''
* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below)
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3).
* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''.
: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system.
* [[OPEN COM]] can also be used for serial port access in '''QB64'''.
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
==Details==
===File ACCESS and LOCK Permissions===
* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network.
* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network.
* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records.
* If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.
===File Access Modes===
* FOR mode can be:
** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]].
** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.'''
** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.'''
** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode.
** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes)
** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number.
====GW-BASIC modes====
* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following:
** "A" = '''APPEND'''.
** "B" = '''BINARY'''.
** "I" = '''INPUT'''.
** "O" = '''OUTPUT'''.
** "R" = '''RANDOM'''.
{{PageExamples}}
''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK.
{{CodeStart}}
file$ = "Hello,~1.mp3" 'example call below
{{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors%
{{Cl|FUNCTION}} CheckName% (Filename$)
'{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call!
{{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}}
L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension
{{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}}
CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character"
code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes
{{Cl|SELECT CASE}} code% 'check for errors and highlight in red
'{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors'''
{{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors'''
{{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12
{{Cl|END SELECT}}
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}}
{{CodeEnd}}
''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64.
{{OutputStart}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}}
f% = {{Cl|FREEFILE}} 'should always be 1 at program start
{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f%
g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g%
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT
{{CodeEnd}}{{small|code by Steve McNeill}}
: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name.
''Example 3:'' Showcasing different file modes.
{{CodeStart}}
{{Cl|CLS}}
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted."
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted."
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1)
{{Cl|INPUT (file statement)|INPUT}} #1, a$
{{Cl|PRINT}} a$
{{Cl|LOOP}}
{{Cl|CLOSE}} #1
{{Cl|KILL}} "test.tst"
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
If test.tst didn't exist:
A new file was created named test.tst and then deleted.
If test.tst did exist:
It was overwritten with this and deleted.
{{OutputEnd}}
:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten.
{{PageSeeAlso}}
* [[PRINT (file statement)]], [[INPUT (file statement)]]
* [[GET]], [[PUT]], [[WRITE (file statement)]]
* [[INPUT$]], [[LINE INPUT (file statement)]]
* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]]
* [[SEEK (statement)]], [[SEEK]]
* [[OPEN COM]], [[LEN]], [[RESET]]
* [[FIELD]], [[TYPE]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}}
* [[_SNDOPEN]], [[_LOADIMAGE]]
{{PageNavigation}}

View file

@ -1,49 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:06}}
The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a character at any position of a [[STRING]] variable.
{{PageSyntax}}
: [[ASC (statement)|ASC]]({{Parameter|stringExpression$}}[, {{Parameter|position%}}]) = {{Parameter|code%}}
{{PageDescription}}
* The {{Parameter|stringExpression$}} variable's value must have been previously defined and cannot be an empty string ("").
* {{Parameter|position%}} is optional. If no position is used, the leftmost character at position 1 is assumed.
* {{Parameter|position%}} cannot be zero or greater than the string's [[LEN|length]] or an [[ERROR Codes|Illegal function error]] will occur.
* The [[ASCII]] replacement {{Parameter|code%}} value can be any [[INTEGER]] value from 0 to 255.
* Some [[ASCII]] control characters will not [[PRINT]] a character or may format the [[SCREEN]]. [[_PRINTSTRING]] can print them graphically.
{{PageExamples}}
''Example:'' Demonstrates how to change existing text characters one letter at a time.
{{CodeStart}}
a$ = "YZC"
{{Cl|ASC (statement)|ASC}}(a$) = 65 ' CHR$(65) = "A"
{{Cl|ASC (statement)|ASC}}(a$, 2) = 66 ' CHR$(66) = "B"
{{Cl|PRINT}} a$ 'ABC
{{Cl|ASC (statement)|ASC}}(a$, 2) = 0 ' CHR$(0) = " "
{{Cl|PRINT}} a$
{{Cl|ASC (statement)|ASC}}(a$, 2) = {{Cl|ASC}}("S") ' get code value from ASC function
{{Cl|PRINT}} a$
{{CodeEnd}}
{{OutputStart}}
ABC
A C
ASC
{{OutputEnd}}
{{PageSeeAlso}}
* [[ASC]] {{text|(function)}}
* [[MID$ (statement)]]
* [[_PRINTSTRING]]
* [[INKEY$]], [[ASCII]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,170 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:05}}
The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] text character or a keyboard press.
{{PageSyntax}}
: {{Parameter|code%}} = [[ASC]]({{Parameter|text$}}[, {{Parameter|position%}}])
* {{Parameter|text$}} [[STRING|string]] character parameter must have a length of at least 1 byte or an error occurs.
* '''In QB64''' the optional byte {{Parameter|position%}} [[INTEGER]] parameter greater than 0 can specify the ASCII code of any character in a string to be returned.
* If the optional {{Parameter|position%}} parameter is omitted, ASC will return the [[ASCII]] code of the first [[STRING]] character.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned range from 0 to 255.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, function, Home/Page keys are used.
** Use QB64's {{Parameter|position%}} parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
* In '''QB64''' ASC string byte position reads are about '''5 times faster''' than [[MID$]] when parsing strings. See [[MID$]] ''Example 2''.
{{PageErrors}}
* If the function is used to read an '''empty string value''' an illegal function call [[ERROR Codes|error]] will occur. [[INKEY$]] returns an empty string when a key is not pressed.
* '''QB64''''s {{Parameter|position%}} parameters must range from 1 to the [[LEN|length]] of the string being read or an illegal function call [[ERROR Codes|error]] will occur.
{{WhiteStart}}' '''ASCII Keyboard Codes'''
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +133 +134 - - -
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45
''' 96 49 50 51 52 53 54 55 56 57 48 45 61''
'''' Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/▲ 9PU + '''
' 9 81 87 69 82 84 89 85 73 79 80 123 125 124 +83 +79 +81 +71 +72 +73 43
''' 113 119 101 114 116 121 117 105 111 112 91 93 92 55 56 57 ''
'''' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-►
' - 65 83 68 70 71 72 74 75 76 58 34 13 +75 +76 +77 '''E'''
''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n'''
'''' Shift Z X C V B N M ,< .> /? Shift ▲ 1End 2/▼ 3PD t'''
' * 90 88 67 86 66 78 77 60 62 63 * +72 +79 +80 +81 '''e'''
''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r'''
'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0Ins .Del '''
' * - * 32 * - - * +75 +80 +77 +82 +83 13
' '' 48 46''
'
' ''' ''Italics'' = LCase/NumLock On ____________ + = 2 Byte: CHR$(0) + CHR$(code)'''
'{{small|NOTE: The above commented table can be copied and pasted directly into the QB64 IDE}}
{{WhiteEnd}}
<center>'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''</center>
{{WhiteStart}} '''Two Byte Characters    Key                 CHR$(0) + "?" '''
CHR$(0) + CHR$(16-50) [Alt] + letter
CHR$(0) + CHR$(59) [F1] ";"
CHR$(0) + CHR$(60) [F2] "<"
CHR$(0) + CHR$(61) [F3] "="
CHR$(0) + CHR$(62) [F4] ">"
CHR$(0) + CHR$(63) [F5] "?"
CHR$(0) + CHR$(64) [F6] "@"
CHR$(0) + CHR$(65) [F7] "A"
CHR$(0) + CHR$(66) [F8] "B"
CHR$(0) + CHR$(67) [F9] "C"
CHR$(0) + CHR$(68) [F10] "D"
CHR$(0) + CHR$(71) [Home] "G"
CHR$(0) + CHR$(72) [↑] Arrow "H"
CHR$(0) + CHR$(73) [Page Up] "I"
CHR$(0) + CHR$(75) [←] Arrow "K"
CHR$(0) + CHR$(76) [5 NumberPad] "L" (NumLock off in QB64)
CHR$(0) + CHR$(77) [→] Arrow "M"
CHR$(0) + CHR$(79) [End] "O"
CHR$(0) + CHR$(80) [↓] Arrow "P"
CHR$(0) + CHR$(81) [Page Down] "Q"
CHR$(0) + CHR$(82) [Insert] "R"
CHR$(0) + CHR$(83) [Delete] "S"
CHR$(0) + CHR$(84-93) [Shift] + F1-10
CHR$(0) + CHR$(94-103) [Ctrl] + F1-10
CHR$(0) + CHR$(104-113) [Alt] + F1-10
CHR$(0) + CHR$(114-119) [Ctrl] + keypad
CHR$(0) + CHR$(120-129) [Alt] + number
CHR$(0) + CHR$(130 or 131) [Alt] + _/- or +/= "é" or "â"
CHR$(0) + CHR$(133) [F11] "à"
CHR$(0) + CHR$(134) [F12] "å"
CHR$(0) + CHR$(135) [Shift] + [F11] "ç"
CHR$(0) + CHR$(136) [Shift] + [F12] "ê"
CHR$(0) + CHR$(137) [Ctrl] + [F11] "ë"
CHR$(0) + CHR$(138) [Ctrl] + [F12] "è"
CHR$(0) + CHR$(139) [Alt] + [F11] "ï"
CHR$(0) + CHR$(140) [Alt] + [F12] "î"
{{WhiteEnd}}
:In '''QB64''', [[CVI]] can be used to get the [[_KEYDOWN]] 2-byte code value. Example: IF _KEYDOWN([[CVI]]([[CHR$]](0) + "P")) THEN
{{PageExamples}}
''Example 1:'' How ASC can be used to find any ASCII code in a string of characters using QB64.
{{CodeStart}}
{{Cl|PRINT}} {{Cl|ASC}}("A")
{{Cl|PRINT}} {{Cl|ASC}}("Be a rockstar")
{{Cl|PRINT}} {{Cl|ASC}}("QB64 is not only COMPATIBLE, it can find any part of the string!", 18)
{{CodeEnd}}
''Returns:''
{{OutputStart}}
65
66
67
{{OutputEnd}}
''Explanation:'' The ASCII code for "A" is 65 and the ASCII code for "B" is 66, ASCII code for "C" is 67 and the "C" is at position 18 in the string.
::''Note:'' The ASCII code for "A" and "a" are different by the value of 32, "A" + 32 is "a", 65("A") + 32 = 97("a").
''Example 2:'' Reading the ASCII and two byte code combinations with ASC in '''QB64'''.
{{CodeStart}}
Q$ = {{Cl|CHR$}}(34) ' quote character
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 5, 22: {{Cl|PRINT}} "Press some keys or combinations!"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 23, 30: {{Cl|PRINT}} "Escape key Quits"
{{Cl|DO}}
{{Cl|DO}}: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ <> "" ' prevent ASC empty string read error
code% = {{Cl|ASC}}(key$): {{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 10
{{Cl|IF...THEN|IF}} code% {{Cl|THEN}} ' ASC returns any value greater than 0
{{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(code%)) + ")" + {{Cl|SPACE$}}(13):
{{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% < 14 {{Cl|THEN}} code% = 32 ' unprintable control codes
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} {{Cl|CHR$}}(code%) + {{Cl|SPACE$}}(13)
{{Cl|ELSE}}: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(key$, 2))) + ")"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + " + Q$ + {{Cl|CHR$}}({{Cl|ASC}}(key$, 2)) + Q$
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} code% = 27 '' '
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The keypress read loop checks that ASC will not read an empty string. That would create a program error. [[SLEEP]] reduces CPU memory usage between keypresses. Normal byte codes returned are indicated by the IF statement when ASC returns a value. Otherwise the routine will return the two byte ASCII code. The extended keyboard keys(Home pad, Arrow pad and Number pad), Function keys or Ctrl, Alt or Shift key combinations will return two byte codes. Ctrl + letter combinations will return control character codes 1 to 26.
''Example 3:'' Reading only numerical values input by a program user.
{{CodeStart}}
{{Cl|DO}}: {{Cl|SLEEP}} ' requires a keypress to run loop once
K$ = {{Cl|INKEY$}}
code = {{Cl|ASC}}(K$)
{{Cl|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code <= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|CHR$}}(code) ' numbers only
{{Cl|IF}} code = 46 {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}}
entry$ = entry$ + K$: flag = 1: mark = {{Cl|LEN}}(entry$) ' decimal point
{{Cl|END IF}}
L = {{Cl|LEN}}(entry$) ' check entry length for possible backspace
{{Cl|IF}} code = 8 {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
entry$ = {{Cl|MID$}}(entry$, 1, L - 1) ' remove one character from entry$
{{Cl|IF}} L - 1 < mark {{Cl|THEN}} flag = 0 ' allow another decimal point if removed.
{{Cl|LOCATE}} 10, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|SPACE$}}(1); ' remove character from screen
{{Cl|END IF}}
{{Cl|LOCATE}} 10, 10: {{Cl|PRINT}} entry$;
' display present entry to user(semicolon required for correct POS return)
{{Cl|LOOP}} {{Cl|UNTIL}} code = 13 {{Cl|AND}} L
{{CodeEnd}}
''Explanation:'' [[SLEEP]] waits for a keypress allowing background programs to use the processor time. It also keeps the press in the keyboard buffer for [[INKEY$]] to read and guarantees that ASC will not read an empty string value to create an error. Filtered codes 48 to 57 are only number characters. One decimal point is allowed by using the flag. Code 8 is a backspace request which is ignored if the entry has no characters. If it is allowed it removes the last character from the entry and the screen. The loop exits when the user presses the [Enter] key and the entry has a length.
{{Parameter|See also:'' }}
* [[ASC (statement)]]
* [[_KEYHIT]], [[_KEYDOWN]]
* [[MID$]], [[CHR$]], [[INKEY$]]
* [[VAL]], [[STRING$]]
* [[ASCII]], [[_MAPUNICODE]]
* [[Scancodes]]
{{PageNavigation}}
[[Category:Latest]]

View file

@ -1,35 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:04}}
The [[AS]] keyword defines a variable data [[type]].
{{PageDescription}}
* AS defines the variable or array type AS [[_BIT]], [[_BYTE]], [[INTEGER]], [[LONG]], [[_INTEGER64]], [[SINGLE]], [[DOUBLE]], [[_FLOAT]] or [[STRING]].
* Specifies a variable's [[type]] in a declarative statement or parameter list using:
** [[DIM]] or [[REDIM]]
** [[DECLARE LIBRARY]]
** [[SUB]]
** [[FUNCTION]]
** [[TYPE]]
** [[SHARED]]
** [[COMMON SHARED]]
** [[STATIC]]
===Details===
* Specifies a '''[[parameter]]''' variable's type in a [[SUB]] or [[FUNCTION]] procedure. '''Cannot be used to define a function's [[type]]'''
* Specifies an element's type in a user-defined data [[TYPE]].
* Assigns a file number to a file or device in an [[OPEN]] statement.
* Specifies a field name in a random-access record (see [[FIELD]])
* Specifies a new file name when you rename a file (see [[NAME]])
* '''NOTE: Many QBasic keywords can be used as variable names if they are created as [[STRING]]s using the suffix '''$'''. You cannot use them without the suffix, use a numerical suffix or use [[DIM]], [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]] statements.'''
{{PageSeeAlso}}
* [[DIM]], [[REDIM]]
* [[_DEFINE]]
* [[BYVAL]], [[TYPE]]
* [[Variable Types]]
{{PageNavigation}}

View file

@ -1,90 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:08}}
The [[ATN]] or arctangent function returns the angle in radians of a numerical [[TAN|tangent]] value.
{{PageSyntax}}
: {{Parameter|radianAngle}} = [[ATN]]({{Parameter|tangent!}})
{{Parameters}}
* The return is the {{Parameter|tangent!}}'s angle in '''radians'''.
* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
{{PageDescription}}
* To convert from radians to degrees, multiply radians * (180 / ã).
* The ''tangent'' value would be equal to the tangent value of an angle. Ex: '''{{text|[[TAN]](ATN(1)) <nowiki>=</nowiki> 1|green}}'''
* The function return value is between -ã / 2 and ã / 2.
{{PageExamples}}
''Example 1:'' When the [[TAN]]gent value equals 1, the line is drawn at a 45 degree angle (.7853982 radians) where [[SIN]] / [[COS]] = 1.
{{CodeStart}}
{{Cl|SCREEN}} 12
x = 100 * {{Cl|COS}}({{Cl|ATN}}(1))
y = 100 * {{Cl|SIN}}({{Cl|ATN}}(1))
{{Cl|LINE}} (200, 200)-(200 + x, 200 + y)
{{CodeEnd}}
''Example 2:'' [[ATN]] can be used to define ã in [[SINGLE]] or [[DOUBLE]] precision. The calculation cannot be used as a [[CONST]]ant.
{{CodeStart}}
Pi = 4 * {{Cl|ATN}}(1) '{{Cl|SINGLE}} precision
Pi# = 4 * {{Cl|ATN}}(1#) '{{Cl|DOUBLE}} precision
PRINT Pi, Pi#
{{CodeEnd}}
:''Note:'' You can use QB64's native [[_PI]] function.
''Example 3:'' Finds the angle from the center point to the mouse pointer.
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
x1! = 320
y1! = 240
DO
{{Cl|PRESET}} (x1!, y1!), {{Cl|_RGB}}(255, 255, 255)
dummy% = {{Cl|_MOUSEINPUT}}
x2! = {{Cl|_MOUSEX}}
y2! = {{Cl|_MOUSEY}}
{{Cl|LINE}} (x1, y1)-(x2, y2), {{Cl|_RGB}}(255, 0, 0)
{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} getangle(x1!, y1!, x2!, y2!)
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 200
{{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> ""
{{Cl|END}}
{{Cl|FUNCTION}} getangle# (x1#, y1#, x2#, y2#) 'returns 0-359.99...
{{Cl|IF...THEN|IF}} y2# = y1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x1# = x2# {{Cl|THEN}} {{Cl|EXIT FUNCTION}}
{{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}} getangle# = 90 {{Cl|ELSE}} getangle# = 270
{{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} x2# = x1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} y2# > y1# {{Cl|THEN}} getangle# = 180
{{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|IF...THEN|IF}} y2# < y1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131
{{Cl|ELSE}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 360
{{Cl|END IF}}
{{Cl|ELSE}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 180
{{Cl|END IF}}
{{Cl|END FUNCTION}}
{{CodeEnd}}{{small|Function by Galleon}}
{{PageSeeAlso}}
* [[_PI]] {{text|(QB64 function)}}
* [[TAN]] {{text|(tangent function)}}
* [[SIN]], [[COS]]
* [[Mathematical Operations]]
* [[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]]
{{PageNavigation}}

View file

@ -1,27 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:53:55}}
The '''apostrophe''' is used to tell the compiler to ignore a statement or programmer comment.
{{PageDescription}}
* Allows programmer comments or temporary code removal.
* [[REM]] can also be used to "comment out" a line.
* QBasic [[Metacommand|metacommand]]s must be commented either with an apostrophe or [[REM]].
* [[$INCLUDE]] requires an apostrophe before and after the included file name.
{{PageExamples}}
{{CodeStart}}
COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{CodeEnd}}
{{OutputStart}}
{{text|Print this....|aqua}}
{{OutputEnd}}
{{PageSeeAlso}}
* [[Comma]], [[Semicolon]]
* [[REM]]
{{PageNavigation}}

View file

@ -1,26 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:09}}
The [[BEEP]] statement produces a beep sound through the sound card.
{{PageSyntax}}
: [[BEEP]]
{{PageDescription}}
* [[BEEP]] can be placed anywhere to alert the user that there is something to do or an error has occurred.
* '''QB64''' produces the actual "beep" sound through the PC's sound card, to emulate QBasic's beeping through the [https://en.wikipedia.org/wiki/PC_speaker PC speaker].
==QBasic/QuickBASIC==
* Older programs may attempt to produce a BEEP by printing [[CHR$]](7) to the screen. This is no longer supported in QB64 after '''version 1.000'''.
** You may have to replace instances of PRINT CHR$(7) in older programs to the [[BEEP]] statement to maintain the legacy functionality.
{{PageSeeAlso}}
* [[SOUND]], [[PLAY]]
* [[_SNDPLAY]] {{text|(play sound files)}}
* [[_SNDRAW]] {{text|(play frequency waves)}}
{{PageNavigation}}

View file

@ -1,163 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:10}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
{{PageDescription}}
* '''QB64''' can open as many files as your computer memory can handle. QBasic could only open about 15 at a time.
* '''QB64 will allocate 4 bytes of memory for every possible file number up to the highest number used in a program.'''
* {{Parameter|mode}} defaults to RANDOM if the {{Parameter|mode}} or FOR access statement is omitted. (see open modes described below)
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
* The '''"SCRN:"''' device is supported in '''version 1.000 and up''' (see Example 3).
* '''Devices such as "KYBD:", "CONS:", "COMn" and "LPTn:" are [[Keywords currently not supported by QB64|not supported in QB64.]]'''.
: '''Note:''' OPEN "LPTn" is not supported by QB64, but may be supported directly by your operating system.
* [[OPEN COM]] can also be used for serial port access in '''QB64'''.
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
==Details==
===File ACCESS and LOCK Permissions===
* [[ACCESS]] clause limits file access to READ, WRITE or READ WRITE on a network.
* [[LOCK (access)|LOCK]] clause can specify SHARED or a LOCK READ or LOCK WRITE file lock in an OPEN statement working on a network.
* A separate [[LOCK]] statement can lock or [[UNLOCK]] file access on a network using a format that can lock specific records.
* If another process already has access to a specified file, program access is denied for that file OPEN access. A "Permission Denied" error 70 will be returned. A network program must be able to handle a denial of access error.
===File Access Modes===
* FOR mode can be:
** '''OUTPUT''': Sequential mode creates a new file or erases an existing file for new program output. Use [[WRITE (file statement)|WRITE #]] to write numerical or text data or [[PRINT (file statement)|PRINT #]] for text. '''OUTPUT clears files of all data''' and clears the receive buffer on other devices such as [[ON COM(n)|COM]].
** '''APPEND''': Sequential mode creates a new file if it doesn't exist or appends program output to the end of an existing file. Use [[WRITE (file statement)|WRITE #]] for numerical or text data or [[PRINT (file statement)|PRINT #]] for text as in the OUTPUT mode. '''APPEND does not remove previous data.'''
** '''INPUT''' : Sequential mode '''only reads input''' from an existing file. '''[[ERROR Codes|File error]] if file does not exist.''' Use [[INPUT (file statement)|INPUT #]] for comma separated numerical or text data and [[LINE INPUT (file statement)|LINE INPUT #]] or [[INPUT$]] to only read text data. '''Use [[_FILEEXISTS]] or [[_DIREXISTS]] to avoid errors.'''
** '''BINARY''': Creates a new file when it doesn't exist or reads and writes to an existing binary file. Use [[GET|GET #]] to read or [[PUT|PUT #]] to write byte positions simultaneously. [[LEN]] = statements are ignored in this mode.
** '''RANDOM''': Creates a new file when it doesn't exist or reads or writes to an existing random file record. Use [[GET|GET #]] or [[PUT|PUT #]] to read or write to file records. A [[LEN]] = statement can define the byte size of a record (no LEN statement defaults to 128 bytes)
** Modes '''INPUT''', '''BINARY''' and '''RANDOM''' allow a file to be concurrently opened in a different mode and number.
====GW-BASIC modes====
* ''Mode letter'' is a variable or literal [[STRING]] letter value as one of the following:
** "A" = '''APPEND'''.
** "B" = '''BINARY'''.
** "I" = '''INPUT'''.
** "O" = '''OUTPUT'''.
** "R" = '''RANDOM'''.
{{PageExamples}}
''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK.
{{CodeStart}}
file$ = "Hello,~1.mp3" 'example call below
{{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors%
{{Cl|FUNCTION}} CheckName% (Filename$)
'{{Cl|NOT}}E: Function also displays filename errors so {{Cl|LOCATE}} on screen before call!
{{Cl|DIM}} L {{Cl|AS}} {{Cl|INTEGER}}, DP {{Cl|AS}} {{Cl|INTEGER}}, XL {{Cl|AS}} {{Cl|INTEGER}}
L = {{Cl|LEN}}(Filename$): DP = {{Cl|INSTR}}(Filename$, "."): {{Cl|IF...THEN|IF}} DP {{Cl|THEN}} XL = L - DP 'extension
{{Cl|IF...THEN|IF}} L = 0 {{Cl|OR (boolean)|OR}} L > 12 {{Cl|OR (boolean)|OR}} DP > 9 {{Cl|OR (boolean)|OR}} XL > 3 {{Cl|THEN}}
CheckName% = -1: {{Cl|COLOR}} 12: {{Cl|PRINT}} "Illegal format!"; : {{Cl|EXIT FUNCTION}}
{{Cl|END IF}}
{{Cl|FOR...NEXT|FOR}} i% = 1 {{Cl|TO}} L 'check each filename character"
code% = {{Cl|ASC}}({{Cl|MID$}}(Filename$, i%, 1)): {{Cl|COLOR}} 10 ' see ASCII codes
{{Cl|SELECT CASE}} code% 'check for errors and highlight in red
'{{Cl|CASE}} 34, 42 {{Cl|TO}} 44, 47, 58 {{Cl|TO}} 63, 91 {{Cl|TO}} 93, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QBasic errors'''
{{Cl|CASE}} 34, 42, 47, 58, 60, 62, 92, 124: E% = E% + 1: {{Cl|COLOR}} 12 ' '''QB64 errors'''
{{Cl|CASE}} 46: dot% = dot% + 1: {{Cl|IF...THEN|IF}} dot% > 1 {{Cl|THEN}} E% = E% + 1: {{Cl|COLOR}} 12
{{Cl|END SELECT}}
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}}
{{CodeEnd}}
''Note: The QBasic character error list is commented out and the function will return invalid filenames under QB64.
{{OutputStart}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}}
f% = {{Cl|FREEFILE}} 'should always be 1 at program start
{{Cl|OPEN}} "SCRN:" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #f%
g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|OPEN}} "temp.txt" {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #g%
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT
{{CodeEnd}}{{small|code by Steve McNeill}}
: ''Note:'' Linux or Mac file names can use a path destination such as ".\SCRN:" to use SCRN: as an actual file name.
''Example 3:'' Showcasing different file modes.
{{CodeStart}}
{{Cl|CLS}}
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst didn't exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "A new file was created named test.tst and then deleted."
{{Cl|PRINT (file statement)|PRINT}} #1, "If test.tst did exist:"
{{Cl|PRINT (file statement)|PRINT}} #1, "It was overwritten with this and deleted."
{{Cl|CLOSE}} #1
{{Cl|OPEN}} "test.tst" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1)
{{Cl|INPUT (file statement)|INPUT}} #1, a$
{{Cl|PRINT}} a$
{{Cl|LOOP}}
{{Cl|CLOSE}} #1
{{Cl|KILL}} "test.tst"
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
If test.tst didn't exist:
A new file was created named test.tst and then deleted.
If test.tst did exist:
It was overwritten with this and deleted.
{{OutputEnd}}
:'''Warning:''' Make sure you don't have a file named test.tst before you run this or it will be overwritten.
{{PageSeeAlso}}
* [[PRINT (file statement)]], [[INPUT (file statement)]]
* [[GET]], [[PUT]], [[WRITE (file statement)]]
* [[INPUT$]], [[LINE INPUT (file statement)]]
* [[CLOSE]], [[LOF]], [[EOF]], [[LOC]]
* [[SEEK (statement)]], [[SEEK]]
* [[OPEN COM]], [[LEN]], [[RESET]]
* [[FIELD]], [[TYPE]]
* [[_FILEEXISTS]], [[_DIREXISTS]]
* [[_OPENCLIENT]], [[_OPENHOST]], [[_OPENCONNECTION]] {{text|(TCP/IP)}}
* [[_SNDOPEN]], [[_LOADIMAGE]]
{{PageNavigation}}

View file

@ -1,57 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:11}}
[[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array.
{{PageSyntax}}
: [[BLOAD]] {{Parameter|fileName$}}, [[VARPTR]]({{Parameter|imageArray%({{Parameter|index}})}})
===Legacy support===
* '''QB64''' can load larger arrays directly from binary files using [[PUT]] # and [[GET]] # without '''BLOAD'''. For that reason, '''BLOAD''' isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
{{Parameters}}
* {{Parameter|fileName$}} is the name of the file that the image should be [[BSAVE]]d to.
* {{Parameter|imageArray%(index)}} is the [[INTEGER]] [[arrays|array]] start index to store the image loaded.
{{PageDescription}}
* There must be an [[INTEGER]] array of adequate size (up to 26K) to hold the graphic data.
* A [[DEF SEG]] pointing to the array is required. [[DEF SEG]] = [[VARSEG]](imageArray%(index))
* {{Parameter|index}} is the starting image element of the Array. Can also include RGB color settings at the start index.
* Fullscreen images in [[SCREEN]] 12 require 3 file BLOADs. A 26K array can hold 1/3 of screen.
* Custom RGB color settings can be embedded(indexed) at the start of the image array.
* BLOAD can be used to load any array that was saved with [[BSAVE]], not just graphics.
* Array sizes are limited to 32767 Integer elements due to use of [[VARPTR]] in QBasic and '''QB64''''s emulated conventional memory.
{{PageExamples}}
''Example 1:'' Loading data to an array from a BSAVED file.
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0))
{{Cl|BLOAD}} filename$, {{Cl|VARPTR}}(Array({{Cl|LBOUND}}(Array))) ' changeable index
{{Cl|DEF SEG}}
{{CodeEnd}}
:''Explanation:'' Referance any type of array that matches the data saved. Can work with Integer, Single, Double, Long, fixed length Strings or [[TYPE]] arrays. [[LBOUND]] determines the starting offset of the array or another index could be used.
''Example 2:'' Using a QB default colored image.
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image%(0)) ' pointer to first image element of an array
{{Cl|BLOAD}} FileName$, {{Cl|VARPTR}}(Image%(0)) ' place data into array at index position 0
{{Cl|PUT (graphics statement)|PUT}}(Col, Row), Image%(0), PSET ' Put the image on the screen from index 0
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Note:'' [[PSET]] is used as a [[PUT (graphics statement)|PUT]] action that places the image over any background objects.
{{PageSeeAlso}}
* [[BSAVE]], [[OPEN]], [[BINARY]]
* [[PUT]], [[GET]] {{text|(file statement)}}
* [[GET (graphics statement)]], [[PUT (graphics statement)]]
* [[VARSEG]], [[VARPTR]]
* [[DEF SEG]]
* [[Text Using Graphics]]
{{PageNavigation}}

View file

@ -1,106 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:12}}
[[BSAVE]] saves the contents of an image array to a [[BINARY]] file.
{{PageSyntax}}
: [[BSAVE]] {{Parameter|saveFile$}}, [[VARPTR]]({{Parameter|array(index)}}), {{Parameter|fileSize&}}
===Legacy support===
* '''QB64''' can save larger arrays directly to binary files using [[PUT]] # and [[GET]] # without '''BSAVE'''. For that reason, '''BSAVE''' isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
{{Parameters}}
* {{Parameter|saveFile$}} is the STRING file name of the file designated to be created.
* {{Parameter|array(index)}} is the image [[arrays|array]] that already holds the [[GET (graphics statement)|GET]] image data.
* {{Parameter|fileSize&}} must be a bit over twice the size of the elements used in an [[INTEGER]] [[Arrays|array]].
{{PageDescription}}
* To place image data into the array, use [[GET (graphics statement)|GET]] to store a box area image of the screen.
* [[SCREEN]] 12 can only GET 1/3 of the screen image at one time using a 26K array.
* Image arrays are [[DIM]]ensioned as [[INTEGER]]. Use [[DEFINT]] when working with large graphic arrays.
* Any arrays can be saved, but image arrays are most common.
* [[DEF SEG]] = [[VARSEG]] must be used to designate the array segment position in memory.
* [[VARPTR]] returns the array index offset of the memory segment. Array sizes are limited to 32767 Integer elements due to the use of [[VARPTR]] in QBasic and '''QB64''''s emulated conventional memory.
* [[BSAVE]] files can later be opened with [[BLOAD]].
{{PageExamples}}
''Example 1:'' Saving array data to a file quickly.
{{CodeStart}}
LB% = {{Cl|LBOUND}}(Array)
bytes% = {{Cl|LEN}}(Array(LB%))
filesize& = (({{Cl|UBOUND}}(Array) - LB%) + 1) * bytes%
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0))
{{Cl|BSAVE}} filename$, {{Cl|VARPTR}}(Array(LB%)), filesize& ' changeable index
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Explanation:'' Procedure determines the filesize from the array size automatically. [[LBOUND]] is used with [[UBOUND]] to determine array size and byte size. Works with any type of array except variable-length strings. Used for saving program data fast.
''Example 2:'' [[BSAVE]]ing a bitmap and calculating the file size
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image(0))
{{Cl|PSET}}(BMPHead.PWidth - 1, BMPHead.PDepth - 1) 'color lower right corner if black
{{Cl|GET (graphics statement)|GET}} (0, 0)-(BMPHead.PWidth - 1, BMPHead.PDepth - 1), Image(NColors * 3) ' for 16 or 256 colors
{{Cl|FOR...NEXT|FOR}} a& = 26000 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} Image(a&) {{Cl|THEN}} ArraySize& = a&: {{Cl|EXIT FOR}}
{{Cl|NEXT}}
{{Cl|BSAVE}} SaveName$, {{Cl|VARPTR}}(Image(0)), (2 * ArraySize&) + 200 'file size
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Explanation:'' The [[FOR...NEXT|FOR]] loop reads backwards through the image array until it finds a value not 0. The [[LONG]] {{Parameter|ArraySize&}} value is doubled and 200 is added. {{Parameter|BMPhead.PWidth}} and {{Parameter|BMPhead.PDepth}} are found by reading the bitmap's information header using a [[TYPE]] definition. See [[Bitmaps]].
''Example 3:'' Using [[PUT]] and [[GET]] to write and read array data from a file without using BSAVE or [[BLOAD]]:
{{CodeStart}}
{{Cl|KILL}} "example2.BIN" 'removes old image file!
{{Cl|SCREEN}} 13
{{Cl|OPTION BASE}} 0
{{Cl|REDIM}} Graphic%(1001) 'REDIM makes array resize-able later
{{Cl|LINE}} (0, 0)-(10, 10), 12, B 'create image
{{Cl|GET (graphics statement)|GET}}(0, 0)-{{Cl|STEP}}(10, 10), Graphic%() 'get image to array
{{Cl|FOR...NEXT|FOR}} i% = 1000 {{Cl|TO}} 0 {{Cl|STEP}} -1 'reverse read array for size needed
{{Cl|IF...THEN|IF}} Graphic%(i%) <> 0 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|NEXT}}
size% = i% + 4 'size plus 2 integers(4 bytes) for dimensions
{{Cl|REDIM}} {{Cl|_PRESERVE}} Graphic%(size%) 'resize existing array in QB64 only!
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file
{{Cl|PUT}} #1, , Graphic%()
{{Cl|CLOSE}}
{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen
{{Cl|DIM}} CopyBin%({{Cl|LOF}}(2) \ 2) 'create new array sized by half of file size
{{Cl|GET}} #2, , CopyBin%()
{{Cl|PUT (graphics statement)|PUT}}(100, 100), CopyBin%(), {{Cl|PSET}}
fsize% = {{Cl|LOF}}(2)
{{Cl|CLOSE}}
K$ = {{Cl|INPUT$}}(1) 'Press any key
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 20 'read all 3 arrays
{{Cl|PRINT}} Graphic%(i); CopyBin%(i)
{{Cl|NEXT}}
{{Cl|PRINT}} "Array:"; size%, "File:"; fsize%
{{CodeEnd}}{{small|Code by Ted Weissgerber}}
: ''Explanation:'' A 10 by 10 pixel box is saved to an array using the [[GET (graphics statement)]] and written to a BINARY file using [[PUT]] #1. Then [[GET]] #1 places the file contents into another INTEGER array and places it on the screen with the [[PUT (graphics statement)]].
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) <> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
{{PageSeeAlso}}
* [[GET (graphics statement)]], [[PUT (graphics statement)]]
* [[BLOAD]], [[OPEN]], [[BINARY]]
* [[GET]], [[PUT]] {{text|(file statements)}}
* [[VARSEG]], [[VARPTR]]
* [[DEF SEG]], [[TYPE]]
* [[Text Using Graphics]]
{{PageNavigation}}

View file

@ -1,104 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:14}}
The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64.
{{PageSyntax}}
: '''DECLARE''' [DYNAMIC|CUSTOMTYPE|STATIC] '''LIBRARY''' [{''"Library_filename"''|''"Headerfile"''}]
: {[[SUB]]|[[FUNCTION]]} [''procedure_name'' {{KW|ALIAS}}] ''library_procedure'' ([{{KW|BYVAL}}] ''parameter {{KW|AS}}'', ...)
::.
::. 'other SUBs or Functions as required
::.
: '''END DECLARE'''
{{Parameters}}
* The {{Parameter|Library_filename}} is needed if a Library is not already loaded by QB64. Do not include the ''.DLL'', ''LIB'' or ''.H'' file extension.
** It's always a good idea to try declaring Windows API libraries without a {{Parameter|Library_filename}} first, as most Windows headers are already included in QB64 source.
* Begin the {{Parameter|Library_filename}} with '''./''' or '''.\''' to make it relative to the path where your source file is saved, so you can keep all your project files together.
* {{Parameter|Procedure_name}} is any program procedure name you want to designate by using [[ALIAS]] with the {{Parameter|Library_procedure}} name.
* {{Parameter|Library procedure}} is the actual procedure name used inside of the library or header file.
===Library Types===
* '''[[DECLARE DYNAMIC LIBRARY|DYNAMIC]]''' links a program to functions in dynamically linkable libraries. At present, only .DLL files are supported
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries. Supports shared object (*.so) libraries.
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't use shared libraries (DLLs are different) this does not affect Windows users.
{{PageDescription}}
* The declaration can be used with C++ sub-procedures, Windows API and QB64 SDL (versions prior to 1.000)/OpenGL (version 1.000 and up) Libraries.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* C procedures can use a header file name. File code must be included with program code. Do not include the ''.h'' extension.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] characters.
* When using a procedure from an '''unsupported''' Dynamic Link Library (DLL file) use [[DECLARE DYNAMIC LIBRARY]].
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that any procedure will work and cannot quarantee any troubleshooting help.'''
{{PageExamples}}
''Example 1:'' Using an '''SDL''' library procedure as a program SUB procedure to move the mouse pointer to a coordinate (works in versions prior to 1.000):
{{CodeStart}}
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} SDL_WarpMouse ({{Cl|BYVAL}} column {{Cl|AS}} {{Cl|LONG}}, {{Cl|BYVAL}} row {{Cl|AS}} {{Cl|LONG}}) 'SDL procedure name
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) 'simulate screen 12 with 256 colors
{{Cl|RANDOMIZE}} {{Cl|TIMER}}
DO
{{Cl|_DELAY}} 1
x = {{Cl|RND}} * 640: y = {{Cl|RND}} * 480
{{Cl|LINE}} (x, y)-{{Cl|STEP}}(10, 10), {{Cl|RND}} * 100 + 32, BF
MouseMove x + 5, y + 5
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) 'any keypress quits
{{Cl|END}}
{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}})
SDL_WarpMouse x, y 'call SDL library procedure
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Code by Galleon}}
:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use.
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_DELAY}} 2
MouseMove 100, 100
{{Cl|_DELAY}} 2
MouseMove 200, 200
{{CodeEnd}}
:''Explanation:'' When a Library procedure is used to represent another procedure name use [[ALIAS]] instead. Saves creating a SUB!
''Example 2:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes.
{{CodeStart}}
{{Cl|DECLARE LIBRARY}} ""
{{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE
{{CodeEnd}}
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.'''
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
* [[DECLARE DYNAMIC LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
* [[SQL Client]]
{{PageNavigation}}

View file

@ -1,65 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:15}}
[[CALL]] sends code execution to a subroutine procedure in a program. In '''QB64''' the subroutine doesn't need to be declared.
{{PageSyntax}}
: [[CALL]] {{Parameter|ProcedureName}} ({{Parameter|parameter1}}, {{Parameter|parameter2}},...)]
===Alternative syntax===
: {{Parameter|ProcedureName}} {{Parameter|parameter1}}, {{Parameter|parameter2}},...]
* CALL requires [[SUB]] program parameters to be enclosed in brackets (parenthesis).
* CALL is not required to call a subprocedure. Use the SUB-procedure name and list any parameters without parenthesis.
* Neither syntax can be used to call [[GOSUB]] linelabel sub procedures.
* To pass parameters by value, instead of by reference, enclose passed variables in parenthesis.
==QBasic/QuickBASIC==
* PDS or Quickbasic 7 up could use [[BYVAL]] to pass variables by values instead of reference.
* QuickBASIC 4.5 could use [[BYVAL]] only for procedures created in Assembly or another language.
* QBasic required [[CALL ABSOLUTE]] only. It did not have to be DECLAREd.
{{PageExamples}}
''Example:'' How parameters are passed in two [[SUB]] calls, one with CALL using brackets and one without CALL or brackets:
{{CodeStart}}
{{Cl|DIM}} a {{Cl|AS}} {{Cl|INTEGER}} 'value not shared with SUB
{{Cl|DIM}} {{Cl|SHARED}} b {{Cl|AS}} {{Cl|INTEGER}} 'value shared with any SUB
a = 1
b = 2
c = 3
{{Cl|CALL}} helloworld (a) 'a passed to c parameter with CALL
helloworld a 'a passed to c parameter w/o CALL
{{Cl|END}}
{{Cl|SUB}} helloworld (c) 'SUB parameter variables are always inside of brackets in SUB code
{{Cl|PRINT}} "Hello World!"
{{Cl|PRINT}} a, b, c
a = a + 1 'a is a SUB value of 0 when printed which may increase inside SUB only
b = b + 1 'b is a shared value which can increase anywhere
c = c + 1 'c is a SUB parameter value from a in calls which may increase inside SUB only
{{Cl|END SUB}}
{{CodeEnd}}
''Returns:''
{{OutputStart}}Hello World!
0 2 1
Hello World!
0 3 1
{{OutputEnd}}
: ''Explanation:'' Variable '''{{Parameter|a}}''' that is outside of the subroutine isn't [[SHARED]] so it will have no effect inside the subroutine, the variable {{Parameter|a}} inside the subroutine is only valid inside the subroutine, and whatever value {{Parameter|a}} has outside of it makes no difference within the subroutine.
:The variable '''{{Parameter|b}}''' on the other hand is [[SHARED]] with the subroutines and thus can be changed in the subroutine. The variable {{Parameter|a}} is initiated with 0 as default when created, thus it will return 0 since it wasn't changed within the subroutine.
:The variable '''{{Parameter|c}}''' is the [[SUB]] parameter variable that passes values into the sub. Its value could be changed by the passed parameter value or inside of the subroutine. The un-shared '''{{Parameter|c}}''' variable value outside of the sub is irrelevant within the subroutine.
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]
{{PageNavigation}}

View file

@ -1,27 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:40:55}}
[[CALL ABSOLUTE]] is used to access interrupts on the computer or execute assembly type procedures.
{{PageSyntax}}
: [[CALL ABSOLUTE]]([{{Parameter|argumentList}},] {{Parameter|integerOffset}})
===Legacy support===
* [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, use [[_MOUSEINPUT]] and related functions.
{{PageDescription}}
* [[CALL]] and parameter brackets are required in the statement.
* {{Parameter|argumentList}} contains the list of arguments passed to the procedure.
* {{Parameter|integerOffset}} contains the offset from the current code segment, set by [[DEF SEG]] and [[SADD]], to the starting location of the called procedure.
* QBasic and '''QB64''' have the ABSOLUTE statement built in and require no library, like QuickBASIC did.
* '''NOTE: QB64 does not support INT 33h mouse functions above 3 or [[BYVAL]] in an ABSOLUTE statement. Registers are emulated.'''
{{PageSeeAlso}}
* [[SADD]], [[INTERRUPT]]
* [[_MOUSEINPUT]]
{{PageNavigation}}

View file

@ -1,3 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:16}}
See page [[SELECT CASE]]

View file

@ -1,3 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:17}}
See page [[SELECT CASE]]

View file

@ -1,3 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:18}}
See page [[SELECT CASE]]

View file

@ -1,36 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:19}}
[[CDBL]] converts a value to the closest [[DOUBLE]]-precision value.
{{PageSyntax}}
: {{Parameter|doubleValue#}} = [[CDBL]]({{Parameter|expression}})
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Rounds to the closest [[DOUBLE]] floating decimal point value.
* Also can be used to define a value as [[DOUBLE]]-precision up to 15 decimals.
{{PageExamples}}
''Example:'' Prints a double-precision version of the single-precision value stored in the variable named A.
{{CodeStart}}
A = 454.67
{{Cl|PRINT}} A; {{Cl|CDBL}}(A)
{{CodeEnd}}
{{OutputStart}} 454.67 454.6700134277344
{{OutputEnd}}
: The last 11 numbers in the double-precision number change the value in this example, since A was previously defined to only two-decimal place accuracy.
{{PageSeeAlso}}
* [[CINT]], [[CLNG]]
* [[CSNG]], [[_ROUND]]
{{PageNavigation}}

View file

@ -1,48 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:20}}
[[CHAIN]] is used to change seamlessly from one module to another one in a program.
{{PageSyntax}}
: [[CHAIN]] {{Parameter|moduleName$}}
===Legacy support===
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[CHAIN]] statement has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.
{{Parameters}}
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
{{PageDescription}}
* CHAIN requires that both the invoking and called modules are of either .BAS or .EXE file types.
* In Windows, '''QB64''' will automatically compile a CHAIN referenced BAS file if there is no EXE file found.
* CHAIN looks for a file extension that is the same as the invoking module's extension.
* The module's filename extension is not required. To save editing at compile time just omit the extensions in the calls.
* To pass data from one module to the other use [[COMMON SHARED]]. The COMMON list should match [[type]]s and names.
* '''QB64 does not retain the [[SCREEN]] mode like QBasic did.'''
* Variable data can be passed in files instead of using [[COMMON SHARED]] values. '''QB64''' uses files to pass [[COMMON]] lists.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]]'''.
''QBasic/QuickBASIC:''
* Compiled EXE files had to include BRUN45.EXE in QuickBASIC 4.5 when CHAIN was used with [[COMMON SHARED]].
{{PageExamples}}
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
{{CodeStart}}
{{Cl|CHAIN}} "Level1"
{{CodeEnd}}
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".
{{PageSeeAlso}}
* [[RUN]]
* [[COMMON]], [[COMMON SHARED]]
* [[SHARED]]
{{PageNavigation}}

View file

@ -1,64 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:22}}
The [[CHDIR]] statement changes the program's location from one working directory to another by specifying a literal or variable [[STRING]] path.
{{PageSyntax}}
:[[CHDIR]] {{Parameter|path$}}
{{PageDescription}}
* {{Parameter|path$}} is the new directory path the program will work in.
* {{Parameter|path$}} can be an absolute path (starting from the root folder) or relative path (starting from the current program location).
* If {{Parameter|path$}} specifies a non-existing path, a [[ERROR Codes|"Path not found"]] error will occur.
* '''A QB64 [[SHELL]] statement cannot use "CD " or "CHDIR " + path$ to change directories.'''
{{PageExamples}}
''Example 1:'' The following code is Windows-specific:
{{CodeStart}}
{{Cl|CHDIR}} "C:\" 'change to the root drive C (absolute path)
{{Cl|CHDIR}} "DOCUME~1" 'change to "C:\Documents and Settings" from root drive (relative path)
{{Cl|CHDIR}} "..\" 'change back to previous folder one up
{{CodeEnd}}
:''Details:'' '''QB64''' can use long or short (8.3 notation) file and path names.
''Example 2:'' Using the Windows API to find the current program's name and root path. The PATH$ is a shared function value.
{{CodeStart}}
{{Cl|_TITLE}} "My program"
{{Cl|PRINT}} TITLE$
{{Cl|PRINT}} PATH$
{{Cl|FUNCTION}} TITLE$ ''=== SHOW CURRENT PROGRAM
{{Cl|SHARED}} PATH$ 'optional path information shared with main module only
{{Cl|DECLARE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav
{{Cl|FUNCTION}} GetModuleFileNameA ({{Cl|BYVAL}} Module {{Cl|AS}} {{Cl|LONG}}, FileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
FileName$ = {{Cl|SPACE$}}(256)
Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates the current program
{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} 'Result returns the length or bytes of the string information
PATH$ = {{Cl|LEFT$}}(FileName$, Result)
start = 1
DO
posit = {{Cl|INSTR}}(start, PATH$, "\")
{{Cl|IF...THEN|IF}} posit {{Cl|THEN}} last = posit
start = posit + 1
{{Cl|LOOP}} {{Cl|UNTIL}} posit = 0
TITLE$ = {{Cl|MID$}}(PATH$, last + 1)
PATH$ = {{Cl|LEFT$}}(PATH$, last)
{{Cl|ELSE}} TITLE$ = "": PATH$ = ""
{{Cl|END IF}}
{{Cl|END FUNCTION}}
{{CodeEnd}}
: '''Note:''' The program's [[_TITLE]] name may be different from the actual program module's file name returned by Windows.
{{PageSeeAlso}}
* [[SHELL]], [[FILES]]
* [[MKDIR]], [[RMDIR]]
* [[$CONSOLE]]
{{PageNavigation}}

View file

@ -1,88 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:23}}
The [[CHR$]] function returns the character associated with a certain [[ASCII|character code]] as a [[STRING]].
{{PageSyntax}}
:{{Parameter|result$}} = [[CHR$]]({{Parameter|code%}})
{{PageDescription}}
* Valid ASCII {{Parameter|code%}} numbers range from 0 to 255.
* The character code of a character can be found using [[ASC]].
* Some control codes below 32 will not [[PRINT]] or will move the screen cursor, unless [[_CONTROLCHR|_CONTROLCHR OFF]] is used.
{{PageExamples}}
''Example 1:'' Outputs the characters of several character codes:
{{CodeStart}}{{Cl|PRINT}} {{Cl|CHR$}}(65); {{Cl|CHR$}}(65 + 32)
{{Cl|PRINT}} {{Cl|CHR$}}(66); {{Cl|CHR$}}(66 + 32)
{{CodeEnd}}
{{OutputStart}}Aa
Bb
{{OutputEnd}}
:Explanation: 65 is the ASCII code for "A" and 65 + 32 is the ASCII code for "a". 66 is the ASCII code for "B" and 66 + 32 is the ASCII code for "b"
''Example 2:'' To cut down on typing CHR$(???) all day, define often used characters as variables such as Q$ = CHR$(34) as shown.
{{CodeStart}}
{{Cl|DIM}} Q AS {{Cl|STRING}} * 1 'define as one byte string(get rid of $ type suffix too)
Q = {{Cl|CHR$}}(34) 'Q will now represent the elusive quotation mark in a string
PRINT "This text uses "; Q; "quotation marks"; Q; " that could have caused a syntax error!"
{{CodeEnd}}
{{OutputStart}}
This text uses "quotation marks" that could have caused a syntax error!
{{OutputEnd}}
''Example 3:'' Using [[ASC]] and [[CHR$]] to ''encrypt'' a text file size up to 32K bytes
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be encrypted
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) <= 32000 {{Cl|THEN}} Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' get Text as one string
{{Cl|CLOSE}} #1
Send$ = "" ' clear value
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1) ' get each character in the text
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code < 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code < 123) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code + 130) ' change letter's ASCII character by 130
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string with just letters encrypted
{{Cl|NEXT}} i
{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 ' erase FileName to be encrypted
{{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' Text as one string
{{Cl|CLOSE}} #1
{{CodeEnd}}
:''Warning: The routine above will change an original text file to be unreadable. Use a second file name to preserve the original file.''
''Example 4:'' '''Decrypting''' the above encrypted text file (32K byte file size limit).
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be decrypted
Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' open Text as one string
{{Cl|CLOSE}} #1
Send$ = ""
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1)
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code < 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code < 253) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code - 130) ' change back to a Letter character
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string as normal letters
{{Cl|NEXT}} i
{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 ' Erase file for decrypted text
{{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' place Text as one string
{{Cl|CLOSE}} #1
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' Examples 3 and 4 encrypt and decrypt a file up to 32 thousand bytes. [[INPUT$]] can only get strings less than 32767 characters. The upper and lower case letter characters are the only ones altered, but the encryption and decryption rely on the fact that most text files do not use the code characters above 193. You could alter any character from ASCII 32 to 125 without problems using the 130 adder. No [[ASCII]] code above 255 is allowed. Don't alter the codes below code 32 as they are control characters. Specifically, characters 13 and 10 (CrLf) may be used for line returns in text files.
{{PageSeeAlso}}
* [[ASC]], [[ASC (statement)]]
* [[INKEY$]]
* [[ASCII|ASCII character codes]]
{{PageNavigation}}

View file

@ -1,37 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:24}}
The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value.
{{PageSyntax}}
: {{Parameter|value%}} = [[CINT]]({{Parameter|expression}})
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Values greater than .5 are rounded up. Values lower than .5 are rounded down.
* ''Warning:'' Since [[CINT]] is used for integer values, the input values cannot exceed 32767 to -32768!
* Use [[CLNG]] for [[LONG]] integer values exceeding [[INTEGER]] limitations.
* Note: When decimal point values are given to BASIC functions requiring [[INTEGER]]s the value will be [[CINT]]ed.
{{PageExamples}}
''Example:'' Shows how CINT rounds values up or down as in "bankers' rounding".
{{CodeStart}}
a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c
{{CodeEnd}}
{{OutputStart}}{{text|1 2 11.5|red}}
{{OutputEnd}}
{{PageSeeAlso}}
* [[_ROUND]], [[_CEIL]]
* [[CLNG]], [[CSNG]], [[CDBL]]
* [[INT]], [[FIX]]
{{PageNavigation}}

View file

@ -1,146 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:25}}
The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes to create circles, arcs or ellipses.
{{PageSyntax}}
: [[CIRCLE]] [{{KW|STEP}}]'''('''{{Parameter|column}}''',''' {{Parameter|row}}'''),''' {{Parameter|radius%}}''',''' [{{Parameter|drawColor%}}][, {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
{{Parameters}}
* Can use [[STEP]] for relative coordinate moves from the previous graphic coordinates.
* Coordinates designate the center position of the circle. Can be partially drawn offscreen.
* {{Parameter|radius%}} is an [[INTEGER]] value for half of the total circle diameter.
* {{Parameter|drawColor%}} is any available color attribute in the [[SCREEN (statement)|SCREEN]] mode used.
* {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} can be any [[SINGLE]] value from 0 to 2 * ã to create partial circles or ellipses.
* {{Parameter|aspect!}} [[SINGLE]] values of 0 to 1 affect the vertical height and values over 1 affect the horizontal width of an ellipse. Aspect = 1 is a normal circle.
{{PageDescription}}
* When using {{Parameter|aspect!}} the {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} commas must be included even if not used.
* Radians move in a counter clockwise direction from 0 to 2 * ã. Zero and 2 * ã are the same circle radian at 3 o'clock.
* Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.
* Commas after the {{Parameter|drawColor%}} parameter are not required when creating a normal circle. {{Parameter|drawColor%}} can also be omitted to use the last color used in a draw statement.
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
* '''CIRCLE can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only.'''
{{PageExamples}}
''Example 1:'' Finding when the mouse is inside of a circular area:
{{CodeStart}}
{{Cl|SCREEN}} 12
r& = 200 'radius change circle size and position here
cx& = 320 'center x horizontal
cy& = 240 'center y vertical
DO
i = {{Cl|_MOUSEINPUT}}
x& = {{Cl|_MOUSEX}}
y& = {{Cl|_MOUSEY}}
xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
{{Cl|IF...THEN|IF}} r& ^ 2 >= xy& {{Cl|THEN}} {{Cl|CIRCLE}} (cx&, cy&), r&, 10 {{Cl|ELSE}} {{Cl|CIRCLE}} (cx&, cy&), r&, 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit
{{CodeEnd}}
: ''Explanation:'' The square of the circle radius will be greater than or equal to the sum of the square of the mouse coordinates minus the center position when the pointer is inside of the circle. In this example the circle color will change from red to green.
''Example 2:'' Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.
{{CodeStart}}
{{Cl|CONST}} PI = 3.141593 'The mathematical value of PI to six places. You can also use QB64's native _PI.
{{Cl|DIM}} clock(60) 'A dimensioned array to hold 60 radian points
clockcount% = 15 'A counter to keep track of the radians
'* Start at radian 2*PI and continue clockwise to radian 0
'* Since radian 2*PI points directly right, we need to start clockcount%
'* at 15 (for 15 seconds). The {{Cl|FOR...NEXT|FOR}}/{{Cl|NEXT}} loop counts backwards in increments
'* of 60 giving us the 60 second clock points. These points are then stored
'* in the dimensioned array clock() to be used later.
'*
{{Cl|FOR...NEXT|FOR}} radian = 2 * PI {{Cl|TO}} 0 {{Cl|STEP}} -(2 * PI) / 60
clock(clockcount%) = radian
clockcount% = clockcount% + 1
{{Cl|IF...THEN|IF}} clockcount% = 61 {{Cl|THEN}} clockcount% = 1
{{Cl|NEXT}} radian
'* Change to a graphics screen and draw the clock face
{{Cl|SCREEN}} 7
{{Cl|CLS}}
{{Cl|LOCATE}} 1, 1
{{Cl|COLOR}} 14, 0
{{Cl|PRINT}} "Ritchie's Clock"
{{Cl|COLOR}} 9, 0
{{Cl|PRINT}} "Uses {{Cl|CIRCLE}} to"
{{Cl|PRINT}} "draw hands!"
{{Cl|COLOR}} 8, 0
{{Cl|CIRCLE}} (160, 100), 110, 8 'circle with radius of 110 and dark gray
{{Cl|CIRCLE}} (160, 100), 102, 8 'circle with radius of 102 and dark gray
{{Cl|PAINT}} (265, 100), 8, 8 'fill between the two dark gray circles with gray
{{Cl|CIRCLE}} (160, 100), 110, 7 'circle with radius of 110 and light gray
'*
'* Get the current time from the QuickBASIC built in variable {{Cl|TIME$}}
'* Since {{Cl|TIME$}} is a string, we need to extract the hours, minutes and
'* seconds from it using {{Cl|LEFT$}}, {{Cl|RIGHT$}} and {{Cl|MID$}}. Then, each of these
'* extractions need to be converted to a numeric value using VAL and
'* stored in their respective variables.
'*
seconds% = {{Cl|INT}}({{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2))) 'extract seconds from {{Cl|TIME$}}
{{Cl|IF...THEN|IF}} seconds% = 0 {{Cl|THEN}} seconds% = 60 'array counts 1 to 60 not 0 to 59
previoussecond% = seconds% 'hold current second for later use
minutes% = {{Cl|INT}}({{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2))) 'extract minutes from {{Cl|TIME$}}
{{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60 'array counts 1 to 60 not 0 to 59
previousminute% = minutes% 'hold current minute for later use
hours% = {{Cl|INT}}({{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))) 'extract hour from {{Cl|TIME$}}
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12 'convert from military time
{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12 'count from 1 to 12 not 0 to 11
previoushour% = hours% 'hold current hour for later use
'*
'* Start of main program loop
'*
{{Cl|DO}}
{{Cl|IF...THEN|IF}} seconds% <> previoussecond% {{Cl|THEN}} 'has a second elapsed?
{{Cl|LOCATE}} 22, 17 'print the time on the screen at
{{Cl|PRINT}} {{Cl|TIME$}}; 'position 22, 17
'* Since a second has elapsed we need to erase the old second hand
'* position and draw the new position
{{Cl|CIRCLE}} (160, 100), 100, 0, -clock(previoussecond%), clock(previoussecond%)
{{Cl|CIRCLE}} (160, 100), 100, 15, -clock(seconds%), clock(seconds%)
previoussecond% = seconds% 'hold current second for later use
{{Cl|IF...THEN|IF}} minutes% <> previousminute% {{Cl|THEN}} 'has a minute elapsed?
'* Since a minute has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 90, 0, -clock(previousminute%), clock(previousminute%)
previousminute% = minutes% 'hold current minute for later use
{{Cl|END IF}}
'*
'* Draw the current minute hand position
'*
{{Cl|CIRCLE}} (160, 100), 90, 14, -clock(minutes%), clock(minutes%)
{{Cl|IF...THEN|IF}} hours% <> previoushour% {{Cl|THEN}} 'has an hour elapsed?
'* Since an hour has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 75, 0, -clock(previoushour% * 5), clock(previoushour% * 5)
previoushour% = hours% 'hold current hour for later use
{{Cl|END IF}}
'*
'* Draw the current hour hand position
'*
{{Cl|CIRCLE}} (160, 100), 75, 12, -clock(hours% * 5), clock(hours% * 5)
{{Cl|END IF}}
seconds% = {{Cl|VAL}}({{Cl|RIGHT$}}({{Cl|TIME$}}, 2)) 'extract time again and do all over
{{Cl|IF...THEN|IF}} seconds% = 0 {{Cl|THEN}} seconds% = 60
minutes% = {{Cl|VAL}}({{Cl|MID$}}({{Cl|TIME$}}, 4, 2))
{{Cl|IF...THEN|IF}} minutes% = 0 {{Cl|THEN}} minutes% = 60
hours% = {{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12
{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key
{{CodeEnd}}
{{small|code by Terry Ritchie}}
{{PageSeeAlso}}
* [[STEP]], [[DRAW]]
* [[LINE]], [[PSET]], [[PRESET]]
* [[SCREEN]], [[SCREEN (function)]]
* [[Alternative circle routine]] {{text|(member-contributed program)}}
{{PageNavigation}}

View file

@ -1,40 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:27}}
The [[CLEAR]] statement clears all variable and array element values in a program.
{{PageSyntax}}
: [[CLEAR]] [, {{Parameter|ignored&}} , {{Parameter|ignored&}}]
{{PageDescription}}
* All parameters are optional and ignored by '''QB64'''.
* Normally used to clear all program variable and [[Arrays|array]] values where numerical values become zero and string values become empty ("").
* It does not clear [[CONST|constant]] values.
* Closes all opened files.
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|redimensioned]] or an [[ERROR Codes|error]] will occur when referenced because they are removed.
{{PageExamples}}
''Example:'' Using CLEAR to clear array elements from [[STATIC|static]] arrays or arrays created using [[DIM]].
{{CodeStart}}
{{Cl|CLS}}
{{Cl|DIM}} array(10) 'create a {{Cl|$STATIC}} array
array(5) = 23
{{Cl|PRINT}} array(5)
{{Cl|CLEAR}}
{{Cl|PRINT}} array(5)
{{CodeEnd}}
:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR.
{{PageSeeAlso}}
* [[ERASE]]
* [[REDIM]], [[_PRESERVE]]
* [[Arrays]], [[&B|_BIT arrays]]
{{PageNavigation}}

View file

@ -1,38 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:28}}
The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[LONG]] integer value.
{{PageSyntax}}
: {{Parameter|value&}} = [[CLNG]]({{Parameter|expression}})
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Used when integer values exceed 32767 or are less than -32768.
* Values greater than .5 are rounded up; .5 or lower are rounded down.
* CLNG can return normal [[INTEGER]] values under 32768 too.
* Use it when a number could exceed normal [[INTEGER]] number limits.
{{PageExamples}}
{{CodeStart}}
a& = {{Cl|CLNG}}(2345678.51)
{{Cl|PRINT}}
{{CodeEnd}}
{{OutputStart}}
2345679
{{OutputEnd}}
{{PageSeeAlso}}
* [[CINT]], [[INT]]
* [[CSNG]], [[CDBL]]
* [[_ROUND]]
{{PageNavigation}}

View file

@ -1,31 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:29}}
[[CLOSE]] closes an open file or port using the number(s) assigned in an [[OPEN]] statement.
{{PageSyntax}}
: [[CLOSE]] [{{Parameter|fileNumber}}[, ...]]
{{Parameters}}
* {{Parameter|fileNumber}} indicates the file or list of file numbers to close. When not specified, all open files are closed.
{{PageDescription}}
* A file must be closed when changing to another file mode.
* [[CLOSE]] files when they are no longer needed, in order to save memory.
* Files cannot be opened in the same [[OPEN]] mode using another number until the first one is closed.
* Use holding variables for each file number returned by [[FREEFILE]] so that the file reference is known.
* Will not return an error if a filenumber is already closed or was never opened. It does not verify that a file was closed.
* [[CLEAR]] can be used to close all open files.
* [[CLOSE]] can also be used to close an open TCP/IP connection using a handle returned by '''QB64'''.
{{PageSeeAlso}}
* [[OPEN]], [[OPEN COM]]
* [[_OPENCLIENT]], [[_OPENHOST]]
* [[_OPENCONNECTION]]
* [[_SNDCLOSE]]
{{PageNavigation}}

View file

@ -1,60 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:30}}
The [[CLS]] statement clears the [[_DEST|current write page]].
{{PageSyntax}}
: [[CLS]] [{{Parameter|method%}}] [, {{Parameter|bgColor&}}]
{{Parameters}}
* {{Parameter|method%}} specifies which parts of the page to clear, and can have one of the following values:
** CLS - clears the active graphics or text viewport or the entire text screen and refreshes bottom function [[KEY LIST|KEY ON]] line.
** CLS 0 - Clears the entire page of text and graphics. Print cursor is moved to row 1 at column 1.
** CLS 1 - Clears only the graphics view port. Has no effect for text mode.
** CLS 2 - Clears only the text view port. The print cursor is moved to the top row of the text view port at column 1.
* The {{Parameter|bgColor&}} specifies the color attribute or palette index to use when clearing the screen in '''QB64'''.
{{PageDescription}}
* In legacy [[SCREEN]] modes {{Parameter|bgColor&}} specifies the color attribute of the background.
* For 32-bit graphics mode, {{Parameter|bgColor&}} specifies the [[_RGB]] or [[_RGBA]] color to use.
* '''32-bit screen surface backgrounds (black) have zero [[_ALPHA]] so that they are transparent when placed over other surfaces.'''
** Use [[CLS]] or [[_DONTBLEND]] to make a new surface background [[_ALPHA]] 255 or opaque.
* If not specified, {{Parameter|bgColor&}} is assumed to be the current background color. 32-bit backgrounds will change to opaque.
* If {{Parameter|bgColor&}} is not a valid attribute, an [[ERROR Codes|illegal function call]] error will occur.
* Use [[_PRINTMODE]] to allow the background colors to be visible through the text or the text background.
{{PageExamples}}
''Example 1:'' Printing black text on a white background in QB64.
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|CLS}} , 15
{{Cl|_PRINTMODE }} _KEEPBACKGROUND 'keeps the text background visible
{{Cl|COLOR}} 0: {{Cl|PRINT}} "This is black text on a white background!"
K$ = {{Cl|INPUT$}}(1
{{CodeEnd}}
:''Explanation:'' [[_PRINTMODE]] can be used with [[PRINT]] or [[_PRINTSTRING]] to make the text or the text background transparent.
''Example 2:'' You don't need to do anything special to use a .PNG image with alpha/transparency. Here's a simple example:
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|CLS}} , {{Cl|_RGB}}(0, 255, 0)
i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples to get the image
{{Cl|_PUTIMAGE}} (0, 0), i 'places image at upper left corner of window w/o stretching it
{{CodeEnd}}
: ''Explanation:'' When QB64 loads a .PNG file containing a transparent color, that color will be properly treated as transparent when _PUTIMAGE is used to put it onto another image. You can use a .PNG file containing transparency information in a 256-color screen mode in QB64. [[CLS]] sets the [[_CLEARCOLOR]] setting using [[_RGB]].
{{PageSeeAlso}}
* [[SCREEN]]
* [[_RGB]], [[_RGBA]], [[_RGB32]], [[_RGBA32]]
* [[VIEW PRINT]], [[VIEW]]
* [[_CLEARCOLOR]]
{{PageNavigation}}

View file

@ -1,195 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:31}}
The [[COLOR]] statement is used to change the foreground and background colors for printing text.
{{PageSyntax}}
: [[COLOR]] [{{Parameter|foreground&}}][, {{Parameter|background&}}]
{{PageDescription}}
* {{Parameter|background&}} colors are available in all QB64 color SCREEN modes.
* [[SCREEN]] mode 10 has only 3 white foreground attributes including flashing.
* To change the {{Parameter|background&}} color only, use a comma and the desired color. Ex: [[COLOR]] , {{Parameter|background&}}
* Graphic drawing statements like [[PSET]], [[PRESET]], [[LINE]], etc, also use the colors set by the [[COLOR]] statement if no color is passed when they are called.
* The [[$COLOR]] metacommand adds named color constants for both text and 32-bit modes.
==Screen Mode Attributes==
* '''SCREEN 0''' {{Parameter|background&}} colors 0 to 7 can be changed each text character without affecting other text. Use [[CLS]] after a background color statement to create a fullscreen background color. 64 [[DAC]] hues with 16 high intensity blinking foreground (16 to 31) color attributes. See [[_BLINK]].
** See example 7 below for more SCREEN 0 background colors.
* '''SCREEN 1''' has '''4 background color attributes''': 0 = black, 1 = blue, 2 = green, 3 = grey. White foreground color only.
* '''SCREEN 2''' is '''monochrome''' with white forecolor and black background.
* '''SCREEN 7''' can use 16 ([[DAC]]) colors with background colors. RGB settings can be changed in colors 0 to 7 using [[_PALETTECOLOR]].
* '''SCREEN 8''' has 16 color attributes with 16 background colors.
* '''SCREEN 9''' can use up to 64 [[DAC]] color hues in 16 color attributes with background colors assigned to attribute 0 with a [[_PALETTECOLOR]] swap. RGB settings can be changed in colors 0 to 5 and 7 using [[_PALETTECOLOR]].
* '''SCREEN 10''' has '''only 4 color attributes''' with black background. COLOR 0 = black, 1 = grey, 2 = flash white and 3 = bright white.
* '''SCREEN 11''' is '''monochrome''' with white forecolor and a black background.
* '''SCREEN 12''' can use 16 color attributes with a black background. 256K possible RGB color hues. Background colors can be used with QB64.
* '''SCREEN 13''' can use 256 color attributes with a black background. 256K possible RGB hues.
* [[PALETTE]] swaps can be made in SCREEN 7 and 9 only. Those screens were [[DAC]] screen modes in QBasic.
* [[_DEST]] can be used to set the destination page or image to color using '''QB64'''.
* [[_DEFAULTCOLOR]] returns the current color being used on an image or screen page handle.
===24/32-Bit colors using QB64===
* Pixel color intensities for red, green, blue and alpha range from 0 to 255 when used with [[_RGB]], [[_RGBA]], [[_RGB32]] and [[RGBA32]].
* Combined RGB function values returned are [[LONG]] values. '''Blue intensity values may be cut off using [[SINGLE]] variables.'''
* [[_ALPHA]] transparency values can range from 0 as transparent up to 255 which is fully opaque.
* [[_CLEARCOLOR]] can also be used to set a color as transparent.
* Colors can be mixed by using [[_BLEND]] (default) in 32-bit screen modes. [[_DONTBLEND]] disables blending.
* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.'''
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
==RGB Palette Intensities==
RGB intensity values can be converted to hexadecimal values to create the [[LONG]] [[_PALETTECOLOR]] value in non-32-bit screens:
{{CodeStart}}
{{Cl|SCREEN}} 12
alpha$ = "FF" 'solid alpha colors only
{{Cl|PRINT}} "Attribute = Hex value Red Green Blue "
{{Cl|PRINT}}
{{Cl|COLOR}} 7
{{Cl|FOR...NEXT|FOR}} attribute = 1 {{Cl|TO}} 15
{{Cl|OUT}} {{Cl|&H}}3C7, attribute 'set color attribute to read
red$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4) 'convert port setting to 32 bit values
grn$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4)
blu$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&H}}3C9) * 4)
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(red$) = 1 {{Cl|THEN}} red$ = "0" + red$ '2 hex digits required
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(grn$) = 1 {{Cl|THEN}} grn$ = "0" + grn$ 'for low or zero hex values
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(blu$) = 1 {{Cl|THEN}} blu$ = "0" + blu$
hex32$ = "{{Cl|&H}}" + alpha$ + red$ + grn$ + blu$
{{Cl|_PALETTECOLOR}} attribute, {{Cl|VAL}}(hex32$) 'VAL converts hex string to a LONG 32 bit value
{{Cl|IF...THEN|IF}} attribute {{Cl|THEN}} {{Cl|COLOR}} attribute 'exclude black color print
{{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}(attribute) + " = " + hex32$, red$, grn$, blu$ 'returns closest attribute
{{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}Attribute Hex value Red Green Blue
{{text|COLOR 1 <nowiki>=</nowiki> &HFF0000A8 00 00 A8|#0050A8}}
{{text|COLOR 2 <nowiki>=</nowiki> &HFF00A800 00 A8 00|#00A800}}
{{text|COLOR 3 <nowiki>=</nowiki> &HFF00A8A8 00 A8 A8|#00A8A8}}
{{text|COLOR 4 <nowiki>=</nowiki> &HFFA80000 A8 00 00|#A80000}}
{{text|COLOR 5 <nowiki>=</nowiki> &HFFA800A8 A8 00 A8|#A800A8}}
{{text|COLOR 6 <nowiki>=</nowiki> &HFFA85400 A8 54 00|#A85400}}
{{text|COLOR 7 <nowiki>=</nowiki> &HFFA8A8A8 A8 A8 A8|#A8A8A8}}
{{text|COLOR 8 <nowiki>=</nowiki> &HFF545454 54 54 54|#545454}}
{{text|COLOR 9 <nowiki>=</nowiki> &HFF5454FC 54 54 FC|#5454FC}}
{{text|COLOR 10 <nowiki>=</nowiki> &HFF54FC54 54 FC 54|#54FC54}}
{{text|COLOR 11 <nowiki>=</nowiki> &HFF5454FC 54 FC FC|#54FCFC}}
{{text|COLOR 12 <nowiki>=</nowiki> &HFFFC5454 FC 54 54|#FC5454}}
{{text|COLOR 13 <nowiki>=</nowiki> &HFFFC54FC FC 54 FC|#FC54FC}}
{{text|COLOR 14 <nowiki>=</nowiki> &HFFFCFC54 FC FC 54|#FCFC54}}
{{text|COLOR 15 <nowiki>=</nowiki> &HFFFCFCFC FC FC FC|#FCFCFC}}
{{OutputEnd}}
:''Explanation:'' The RGB intensity values are multiplied by 4 to get the [[_RGB]] intensity values as [[HEX$|hexadecimal]] values. The individual 2 digit [[HEX$]] intensity values can be added to "&HFF" to make up the 32-bit hexadecimal string value necessary for [[VAL]] to return to [[_PALETTECOLOR]]. The statement is only included in the example to show how that can be done with any 32-bit color value.
===Read & write color port intensities with [[INP]] & [[OUT]]===
* Legacy code may use [[INP]] and [[OUT]] to read or set color port intensities. '''QB64''' emulates VGA memory to maintain compatibility.
* The same can be achieved using [[_PALETTECOLOR]] ('''recommended practice''').
:'''{{text|OUT &H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:'''{{text|color_intensity <nowiki>=</nowiki> INP(&H3C9)|green}}''' 'reads present intensity setting
:'''{{text|OUT &H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:'''{{text|OUT &H3C9, color_intensity|green}}''' 'writes new intensity setting
* After every 3 reads or writes, changes to next higher color attribute. Loops can be used to set more than one attribute's intensities.
* Color port setting of red, green and blue intensities can be done in ascending order.
* Color port attribute intensity values range from 0 to 63 (1/4 of the 32-bit values) in QBasic's legacy 4 and 8 bit screen modes.
<p style="text-align: center">([[#toc|Return to Table of Contents]])</p>
{{PageExamples}}
''Example 1:'' Reading the default RGB color settings of color attribute 15.
{{CodeStart}}
{{Cl|OUT}} &H3C7, 15
red% = {{Cl|INP}}(&H3C9)
green% = {{Cl|INP}}(&H3C9)
blue% = {{Cl|INP}}(&H3C9)
{{Cl|PRINT}} red%, green%, blue%
{{CodeEnd}}
{{OutputStart}}
63 63 63
{{OutputEnd}}
''Example 2:'' Changing the color settings of attribute 0 (the background) to blue in [[SCREEN]]s 12 or 13.
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|OUT}} {{Cl|&H}}3C8, 0 'set color port attribute to write
{{Cl|OUT}} {{Cl|&H}}3C9, 0 'red intensity
{{Cl|OUT}} {{Cl|&H}}3C9, 0 'green intensity
{{Cl|OUT}} {{Cl|&H}}3C9, 42 'blue intensity
{{Cl|OUT}} {{Cl|&H}}3C7, 0
{{Cl|PRINT}} {{Cl|INP}}({{Cl|&H}}3C9); {{Cl|INP}}({{Cl|&H}}3C9); {{Cl|INP}}({{Cl|&H}}3C9)
{{Cl|END}}
{{CodeEnd}}
{{OutputStartBG1}} 0 0 42 {{OutputEnd}}
''Example 3:'' Printing in fullscreen SCREEN 0 mode with a color background under the text only.
{{CodeStart}}
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} ' used for fullscreen instead of window
{{Cl|COLOR}} 14, 6: {{Cl|LOCATE}} 4, 4: {{Cl|PRINT}} "Hello!"
{{CodeEnd}}
{{OutputStart}}
{{Ot|Hello!|#fcfc54|#aa5500}}
{{OutputEnd}}
''Example 4:'' Using [[CLS]] after setting the background color in SCREEN 0 to make the color cover the entire screen.
{{CodeStart}}
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}}
{{Cl|COLOR}} , 7: {{Cl|CLS}}
{{Cl|COLOR}} 9: {{Cl|PRINT}} "Hello"
{{CodeEnd}}
{{OutputStartBG7}}
{{Text|Hello|#5454fc}}
{{OutputEnd}}
''Example 5:'' Using a different foreground color for each letter:
{{CodeStart}}
{{Cl|SCREEN}} 0
{{Cl|COLOR}} 1: {{Cl|PRINT}} "H";
{{Cl|COLOR}} 3: {{Cl|PRINT}} "E";
{{Cl|COLOR}} 4: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 5: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 6: {{Cl|PRINT}} "O"
{{Cl|COLOR}} 9: {{Cl|PRINT}} "W";
{{Cl|COLOR}} 11: {{Cl|PRINT}} "O";
{{Cl|COLOR}} 12: {{Cl|PRINT}} "R";
{{Cl|COLOR}} 13: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 14: {{Cl|PRINT}} "D"
{{CodeEnd}}
{{OutputStart}}
{{text|H|#0000aa}}{{text|E|#00aaaa}}{{text|L|#aa0000}}{{text|L|#aa00aa}}{{text|O|#aa5500}}
{{text|W|#5454fc}}{{text|O|#54fcfc}}{{text|R|#fc5454}}{{text|L|#fc54fc}}{{text|D|#fcfc54}}
{{OutputEnd}}
{{PageSeeAlso}}
* [[$COLOR]] (metacommand)
* [[_RGB]], [[_RGBA]], [[_RGB32]], [[RGBA32]].
* [[_RED]], [[_GREEN]], [[_BLUE]]
* [[_RED32]], [[_GREEN32]], [[_BLUE32]]
* [[_ALPHA]], [[_ALPHA32]], [[_CLEARCOLOR]]
* [[PRINT]], [[LOCATE]], [[SCREEN]]
* [[POINT]], [[SCREEN (function)]]
* [[OUT]], [[INP]], [[PALETTE]]
* [[_BLINK]]
* [[_DEFAULTCOLOR]]
* [[_BACKGROUNDCOLOR]]
* [[_PALETTECOLOR]]
* [[Windows_Libraries#Color_Dialog_Box|Color Dialog Box]]
* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values]
{{PageNavigation}}

View file

@ -1,75 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:33}}
The '''COMMAND$''' function returns the command line argument(s) passed when a program is run.
{{PageSyntax}}
: {{Parameter|commandLine$}} = [[COMMAND$]][(count%)]
{{PageDescription}}
* The [[STRING]] return value is anything typed after a program's executable file name in command line (or using the [[RUN]] statement).
* Unlike QuickBASIC, '''QB64''' does not return all [[UCASE$|uppercase]] values so keep that in mind when checking parameters.
* In '''QB64''', COMMAND$ works as an array to return specific elements passed to the command line. COMMAND$(2) would return the second parameter passed at the command line. Arguments can contain spaces if they are passed inside quotation marks. This can be used to properly retrieve file names and arguments which contain spaces.
* Use the [[_COMMANDCOUNT]] function to find the number of parameters passed to a program via the command line. See ''Example 2'' below.
{{PageExamples}}
''Example 1:'' Compile both programs. ProgramA [[RUN]]s ProgramB with a parameter passed following the filename:
{{CodeStart}}
{{Cl|LOCATE}} 12, 36: {{Cl|PRINT}} "ProgramA"
{{Cl|LOCATE}} 23, 25: {{Cl|PRINT}} "Press any key to run ProgramB"
K$ = {{Cl|INPUT$}}(1)
{{Cl|RUN}} "ProgramB FS" 'pass FS parameter to ProgramB in QB64 or QB4.5
{{Cl|SYSTEM}}
{{CodeEnd}}
: ''ProgramB'' checks for fullscreen parameter pass in QB64 and goes full screen.
{{CodeStart}}
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'UCASE$ is needed in QB64 only, as QB4.5 will always return upper case
{{Cl|LOCATE}} 20, 33: {{Cl|PRINT}} "Parameter = " + parameter$
{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(parameter$, 2) = "FS" {{Cl|THEN}} {{Cl|_FULLSCREEN}} 'parameter changes to full screen
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
ProgramB
Parameter = FS.EXE
{{OutputEnd}}
''Example 2:'' Program gets the number of parameters passed to the program, and then prints those parameters to the screen one at a time.
{{CodeStart}}count = {{Cl|_COMMANDCOUNT}}
{{Cl|FOR...NEXT|FOR}} c = 1 {{Cl|TO}} count
{{Cl|PRINT}} {{Cl|COMMAND$}}(c) 'or process commands sent
{{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}-1
a data file
{{OutputEnd}}
: ''Explanation: If we start ''ThisProgram.exe'' with the command line '''ThisProgram -l "a data file"''', COMMAND$ will return a single string of "-1 a data file" which might be hard to process and interpret properly, but COMMAND$(1) would return "-l" and COMMAND$(2) would return the quoted "a data file" option as separate entries for easier parsing and processing.
''Example 3:'' As part of the command array syntax, you can also just read the array to see how many commands were sent (or simply check [[_COMMANDCOUNT]]):
{{CodeStart}}DO
count = count + 1
cmd$ = {{Cl|COMMAND$}}(count)
{{Cl|IF...THEN|IF}} cmd$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} 'read until an empty return
{{Cl|PRINT}} cmd$ 'or process commands sent
{{Cl|LOOP}}
count = count - 1 'save the number of parameters sent to this program when run
{{CodeEnd}}
{{PageSeeAlso}}
* [[SHELL]], [[RUN]]
* [[UCASE$]], [[LCASE$]]
* [[_COMMANDCOUNT]]
{{PageNavigation}}

View file

@ -1,27 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:34}}
[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules.
{{PageSyntax}}
: [[COMMON]] [SHARED] variableList
===Legacy support===
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[COMMON]] statement has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.
{{PageDescription}}
* COMMON must be called before any executable statements.
* [[SHARED]] makes the variables shared within [[SUB]] and [[FUNCTION]] procedures within that module.
* variableList is the list of common variables made available separated by commas.
* Remember to keep the variable type ''order'' the same in all modules, as the variables names don't matter.
* [[COMMON SHARED]] is most commonly used to share the variables with subs and functions of that module.
* '''Note: Values assigned to shared variables used as procedure call parameters will not be passed to other procedures. The shared variable value must be assigned inside of the [[SUB]] or [[FUNCTION]] procedure to be passed.'''
{{PageSeeAlso}}
* [[COMMON SHARED]], [[CHAIN]]
* [[DIM]], [[REDIM]], [[SHARED]]
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
{{PageNavigation}}

View file

@ -1,73 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:35}}
The [[CONST]] statement globally defines one or more named numeric or string values which will not change while the program is running.
{{PageSyntax}}
: [[CONST]] {{Parameter|constantName}} = {{Parameter|value}}[, ...]
{{Parameters}}
* {{Parameter|constantName}} is the constant name or list of names assigned by the programmer.
* {{Parameter|value}} is the value to initialize the global constant which cannot change once defined.
** If {{Parameter|constantName}} specifies a numeric type, {{Parameter|value}} must be a numeric expression containing literals and other constants.
** If {{Parameter|constantName}} specifies a string type, the {{Parameter|value}} must be a literal value.
{{PageDescription}}
* The {{Parameter|constantName}} does not have to include a type suffix. The datatype is automatically infered by the compiler using the {{Parameter|value}}.
* Constant values cannot reference a variable, [[SUB]] or [[FUNCTION]] return values when defined.
** The exception to the above are color functions [[_RGB32]] and [[_RGBA32]], which can be used in a CONST statement. See ''Example 2'' below.
* Constants cannot be reassigned values. They retain the same value throughout all of the program procedures.
* Constants defined in module-level code have [[SHARED|shared]] scope, so they can also be used in [[SUB]] or [[FUNCTION]] procedures.
* Constants defined in [[SUB]] or [[FUNCTION]] procedures are local to those procedures.
* [[CLEAR]] will not affect or change constant values.
{{PageExamples}}
''Example 1:'' Display the circumference and area of circles:
{{CodeStart}}' Declare a numeric constant approximately equal to the ratio of a circle's
' circumference to its diameter:
{{Cl|CONST}} PI = 3.141593
' Declare some string constants:
{{Cl|CONST}} circumferenceText = "The circumference of the circle is"
{{Cl|CONST}} areaText = "The area of the circle is"
{{Cl|DO...LOOP|DO}}
{{Cl|INPUT}} "Enter the radius of a circle or zero to quit"; radius
{{Cl|IF...THEN|IF}} radius = 0 {{Cl|IF...THEN|THEN}} {{Cl|END}}
{{Cl|PRINT}} circumferenceText; 2 * PI * radius
{{Cl|PRINT}} areaText; PI * radius * radius ' radius squared
{{Cl|PRINT}}
{{Cl|DO...LOOP|LOOP}}
{{CodeEnd}}
{{OutputStart}}Enter the radius of a circle or zero to quit? ''10''
The circumference of the circle is 62.83186
The area of the circle is 314.1593
Enter the radius of a circle or zero to quit? ''123.456''
The circumference of the circle is 775.697
The area of the circle is 47882.23
Enter the radius of a circle or zero to quit? ''0''
{{OutputEnd}}
: ''Explanation:'' PI cannot change as it is a mathematical constant so it is fitting to define it as a constant. Trying to change PI will result in a calculation error.
''Example 2'': Using _RGB32 to set a constant's value.
{{CodeStart}}
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|COLOR}} Red
{{Cl|PRINT}} "Hello World"
{{CodeEnd}}
{{PageSeeAlso}}
* [[DIM]], [[SHARED]]
* [[STATIC]], [[COMMON]]
* [[_PI]], [[_RGB32]], [[_RGBA32]]
* [http://doc.pcsoft.fr/en-US/?6510001 Windows 32 API constant values]
{{PageNavigation}}

View file

@ -1,108 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:36}}
The [[COS]] function returns the horizontal component or the cosine of an angle measured in radians.
{{PageSyntax}}
: {{Parameter|value!}} = [[COS]]({{Parameter|radianAngle!}})
{{Parameters}}
* The {{Parameter|radianAngle!}} must be measured in radians.
{{PageDescription}}
* To convert from degrees to radians, multiply degrees * ã / 180.
* [[COS]]INE is the horizontal component of a unit vector in the direction theta (é).
* COS(x) can be calculated in either [[SINGLE]] or [[DOUBLE]] precision depending on its argument.
::: COS(4) = -.6536436 ...... COS(4#) = -.6536436208636119
{{PageExamples}}
''Example 1:'' Converting degree angles to radians for QBasic's trig functions and drawing the line at the angle.
{{CodeStart}}
{{Cl|SCREEN}} 12
PI = 4 * {{Cl|ATN}}(1)
{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI
{{Cl|PRINT}} "COS(PI) = "; {{Cl|COS}}(PI)
{{Cl|PRINT}} "SIN(PI) = "; {{Cl|SIN}}(PI)
{{Cl|DO...LOOP|DO}}
{{Cl|PRINT}}
{{Cl|INPUT}} "Enter the degree angle (0 quits): ", DEGREES%
RADIANS = DEGREES% * PI / 180
{{Cl|PRINT}} "RADIANS = DEGREES% * PI / 180 = "; RADIANS
{{Cl|PRINT}} "X = COS(RADIANS) = "; {{Cl|COS}}(RADIANS)
{{Cl|PRINT}} "Y = SIN(RADIANS) = "; {{Cl|SIN}}(RADIANS)
{{Cl|CIRCLE}} (400, 240), 2, 12
{{Cl|LINE}} (400, 240)-(400 + (50 * {{Cl|SIN}}(RADIANS)), 240 + (50 * {{Cl|COS}}(RADIANS))), 11
DEGREES% = RADIANS * 180 / PI
{{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES%
{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0
{{CodeEnd}}
{{OutputStart}}
PI = 4 * ATN(1) = 3.141593
COS(PI) = -1
SIN(PI) = -8.742278E-08
Enter the degree angle (0 quits): 45
RADIANS = DEGREES% * PI / 180 = .7853982
X = COS(RADIANS) = .7071068
Y = SIN(RADIANS) = .7071068
DEGREES% = RADIANS * 180 / PI = 45
{{OutputEnd}}
: ''Explanation:'' When 8.742278E-08(.00000008742278) is returned by [[SIN]] or COS the value is essentially zero.
''Example 2:'' Creating 12 analog clock hour points using [[CIRCLE]]s and [[PAINT]]
{{CodeStart}}
PI2 = 8 * {{Cl|ATN}}(1) '2 * π
arc! = PI2 / 12 'arc interval between hour circles
{{Cl|SCREEN (statement)|SCREEN}} 12
FOR t! = 0 TO PI2 STEP arc!
cx% = {{Cl|CINT}}({{Cl|COS}}(t!) * 70) ' pixel columns (circular radius = 70)
cy% = {{Cl|CINT}}({{Cl|SIN}}(t!) * 70) ' pixel rows
{{Cl|CIRCLE}} (cx% + 320, cy% + 240), 3, 12
{{Cl|PAINT}} {{Cl|STEP}}(0, 0), 9, 12
NEXT
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The 12 circles are placed at radian angles that are 1/12 of 6.28318 or .523598 radians apart.
''Example 3:'' Creating a rotating spiral with COS and [[SIN]].
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|DO...LOOP|DO}}
{{Cl|LINE}} (0, 0)-(640, 480), {{Cl|_RGB}}(0, 0, 0), BF
j = j + 1
{{Cl|PSET}} (320, 240)
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1
{{Cl|LINE}} -(.05 * i * i * {{Cl|COS}}(j + i) + 320, .05 * i * i * {{Cl|SIN}}(j + i) + 240)
{{Cl|NEXT}}
{{Cl|PSET}} (320, 240)
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1
{{Cl|LINE}} -(.05 * i * i * {{Cl|COS}}(j + i + 10) + 320, .05 * i * i * {{Cl|SIN}}(j + i + 10) + 240)
{{Cl|NEXT}}
{{Cl|PSET}} (320, 240)
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 100 {{Cl|STEP}} .1
{{Cl|PAINT}} (.05 * i * i * {{Cl|COS}}(j + i + 5) + 320, .05 * i * i * {{Cl|SIN}}(j + i + 5) + 240)
{{Cl|NEXT}}
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INP}}({{Cl|&H}}60) = 1 'escape exit
{{CodeEnd}}
{{small|Code by Ben}}
{{PageSeeAlso}}
* [[_PI]] {{text|(QB64 function)}}
* [[SIN]] {{text|(sine)}}
* [[ATN]] {{text|(arctangent)}}
* [[TAN]] {{text|(tangent)}}
*[[Mathematical Operations]]
*[[Mathematical_Operations#Derived_Mathematical_Functions|Derived Mathematical Functions]]
{{PageNavigation}}

View file

@ -1,34 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:37}}
[[CSNG]] converts a numerical value to the closest [[SINGLE]]-precision number.
{{PageSyntax}}
: {{Parameter|singleValue!}} = [[CSNG]]({{Parameter|expression}})
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* Returns the closest [[SINGLE]] decimal point value.
* Also used to define a value as [[SINGLE]]-precision up to 7 decimals.
{{PageExamples}}
{{CodeStart}}
A# = 975.3421222#
PRINT A#, CSNG(A#)
{{CodeEnd}}
{{OutputStart}}975.3421222      975.3421
{{OutputEnd}}
''See also:''
* [[CDBL]], [[CLNG]]
* [[CINT]], [[INT]]
* [[_ROUND]]
{{PageNavigation}}

View file

@ -1,52 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:39}}
The [[CSRLIN]] function returns the current text row position of the [[PRINT]] cursor.
{{PageSyntax}}
: {{Parameter|row%}} = [[CSRLIN]]
{{PageDescription}}
* The value returned is within the range of 1 to the current number of rows in the [[SCREEN]] mode used.
** In [[SCREEN]] 0 (text mode), the [[_HEIGHT]] function returns the number of text rows.
** In graphic modes, the number of available text rows can be calculated by dividing [[_HEIGHT]] (measured in pixels in graphic modes) by [[_FONTHEIGHT]]: '''''totalRows%'' = _HEIGHT / _FONTHEIGHT'''
* In screen modes that support page flipping, the [[CSRLIN]] function returns the vertical coordinate of the cursor on the active page.
* x = [[POS]](0) returns the column location of the cursor.
{{PageExamples}}
''Example:'' A semicolon stops the print cursor immediately after the print.
{{CodeStart}}
LOCATE 5, 5: PRINT "HELLO ";
Y = {{Cl|CSRLIN}} 'save the row
X = {{Cl|POS}}(0) 'save the column
LOCATE 10, 10: PRINT "WORLD"
LOCATE Y, X 'restore saved position
PRINT "GOODBYE"
{{CodeEnd}}
{{OutputStart}}
HELLO GOODBYE
WORLD
{{OutputEnd}}
:''Explanation:'' "HELLO " is printed and the semicolon stops the cursor immediately after the text. The [[CSRLIN]] variable records the current print cursor's text row in Y. The [[POS]] function records the current print cursor's text column in X. The second [[PRINT]] statement displays the comment "WORLD" on the 10th line of the screen. The last [[LOCATE]] statement restores the position of the cursor to the original line and column immediately after the first print.
{{PageSeeAlso}}
* [[SCREEN]], [[LOCATE]], [[POS]]
* [[_PRINTSTRING]] (graphic print)
{{PageNavigation}}

View file

@ -1,41 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:41}}
The [[CVDMBF]] function decodes an 8-byte [[STRING]] generated by [[MKDMBF$]] (or read from a file) to [[DOUBLE]] numeric values.
{{PageSyntax}}
: {{Parameter|result#}} = [[CVDMBF]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKDMBF$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKDMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVDMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
Value of a# encoded using MKDmbf$: 5─c▼d▬æ
The string above, decoded using CVDMBF: 77000.24523213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 15 ASCII characters (fifteen bytes), writing to a file using [[MKDMBF$]] conversion, and then reading back with the [[CVDMBF]] conversion can save up to 7 bytes of storage space.
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,52 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:40}}
The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read from a file) to [[DOUBLE]] numeric values.
{{PageSyntax}}
: {{Parameter|result#}} = [[CVD]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* Variables of numerical types are also encoded when [[PUT]] to a [[RANDOM]] or [[BINARY]]-access file.
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[DOUBLE]] values can range up to 15 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Reading an 8-byte encoded string n$ from a file and obtaining the decoded [[DOUBLE]] value:
{{CodeStart}}
{{Cl|FIELD}} #1, 8 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y# = {{Cl|CVD}}(N$)
{{CodeEnd}}
: ''Explanation:'' Reads a field from file #1, and converts the first eight bytes (N$) into an double-precision number assigned to the variable Y#.
''Example 2:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a# = 77000.24523213
{{Cl|PRINT}} "Value of a#:"; a#
b$ = {{Cl|MKD$}}(a#)
{{Cl|PRINT}} "Value of a# encoded using MKD$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVD:"; {{Cl|CVD}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a#: 77000.24523213
Value of a# encoded using MKD$: ñåxýâ╠‗@
The string above, decoded using CVD: 77000.24523213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 15 ASCII characters (fifteen bytes), writing to a file using [[MKD$]] conversion, and then reading back with the [[CVD]] conversion can save up to 7 bytes of storage space.
{{PageSeeAlso}}
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVL]], [[CVSMBF]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,67 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:42}}
The [[CVI]] function decodes a 2-byte [[STRING]] generated by [[MKI$]] (or read from a file) to [[INTEGER]] numeric values.
{{PageSyntax}}
: {{Parameter|result%}} = [[CVI]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[INTEGER]] values can range from -32768 to 32767.
* Doesn't return [[_UNSIGNED]] values.
{{PageExamples}}
''Example 1:''
{{CodeStart}}
{{Cl|FIELD}} #1, 2 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1 'GET does not need a position or variable with successive FIELD buffer reads
Y = {{Cl|CVI}}(N$)
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first two bytes (N$) into an integer number assigned to the variable Y.
:Since the representation of an integer number can use up to 5 ASCII characters (five bytes), writing to a file using [[MKI$]] conversion, and then reading back with the [[CVI]] conversion can save up to 3 bytes of storage space.
''Example 2:'' How CVI converts the ASCII code values created by the MKI$ function.
{{CodeStart}}
{{Cl|SCREEN (statement)|SCREEN}} 12
{{Cl|DIM}} Q {{Cl|AS}} {{Cl|STRING}} * 1
Q = {{Cl|CHR$}}(34)
' create Print using templates to align the values returned
tmp1$ = "1st character code = ### * 1 = ### "
tmp2$ = "2nd character code = ### * 256 = ##### "
tmp3$ = " & "
tmp4$ = " CVI Total = ##### "
{{Cl|DO...LOOP|DO}}
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number%
{{Cl|IF...THEN|IF}} number% < 1 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|CLS}}
ASCII$ = {{Cl|MKI$}}(number%) ' create the 2 byte character string
{{Cl|COLOR}} 11
{{Cl|_PRINTSTRING}} (152, 240), "{{Cl|MKI$}} creates 2 byte ASCII string: " + Q + ASCII$ + Q ' displays character(s)
asc1% = {{Cl|ASC}}(ASCII$) ' find the ASCII code values of each character
asc2% = {{Cl|ASC}}(ASCII$, 2) ' '''QB64''' allows ASC to read specific characters in a string
{{Cl|LOCATE}} 18, 20: {{Cl|PRINT USING}} tmp1$; asc1%; asc1%
{{Cl|LOCATE}} 19, 20: {{Cl|PRINT USING}} tmp2$; asc2%; asc2% * 256
{{Cl|LOCATE}} 20, 20: {{Cl|PRINT USING}} tmp3$; "-----"
{{Cl|LOCATE}} 21, 20: {{Cl|PRINT USING}} tmp4$; asc1% + (256 * asc2%)
{{Cl|LOOP}}
{{Cl|SYSTEM}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired. ("90" gets decoded to 12345).
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVS]], [[CVD]], [[CVL]], [[CVSMBF]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,44 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:43}}
The [[CVL]] function decodes a 4-byte [[STRING]] generated by [[MKL$]] (or read from a file) to [[LONG]] numeric values.
{{PageSyntax}}
: {{Parameter|result&}} = [[CVL]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[LONG]] values can range from -2147483648 to 2147483647.
* Doesn't return [[_UNSIGNED]] values.
{{PageExamples}}
''Example 1: 4 byte [[ASCII]] character strings show how CVL multipliers convert [[MKL$]] values into a 4 byte [[LONG]] value.
{{CodeStart}}
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(1) + {{Cl|STRING$}}(3, 0)) '{{Cl|ASC}}(CHR$(1)) * 1 = 1
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(0) + {{Cl|CHR$}}(1) + {{Cl|STRING$}}(2, 0)) '{{Cl|ASC}}(CHR$(1)) * 256 = 256
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(2, 0) + {{Cl|CHR$}}(1) + {{Cl|CHR$}}(0)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 = 65536
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(3, 0) + {{Cl|CHR$}}(1)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 * 256 = 16777216
{{CodeEnd}}
''Example 2:''
{{CodeStart}}
{{Cl|FIELD}} #1, 4 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y& = {{Cl|CVL}}(N$)
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first four bytes (N$) into a long integer value assigned to the variable Y&.
:Since the representation of a long number can use up to 10 ASCII characters (ten bytes), writing to a file using [[MKL$]] conversion, and then reading back with the [[CVL]] conversion can save up to 6 bytes of storage space.
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVDMBF]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,39 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:47}}
The [[CVDMBF]] function decodes a 4-byte [[STRING]] generated by [[MKSMBF$]] (or read from a file) to [[SINGLE]] numeric values.
{{PageSyntax}}
: {{Parameter|result!}} = [[CVSMBF]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[SINGLE]] values can range up to 7 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKSMBF$}}(a!)
{{Cl|PRINT}} "Value of a! encoded using MKSMBF$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVSMBF:"; {{Cl|CVDMBF}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a!: 700.2213
Value of a# encoded using MKSMBF$: *♫/è
The string above, decoded using CVSMBF: 700.2213
{{OutputEnd}}
:Since the representation of a double-precision number can use up to 7 ASCII characters (seven bytes), writing to a file using [[MKSMBF$]] conversion, and then reading back with the [[CVSMBF]] conversion can save up to 3 bytes of storage space.
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVS]], [[CVD]], [[CVL]], [[CVDMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,39 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:46}}
The [[CVS]] function decodes a 4-byte [[STRING]] generated by [[MKS$]] (or read from a file) to [[SINGLE]] numeric values.
{{PageSyntax}}
: {{Parameter|result!}} = [[CVS]]({{Parameter|stringData$}})
{{PageDescription}}
* ''CV'' functions ([[CVD]], [[CVS]], [[CVI]], [[CVL]], [[CVDMBF]], [[CVSMBF]]) are used to convert values encoded by ''MK$'' functions ([[MKD$]], [[MKS$]], [[MKI$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]).
* '''QB64''' has [[_CV]] and [[_MK$]] functions which can also deal with extended [[Data types|data types]].
* [[SINGLE]] values can range up to 7 decimal point digits. Decimal point accuracy depends on whole value places taken.
{{PageExamples}}
''Example 1:'' Showcases the reduced space to store an encoded number.
{{CodeStart}}
a! = 700.2213
{{Cl|PRINT}} "Value of a!:"; a!
b$ = {{Cl|MKDMBF$}}(a!)
{{Cl|PRINT}} "Value of a# encoded using MKS$: "; b$
{{Cl|PRINT}} "The string above, decoded using CVS:"; {{Cl|CVS}}(b$)
{{CodeEnd}}
{{OutputStart}}
Value of a!: 700.2213
Value of a# encoded using MKS: *♫/D
The string above, decoded using CVS: 700.2213
{{OutputEnd}}
:Since the representation of a single-precision number can use up to 7 ASCII characters (seven bytes), writing to a file using [[MKS$]] conversion, and then reading back with the [[CVS]] conversion can save up to 3 bytes of storage space.
{{PageSeeAlso}}
* [[MKD$]], [[MKI$]], [[MKS$]], [[MKL$]], [[MKDMBF$]], [[MKSMBF$]]
* [[CVI]], [[CVD]], [[CVL]], [[CVDMBF]], [[CVSMBF]]
* [[_CV]], [[_MK$]]
{{PageNavigation}}

View file

@ -1,24 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:53:56}}
A '''colon''' can be used to separate two unrelated procedure statements on the same line.
''Usage:'' COLOR 10: PRINT "Hello "; : COLOR 12: PRINT "World"
{{OutputStart}}
{{text|Hello |limegreen}}{{text|World|red}}
{{OutputEnd}}
* Use colons to combine variable definition statements or screen [[PRINT|prints]].
* Some statements such as [[END IF]] and [[Metacommand]]s require a new code line!
* Use [[Semicolon|semicolons]] and [[Comma|commas]] where appropriate in [[PRINT]]s.
* Use an [[underscore]] at the end of a line to extend a line of code to the next line.
''See also:''
* [[Comma]], [[Semicolon]]
{{PageNavigation}}

View file

@ -1,83 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:48}}
The [[DATA]] statement creates a line of fixed program information separated by commas. The DATA can be later READ by the program at runtime.
{{PageSyntax}}
: [[DATA]] [value1, value2, ...]
{{PageDescription}}
* DATA is used at the beginning of every data field line with commas separating the values that follow.
* Values can be any '''literal''' [[STRING]] or numerical type. '''Variables cannot be used.'''
* DATA fields can be placed and READ consecutively in the main program code body with or without line labels for [[RESTORE]].
* DATA is best placed after the main program code.
** '''QB64''' DATA can be placed inside a [[SUB]] or [[FUNCTION]] procedures.
* [[RESTORE]] will only read the first data field if the DATA is not labeled or no label is specified in a RESTORE call.
* When using multiple DATA fields, label each data field with a line label so that each data pointer can be reset for multiple reads with '''[[RESTORE]] ''linelabel'''''.
* QBasic comma separations were flexible to allow column alignments when creating them. QB64 removes spacing between commas.
* [[STRING]] DATA values with end spaces, QBasic keywords and values that include the comma character must be enclosed in quotation marks.
* DATA fields can only be created by the programmer and cannot be changed by a user or lost.
* Comments after a data line require a colon before the comment.
* If a [[READ]] statement attempts to read past the last data value, an [[ERROR Codes|"Out of Data" error]] will occur. Use end of data markers when necessary.
* '''[[DATA]] fields can be placed after [[SUB]] or [[FUNCTION]] procedures, but line labels are not allowed.'''
{{PageExamples}}
''Example 1:'' Creating two DATA fields that can be [[READ]] repeatedly using [[RESTORE]] with the appropriate line label.
{{CodeStart}}
{{Cl|RESTORE}} Database2
{{Cl|READ}} A$, B$, C$, D$ 'read 4 string values from second DATA field
PRINT A$ + B$ + C$ + D$ 'note that quoted strings values are spaced
{{Cl|RESTORE}} Database1
FOR i = 1 TO 18
{{Cl|READ}} number% 'read first DATA field 18 times only
PRINT number%;
NEXT
END
Database1:
{{Cl|DATA}} 1, 0, 0, 1, 1, 0, 1, 1, 1
{{Cl|DATA}} 2, 0, 0, 2, 2, 0, 2, 2, 2 : ' DATA line comments require a colon
Database2:
{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work!
{{CodeEnd}}
{{OutputStart}}Hello world! Goodbyework!
1 0 0 1 1 0 1 1 1 2 0 0 2 2 0 2 2 2
{{OutputEnd}}
''Example 2:'' How to [[RESTORE]] and [[READ]] DATA in a [[SUB]] procedure in QB64. Line labels can be used for multiple DATA fields.
{{CodeStart}}
{{Cl|DIM}} {{Cl|SHARED}} num(10) 'shared array or must be passed as a parameter
ReadData 2 '<<<<<<< change value to 1 to read other data
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|PRINT}} num(i);
{{Cl|NEXT}}
{{Cl|END}}
{{Cl|SUB}} ReadData (mode)
{{Cl|IF...THEN|IF}} mode = 1 {{Cl|THEN}} {{Cl|RESTORE}} mydata1 {{Cl|ELSE}} {{Cl|RESTORE}} mydata2
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|READ}} num(i)
{{Cl|NEXT}}
mydata1:
{{Cl|DATA}} 1,2,3,4,5,6,7,8,9,10
mydata2:
{{Cl|DATA}} 10,9,8,7,6,5,4,3,2,1
{{Cl|END SUB}}
{{CodeEnd}}
{{OutputStart}} 10 9 8 7 6 5 4 3 2 1 {{OutputEnd}}
{{PageSeeAlso}}
* [[READ]]
* [[RESTORE]]
* [[SUB]], [[FUNCTION]]
{{PageNavigation}}

View file

@ -1,72 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:49}}
The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
{{PageSyntax}}
: {{Parameter|today$}} = [[DATE$]]
{{PageDescription}}
* Returns the current computer date in the format "mm-dd-yyyy" (e.g., "12-25-2009").
{{PageExamples}}
''Example:'' Displaying the weekday and current date.
{{CodeStart}}
{{Cl|PRINT}} {{Cl|DATE$}}
month$ = {{Cl|LEFT$}}({{Cl|DATE$}}, 2): M = {{Cl|VAL}}(month$)
day$ = {{Cl|MID$}}({{Cl|DATE$}}, 4, 2): D = {{Cl|VAL}}(day$)
day$ = {{Cl|STR$}}(D) ' eliminate any leading zeros
year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$)
{{Cl|SELECT CASE}} M
{{Cl|CASE}} 1: Moon$ = "January"
{{Cl|CASE}} 2: Moon$ = "February"
{{Cl|CASE}} 3: Moon$ = "March"
{{Cl|CASE}} 4: Moon$ = "April"
{{Cl|CASE}} 5: Moon$ = "May"
{{Cl|CASE}} 6: Moon$ = "June"
{{Cl|CASE}} 7: Moon$ = "July"
{{Cl|CASE}} 8: Moon$ = "August"
{{Cl|CASE}} 9: Moon$ = "September"
{{Cl|CASE}} 10: Moon$ = "October"
{{Cl|CASE}} 11: Moon$ = "November"
{{Cl|CASE}} 12: Moon$ = "December"
{{Cl|END SELECT}}
{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10)
{{Cl|DEFINT}} A-Z
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
{{Cl|IF}} M < 3 {{Cl|THEN}} M = M + 12: Y = Y - 1 'add 12 to Jan - Feb month, -1 year
C = Y \ 100: Y = Y {{Cl|MOD}} 100 'split century and year number
S1 = (C \ 4) - (2 * C) - 1 'century leap
S2 = (5 * Y) \ 4 '4 year leap
S3 = 26 * (M + 1) \ 10 'days in months
WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder
{{Cl|IF}} WkDay < 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6
{{Cl|SELECT CASE}} WkDay
{{Cl|CASE}} 0: day$ = "Sunday"
{{Cl|CASE}} 1: day$ = "Monday"
{{Cl|CASE}} 2: day$ = "Tuesday"
{{Cl|CASE}} 3: day$ = "Wednesday"
{{Cl|CASE}} 4: day$ = "Thursday"
{{Cl|CASE}} 5: day$ = "Friday"
{{Cl|CASE}} 6: day$ = "Saturday"
{{Cl|END SELECT}}
WeekDay$ = day$
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
{{OutputStart}}
06-02-2010
Today is Wednesday, June 2, 2010
{{OutputEnd}}
{{PageSeeAlso}}
* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]]
* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]]
{{PageNavigation}}

View file

@ -1,106 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:08}}
'''DECLARE DYNAMIC LIBRARY''' allows you to dynamically link your program to functions in dynamically linkable libraries. At present, only ''.DLL'' files are supported (support for ''.so'' will be added soon). These libraries are loaded when your program begins.
{{PageSyntax}}
: DECLARE [DYNAMIC|CUSTOMTYPE|STATIC] LIBRARY [''"DLL_Library_file"'', "other_library..."]
: {SUB|FUNCTION} [''procedure_name'' ALIAS] ''library_procedure'' (BYVAL ''parameter(s)'',...)
::.
::. 'other Library sub-procedures for named ''DLL''
::.
: END DECLARE
{{PageDescription}}
* The dynamic library file can be located in the QB64 folder (alongside your programs '.EXE'), in Windows' system32 folder, or in a relative/absolute path specified along with the library name.
* '''Declarations must be made at the program start and only one ''.DLL'' file can be specified in each declaration block.'''
* ''Library_file'' is the ''DLL'' file's name with a specified path when not in the QB64 or the WINDOWS\SYSTEM32 folder. Don't add a file extension.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* ''Procedure_name'' is any procedure name you want to designate by using [[ALIAS]] with the ''Library_procedure'' name following.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] values.
* '''''.h'' header files cannot be used with DECLARE DYNAMIC LIBRARY. Existence of any ''.h'' file of the same name as the ''.DLL'' file will cause DECLARE DYNAMIC LIBRARY to fail.'''
* '''IMPORTANT:''' [[DECLARE DYNAMIC LIBRARY]] let's you specify any SUB/FUNCTION calling format you wish, but '''if the size of the parameters does not match, the size expected within the library your code will probably cause a GPF (General Protection Fault).''' It is important to understand that you are creating a 32-bit program (even under 64-bit Windows) so '''pointers (if required) will be 32-bits in size, the equivalent of a [[LONG]].'''
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't really use shared libraries (DLLs are a bit different) this does not affect Windows users.
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* [[SUB]] procedures using DECLARE CUSTOMTYPE LIBRARY API procedures '''may error'''. Try DYNAMIC with the DLL name.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use. QB64 cannot guarantee that any procedure will work and cannot quarantee any troubleshooting help.'''
==Availability==
* '''Version 0.923 and up (Windows)'''
* '''Version 0.94 and up (Linux and macOS)'''
{{PageExamples}}
''Example 1:'' This example plays Midi files using the ''playmidi32.dll'' documented here: [http://libertybasicuniversity.com/lbnews/nl110/midi3.htm Liberty Basic University]. Download the following DLL file to your main QB64 folder: [https://www.qb64.org/resources/Playmidi32.dll PlayMidi32.dll]
{{CodeStart}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32"
{{Cl|FUNCTION}} PlayMIDI& (filename {{Cl|AS}} {{Cl|STRING}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0))
{{Cl|PRINT}} result
{{CodeEnd}}
: '''Note:''' Filename needs to be [[CHR$]](0) terminated. QB64 [[STRING]]s are passed to external libraries as pointers to first character.
''Example 2:'' Using a CUSTOMTYPE LIBRARY to return the [[Unicode]] version of the current running program's name.
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav
{{Cl|FUNCTION}} GetModuleFileNameA& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|FUNCTION}} GetModuleFileNameW& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
'=== SHOW CURRENT PROGRAM
FileName$ = {{Cl|SPACE$}}(512)
Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$))
{{Cl|IF...THEN|IF}} Result {{Cl|THEN}} {{Cl|PRINT}} "CURRENT PROGRAM (ASCII): "; {{Cl|LEFT$}}(FileName$, Result)
'load a unicode font
f = {{Cl|_LOADFONT}}("cyberbit.ttf", 24, "UNICODE")
{{Cl|_FONT}} f
Result = GetModuleFileNameW(0, FileName$, {{Cl|LEN}}(FileName$) \ 2)
{{Cl|LOCATE}} 2, 1
{{Cl|PRINT}} QuickCP437toUTF32$("CURRENT PROGRAM (UTF): ") + QuickUTF16toUTF32$({{Cl|LEFT$}}(FileName$, Result * 2))
{{Cl|_FONT}} 16 'restore CP437 font
{{Cl|FUNCTION}} QuickCP437toUTF32$ (a$)
b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 4, 0)
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$)
{{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i)
{{Cl|NEXT}}
QuickCP437toUTF32$ = b$
{{Cl|END FUNCTION}}
{{Cl|FUNCTION}} QuickUTF16toUTF32$ (a$)
b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 2, 0)
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(a$) \ 2
{{Cl|ASC}}(b$, i * 4 - 3) = {{Cl|ASC}}(a$, i * 2 - 1)
{{Cl|ASC}}(b$, i * 4 - 2) = {{Cl|ASC}}(a$, i * 2)
{{Cl|NEXT}}
QuickUTF16toUTF32$ = b$
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by Galleon}}
: '''Note:''' SUB procedures using CUSTOMTYPE LIBRARY API procedures inside may error. Try DYNAMIC with "KERNEL32".
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
* [[DECLARE LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[_OFFSET (function)]], [[_OFFSET]] {{text|(variable type)}}
* [[C Libraries]], [[SDL Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
{{PageNavigation}}

View file

@ -1,104 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:37:06}}
The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64.
{{PageSyntax}}
: '''DECLARE''' [DYNAMIC|CUSTOMTYPE|STATIC] '''LIBRARY''' [{''"Library_filename"''|''"Headerfile"''}]
: {[[SUB]]|[[FUNCTION]]} [''procedure_name'' {{KW|ALIAS}}] ''library_procedure'' ([{{KW|BYVAL}}] ''parameter {{KW|AS}}'', ...)
::.
::. 'other SUBs or Functions as required
::.
: '''END DECLARE'''
{{Parameters}}
* The {{Parameter|Library_filename}} is needed if a Library is not already loaded by QB64. Do not include the ''.DLL'', ''LIB'' or ''.H'' file extension.
** It's always a good idea to try declaring Windows API libraries without a {{Parameter|Library_filename}} first, as most Windows headers are already included in QB64 source.
* Begin the {{Parameter|Library_filename}} with '''./''' or '''.\''' to make it relative to the path where your source file is saved, so you can keep all your project files together.
* {{Parameter|Procedure_name}} is any program procedure name you want to designate by using [[ALIAS]] with the {{Parameter|Library_procedure}} name.
* {{Parameter|Library procedure}} is the actual procedure name used inside of the library or header file.
===Library Types===
* '''[[DECLARE DYNAMIC LIBRARY|DYNAMIC]]''' links a program to functions in dynamically linkable libraries. At present, only .DLL files are supported
* '''CUSTOMTYPE''' is already implied when using [[DECLARE DYNAMIC LIBRARY]]. This type of library just allows the same flexibility to apply when referencing STATIC libraries that are used to refer to dynamic libraries. Supports shared object (*.so) libraries.
* '''STATIC''' is the same as [[DECLARE LIBRARY]] except that it prioritizes linking to static libraries (*.a/*.o) over shared object (*.so) libraries, if both exist. As Windows doesn't use shared libraries (DLLs are different) this does not affect Windows users.
{{PageDescription}}
* The declaration can be used with C++ sub-procedures, Windows API and QB64 SDL (versions prior to 1.000)/OpenGL (version 1.000 and up) Libraries.
* ''Library filename''s can be listed to combine more than one DLL or Header file name or path into one DECLARE LIBRARY block.
* C procedures can use a header file name. File code must be included with program code. Do not include the ''.h'' extension.
* ''Parameters'' used by the Library procedure must be passed by value ([[BYVAL]]) except for [[STRING]] characters.
* When using a procedure from an '''unsupported''' Dynamic Link Library (DLL file) use [[DECLARE DYNAMIC LIBRARY]].
* The [[_OFFSET]] in memory can be used in '''CUSTOMTYPE''', '''STATIC''' and '''DYNAMIC LIBRARY''' declarations.
* Declarations can be made inside of [[SUB]] or [[FUNCTION]] procedures. Declarations do not need to be at program start.
* '''NOTE: It is up to the user to document and determine the suitability of all Libraries and procedures they choose to use! QB64 cannot guarantee that any procedure will work and cannot quarantee any troubleshooting help.'''
{{PageExamples}}
''Example 1:'' Using an '''SDL''' library procedure as a program SUB procedure to move the mouse pointer to a coordinate (works in versions prior to 1.000):
{{CodeStart}}
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} SDL_WarpMouse ({{Cl|BYVAL}} column {{Cl|AS}} {{Cl|LONG}}, {{Cl|BYVAL}} row {{Cl|AS}} {{Cl|LONG}}) 'SDL procedure name
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 256) 'simulate screen 12 with 256 colors
{{Cl|RANDOMIZE}} {{Cl|TIMER}}
DO
{{Cl|_DELAY}} 1
x = {{Cl|RND}} * 640: y = {{Cl|RND}} * 480
{{Cl|LINE}} (x, y)-{{Cl|STEP}}(10, 10), {{Cl|RND}} * 100 + 32, BF
MouseMove x + 5, y + 5
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|LEN}}({{Cl|INKEY$}}) 'any keypress quits
{{Cl|END}}
{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}})
SDL_WarpMouse x, y 'call SDL library procedure
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Code by Galleon}}
:''Explanation:'' The SDL Library is included and loaded with QB64 versions prior to 1.000, so these procedures are directly available for use.
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_DELAY}} 2
MouseMove 100, 100
{{Cl|_DELAY}} 2
MouseMove 200, 200
{{CodeEnd}}
:''Explanation:'' When a Library procedure is used to represent another procedure name use [[ALIAS]] instead. Saves creating a SUB!
''Example 2:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes.
{{CodeStart}}
{{Cl|DECLARE LIBRARY}} ""
{{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE
{{CodeEnd}}
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.'''
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
* [[DECLARE DYNAMIC LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
* [[SQL Client]]
{{PageNavigation}}

View file

@ -1,42 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:51}}
The [[DEFDBL]] statement defines all variables with names starting with the specified letter (or letter range) AS [[DOUBLE]] variables instead of the [[SINGLE]] type default.
{{PageSyntax}}
: [[DEFDBL]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
===Legacy support===
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS DOUBLE, a2 AS DOUBLE, a3 AS DOUBLE{{InlineCodeEnd}}, simply having {{InlineCode}}DEFDBL A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFDBL]].
* [[DEFDBL]] sets the [[type]] 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]] procedures).
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding 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]] procedures.
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFDBL}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type DOUBLE, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,43 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:53}}
The [[DEFINT]] statement defines all variables with names starting with the specified letter (or letter range) AS [[INTEGER]] variables instead of the [[SINGLE]] type default.
{{PageSyntax}}
: [[DEFINT]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
===Legacy support===
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS INTEGER, a2 AS INTEGER, a3 AS INTEGER{{InlineCodeEnd}}, simply having {{InlineCode}}DEFINT A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFINT]].
* [[DEFINT]] sets the [[type]] 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]] procedures).
* For [[_UNSIGNED]] [[INTEGER]], use [[_DEFINE]]
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding 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]] procedures.
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFINT}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type INTEGER, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,43 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:54}}
The [[DEFLNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[LONG]] variables instead of the [[SINGLE]] type default.
{{PageSyntax}}
: [[DEFLNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
===Legacy support===
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS LONG, a2 AS LONG, a3 AS LONG{{InlineCodeEnd}}, simply having {{InlineCode}}DEFLNG A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFLNG]].
* [[DEFLNG]] sets the [[type]] 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]] procedures).
* For [[_UNSIGNED]] [[LONG]], use [[_DEFINE]]
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding 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]] procedures.
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFLNG}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type LONG, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFDBL]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,43 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:55}}
The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables.
{{PageSyntax}}
: [[DEFSNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
===Legacy support===
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS SINGLE, a2 AS SINGLE, a3 AS SINGLE{{InlineCodeEnd}}, simply having {{InlineCode}}DEFSNG A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* Undeclared variables with no type suffix are of type [[SINGLE]] by default.
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFSNG]].
* [[DEFSNG]] sets the [[type]] 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]] procedures).
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding 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]] procedures.
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFSNG}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type SINGLE, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFDBL]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,42 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:56}}
The [[DEFSTR]] statement defines all variables with names starting with the specified letter (or letter range) AS [[STRING]] variables instead of the [[SINGLE]] type default.
{{PageSyntax}}
: [[DEFSTR]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
===Legacy support===
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS STRING, a2 AS STRING, a3 AS STRING{{InlineCodeEnd}}, simply having {{InlineCode}}DEFSTR A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
* Variables [[DIM]]ensioned as another variable type or that use type suffixes are not affected by [[DEFSTR]].
* [[DEFSTR]] sets the [[type]] 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]] procedures).
* '''Warning: QBasic keyword names can only be used as string variable names when they are followed by the string type suffix ($).'''
==QBasic/QuickBASIC==
* QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding 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]] procedures.
{{PageExamples}}
{{CodeStart}}
{{Cl|DEFSTR}} A, F-H, M
'With the above, all variables with names starting with A, F, G, H and M
'will be of type STRING, unless they have a type suffix
'indicating another type or they are {{Cl|DIM|dimensioned}} differently
{{CodeEnd}}
{{PageSeeAlso}}
* [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFDBL]]
* [[_DEFINE]]
{{PageNavigation}}

View file

@ -1,74 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:50}}
[[DEF SEG]] is used to define the area in memory to access QB64's emulated conventional memory.
{{PageSyntax}}
: [[DEF SEG]] [=][{segment|VARSEG(variable}]
===Legacy support===
* '''QB64 implements memory access using [[_MEM]] and related functions. For that reason, [[DEF SEG]] isn't recommended practice anymore and is supported to maintain compatibility with legacy code.'''
{{PageDescription}}
* Used to set the pointer to a memory area of a variable/array or register.
* [[PEEK]] and [[POKE]] require a segment memory address (often just 0) without using VARSEG.
* Important segments using [[PEEK]] and [[POKE]] include &HB800 (text segment) and &HA000 (graphics segment).
* [[BSAVE]] and [[BLOAD]] require a VARSEG reference to the grahic array(0 index) used.
* Always use DEF SEG when the procedure is completed, in order to reset the segment to QBasic's default value.
* [[DEF SEG]], [[VARSEG]], [[VARPTR]], [[PEEK]] and [[POKE]] access QB64's emulated 16 bit conventional memory block. '''It is highly recommended to use QB64's [[_MEM]] memory system to avoid running out of memory.'''
<!--
{{PageExamples}}
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
{{CodeStart}}
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
{{Cl|DEFINT}} A-Z
{{Cl|DIM}} filename {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} result {{Cl|AS}} {{Cl|LONG}}
{{Cl|DIM}} t {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} i {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|CONST}} codelen = 48
{{Cl|DIM}} code {{Cl|AS}} {{Cl|STRING}} * codelen
{{Cl|CLS}}
t = "5589E51E8B560C8EDA8B5E0A8B5702B441CD218B56088EDA8B5E06720B6631C0"
t = t + "6689071F5DCA0800660D0000FFFFEBF0"
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} codelen - 1
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&h" + {{Cl|MID$}}(t, i + i + 1, 2)))
{{Cl|NEXT}}
{{Cl|OPEN}} file {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} 1 'create temporary file
{{Cl|PRINT (file statement)|PRINT}} #1, "I am doomed! :-("
{{Cl|CLOSE}}
{{Cl|PRINT}} "now you see it:"
{{Cl|SHELL}} "dir " + file
K$ = {{Cl|INPUT$}}(1)
filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(code)
{{Cl|CALL}} absolute('''SEG''' filename, '''SEG''' result, {{Cl|VARPTR}}(code))
{{Cl|IF...THEN|IF}} result {{Cl|THEN}} 'check results
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&)
{{Cl|ELSE}}
{{Cl|PRINT}} "now you don't:"
{{Cl|END IF}}
{{Cl|SHELL}} "dir " + file
{{Cl|END}}
{{CodeEnd}}
{{small|Code by Michael Calkins as Public Domain(2011)}}
-->
''See also:''
* [[DEF SEG = 0]]
* [[VARPTR]], [[VARSEG]]
* [[PEEK]], [[POKE]]
* [[BSAVE]], [[BLOAD]]
{{PageNavigation}}

View file

@ -1,111 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:57}}
The [[DIM]] statement is used to declare a variable or a list of variables as a specified data type or to dimension [[$STATIC]] or [[$DYNAMIC]] [[Arrays|arrays]].
{{PageSyntax}}
::''To declare variables:''
:::[[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]]
::''To declare arrays:''
:::[[DIM]] [{{KW|SHARED}}] ''array([lowest% {{KW|TO}}] highest%])''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
::'' '''QB64''' Alternative Syntax:''
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''variable'' [, ''variable2''...]
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''array([lowest% {{KW|TO}}] highest%])'' [, ''array2(elements)''...]
{{PageDescription}}
* Sets the [[INTEGER]] range of elements (indices) of a [[STATIC]] array. If only one number is used, the [[LBOUND|lowest boundary]] is 0 by default.
* When used before an array is dimensioned, '''[[OPTION BASE]] 1''' can set the default [[LBOUND|lower boundary]] of arrays to 1.
* DIM [[SHARED]] shares variable values with sub-procedures without passing the value in a parameter.
* Use the [[AS]] keyword to define a variable or array ''type'' [[AS]]...
** [[INTEGER]] (or use variable suffix '''%''')
** [[LONG]] (or use variable suffix '''&''')
** [[SINGLE]] (or use variable suffix '''!''' or no suffix by default)
** [[DOUBLE]] (or use variable suffix '''#''')
** [[STRING]] (or use variable suffix '''$'''). An AS multiplier can set the string [[LEN|length]]. Ex: {{InlineCode}}DIM ''variable'' AS STRING * 8{{InlineCodeEnd}}
* '''QB64''' variable types:
** [[_BIT]] (or use variable suffix '''`'''). An AS multiplier can be used for multiple bits. Ex: {{InlineCode}}DIM ''variable'' AS _BIT * 8{{InlineCodeEnd}}
** [[_BYTE]] (or use variable suffix '''%%''')
** [[_INTEGER64]] (or use variable suffix '''&&''')
** [[_FLOAT]] (or use variable suffix '''##''')
** [[_OFFSET]] (or use variable suffix '''%&''')
** DIM AS [[_MEM]] (the _MEM type has no type suffix).
* '''Note: When a variable has not been defined or has no type suffix, the type defaults to [[SINGLE]].'''
* When using the '''AS type variable-list''' syntax, type symbols cannot be used.
* When the [[$DYNAMIC]] metacommand or [[REDIM]] is used, array element sizes are changeable (not [[$STATIC]]).
* Use [[REDIM]] instead of DIM to dimension arrays as dynamic without the {{KW|$DYNAMIC}} metacommand.
* Use [[REDIM]] [[_PRESERVE]] in '''QB64''' to retain previous array values when changing the size of an array.
* [[REDIM]] [[_PRESERVE]] cannot change the number of array dimensions. An [[ERROR Codes|error]] will occur.
* [[$DYNAMIC|Dynamic]] arrays MUST be [[REDIM]]ensioned if [[ERASE]] or [[CLEAR]] are used, as the arrays are completely removed.
* All numerical variable types '''except''' {{KW|SINGLE}}, {{KW|DOUBLE}} and {{KW|_FLOAT}} can be dimensioned as [[_UNSIGNED]] (suffix ~) or positive only.
* '''NOTE:''' Many QBasic keyword variable names can be used with a [[STRING]] suffix ($). You cannot use them without the suffix, use a numerical suffix or use ''DIM, [[REDIM]], [[_DEFINE]], [[BYVAL]] or [[TYPE]] variable [[AS]]'' statements. '''Although possible, it's recommended to avoid using reserved names.'''
* '''Warning: Do not use negative array upper bound index values, or OS access or "Out of Memory" [[ERROR Codes|errors]] will occur.'''
{{PageExamples}}
''Example 1:'' Defines Qt variable as a one byte fixed length string.
{{CodeStart}}
{{Cl|DIM}} Qt {{Cl|AS}} {{Cl|STRING}} * 1
{{CodeEnd}}
''Example 2:'' Dimensions and types an array.
{{CodeStart}}
{{Cl|DIM}} Image(2000) {{Cl|AS}} {{Cl|INTEGER}}
{{CodeEnd}}
''Example 3:'' Dimensions array with an [[INTEGER]] type suffix.
{{CodeStart}}
{{Cl|DIM}} Image%(2000)
{{CodeEnd}}
''Example 4:'' Dimensions a range of [[Arrays|array]] elements as [[SHARED]] integers.
{{CodeStart}}
{{Cl|DIM}} {{Cl|SHARED}} Image(1 {{Cl|TO}} 1000) {{Cl|AS}} {{Cl|INTEGER}}
{{CodeEnd}}
''Example 5:'' Dimensions variable as an [[Arrays|array]] of 8 elements of the type [[UNSIGNED]] BIT.
{{CodeStart}}
{{Cl|DIM}} bit(8) {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|_BIT}}
{{CodeEnd}}
''Example 6:'' QB64 is more flexible than QBasic when it comes to "Duplicate Definition" errors. The following code does not error:
{{CodeStart}}
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
{{Cl|DIM}} x {{Cl|AS}} {{Cl|LONG}}
{{Cl|PRINT}} x
{{CodeEnd}}
: ''Explanation:'' The [[SINGLE]] variable can be differentiated from the [[LONG]] x variable by using suffixes like x! or x& in later code.
''Example 7:'' The following code will create a "Name already in use" '''status error''' in QB64 when the variable types are the same.
{{CodeStart}}
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
{{Cl|DIM}} x {{Cl|AS}} {{Cl|SINGLE}}
{{Cl|PRINT}} x
{{CodeEnd}}
: ''Explanation:'' QB64 gives an error because the creation of the new variable would make referring to the existing one impossible.
''Example 8:'' Using QB64's alternative syntax to declare multiple variables/arrays of the same type.
{{CodeStart}}
{{Cl|DIM}} {{Cl|AS}} {{Cl|LONG}} w, h, id, weight, index 'all of these variables are created as type LONG
{{Cl|DIM}} {{Cl|AS}} {{Cl|SINGLE}} x, y, z 'all of these variables are created as type SINGLE
{{CodeEnd}}
{{PageSeeAlso}}
* [[_DEFINE]], [[_PRESERVE]]
* [[REDIM]], [[TYPE]]
* [[ERASE]], [[CLEAR]]
* [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]], [[DEFSTR]]
* [[Mathematical Operations]], [[Arrays]]
* [[Variable Types]]
* [[OPTION _EXPLICIT]]
{{PageNavigation}}

View file

@ -1,152 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:41:59}}
'''DO...LOOP''' statements are used in programs to repeat code or return to the start of a procedure.
{{PageSyntax}}
''Syntax 1:''
:'''[[DO]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
:: ''{code}''
:: ⋮
:'''[[LOOP]]'''
''Syntax 2:''
:'''[[DO]]'''
:: ''{code}''
:: ⋮
:'''[[LOOP]]''' [{{{KW|WHILE}}|{{KW|UNTIL}}} condition]
{{PageDescription}}
* '''DO UNTIL or DO WHILE used with LOOP''': The condition is evaluated before running the loop code.
::[[UNTIL]] checks if the condition is false each time before running code.
::[[WHILE]] checks if the condition is true each time before running code.
* '''DO used with LOOP UNTIL or LOOP WHILE''': The code block will run at least once:
::[[UNTIL]] checks if the condition is false before running loop code again.
::[[WHILE]] checks if the condition is true before running loop code again.
* NOTE: You cannot use a condition after both the DO and LOOP statements at the same time.
* Use '''[[EXIT]] DO''' to exit a loop block even before the condition is met.
** If you don't specify a condition, you must exit the loop block manually using '''[[EXIT]] DO'''.
* If a loop never meets an exit condition requirement, it will never stop.
{{RelationalTable}}
{{PageExamples}}
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}
DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code
DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of loop code
{{CodeEnd}}
''Example 2:'' Using UNTIL to clear the keyboard buffer.
{{CodeStart}}
DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code
DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
{{CodeEnd}}
''Example 3:'' Using a one time DO loop to exit ANY of several FOR LOOPs, without using [[GOTO]].
:SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image.
{{CodeStart}}
{{Cl|DEFINT}} A-Z
{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$
CheckScreen filenm$
{{Cl|END}}
{{Cl|DEFINT}} A-Z
{{Cl|SUB}} CheckScreen (Filename$) 'find Screen mode (12 or 13) and image dimensions
DIM Bsv AS {{Cl|STRING}} * 1
DIM Header AS STRING * 6
Scr = 0: MaxColors = 0
{{Cl|OPEN}} Filename$ FOR {{Cl|BINARY}} AS #1
{{Cl|GET}} #1, , Bsv '1 check for small 2 character
GET #1, , Header '2 - 7 rest of file header
IF Bsv <> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file
COLOR 12: LOCATE 15, 33: PRINT "Not a BSAVE file!": SLEEP 3: {{Cl|EXIT}} SUB
END IF
GET #1, , widN '8 no color info bmp sizes
GET #1, , depN '9 " " "
DO
IF widN > 63 OR depN > 63 THEN {{Cl|EXIT DO}} ' width and depth already found
FOR i = 10 TO 55 'check for Screen 12 embedded colors
GET #1, , RGB
tot12& = tot12& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test sound slows loop in QB
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 55 AND tot12& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid12 '56
GET #1, , dep12 '57
IF wid12 > 63 OR dep12 > 63 THEN {{Cl|EXIT DO}}
FOR i = 58 TO 775 'check for Screen 13 embedded colors
GET #1, , RGB
tot13& = tot13& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 775 AND tot13& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid13 '776
GET #1, , dep13 '777
LOOP {{Cl|UNTIL}} 1 = 1 'TRUE statement exits one-time LOOP
CLOSE #1
COLOR 14: LOCATE 10, 25
{{Cl|SELECT CASE}} i
{{Cl|CASE IS}} < 56:
IF widN > 640 THEN
Scr = 13: MaxColors = 0
PRINT "Default Screen 13:"; widN \ 8; "X"; depN
ELSE
LOCATE 10, 15
PRINT "Screen 12 ("; widN; "X"; depN; ") OR 13 ("; widN \ 8; "X"; depN; ")"
DO: SOUND 600, 4
COLOR 13: LOCATE 12, 23 'ask if no data found. Prevents ERROR opening in wrong mode
{{Cl|INPUT}} "Enter a Screen mode 12 or 13 : ", Scrn$
Scr = VAL(Scrn$)
LOOP UNTIL Scr = 12 OR Scr = 13
END IF
IF Scr = 12 THEN MaxColors = 0: PWidth = widN: PDepth = depN
IF Scr = 13 THEN MaxColors = 0: PWidth = widN \ 8: PDepth = depN
{{Cl|CASE}} 56 TO 775
PRINT "Custom Screen 12:"; wid12; "X"; dep12
Scr = 12: MaxColors = 16: PWidth = wid12: PDepth = dep12
{{Cl|CASE}} 776: PRINT "Custom Screen 13:"; wid13 \ 8; "X"; dep13
Scr = 13: MaxColors = 256: PWidth = wid13 \ 8: PDepth = dep13
{{Cl|END SELECT}}
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The SUB procedure reads a file that was [[BSAVE]]d previously. If the RGB colors are stored before the image, the values can only be between 0 and 63. Higher values indicate that the image width and height are located there and that there are no stored color values to be read. SUB later displays the dimensions of the file image that [[GET (graphics statement)|GET]] placed in the file array. The loop is set to only run once by creating '''a TRUE [[UNTIL]] statement''' such as 1 = 1. When a screen mode cannot be determined, the user must select one.
:Dimensions and location of width and height information indicates the screen mode as [[SCREEN (statement)|SCREEN]] 13 if it has 768 RGB values and dimensions of 320 X 200 max. If the file only holds 64 settings and/or is larger than 320 X 200, it uses SCREEN 12 or 9. The procedure [[EXIT]]s the DO LOOP early when the image size is found with or without custom color settings.
: Divide SCREEN 13 [[GET (graphics statement)|GET]] widths by 8.
{{PageSeeAlso}}
* [[EXIT DO]]
* [[WHILE...WEND]]
* [[FOR...NEXT]]
{{PageNavigation}}

View file

@ -1,33 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:00}}
[[DOUBLE]] type floating point numerical values use 8 bytes per value.
{{PageSyntax}}
: [[DIM]] {{Parameter|variable}} [[AS]] [[DOUBLE]]
{{PageDescription}}
* Literal or variable values can range up to 15 decimal point places.
* The variable suffix type is '''#'''.
* Use DOUBLE and [[_FLOAT]] variables sparingly as they use a lot of program memory.
* Values returned may be expressed using exponential or [[scientific notation]] using '''E''' for SINGLE or '''D''' for DOUBLE precision.
* Floating decimal point numerical values cannot be [[_UNSIGNED]].
* Values can be converted to 8 byte [[ASCII]] string values using [[_MKD$]] and back with [[_CVD]].
* '''When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
==QBasic/QuickBASIC==
* Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5.
{{PageSeeAlso}}
* [[DIM]], [[DEFDBL]]
* [[MKD$]], [[CVD]]
* [[SINGLE]], [[_FLOAT]]
* [[LEN]]
* [[Variable Types]]
{{PageNavigation}}

View file

@ -1,170 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:01}}
The [[DRAW]] statement uses a [[STRING]] expression to draw lines on the screen.
{{PageSyntax}}
: [[DRAW]] {{Parameter|drawString$}}
{{PageDescription}}
* The {{Parameter|drawString$}} can be [[DRAW]] instructions in quotation marks or a [[STRING]] variable using [[DRAW]] instructions.
* [[DRAW]] starting coordinates can be set using [[PSET]], [[PRESET]], [[CIRCLE]] or [[LINE]] ending positions.
* Other graphic objects can be located at or relative to the last DRAW position using [[STEP]].
* [[DRAW]] can inherit colors from other graphic statements such as [[PSET]], [[LINE]] and [[CIRCLE]].
* Draw strings use letters followed by the number of pixels to move, an angle, coordinate or a color value.
* Draw strings are flexible with spacing. '''Spacing is not required.''' [[DRAW]] will look for a number value after a valid letter.
* DRAW statements are not case sensitive.
** "'''B'''" (blind) before a line move designates that the line move will be hidden. Use to offset from a "P" or [[PAINT]] border.
** "'''C''' n" designates the color attribute or [[_RGB]] [[STR$|string]] numerical color value to be used in the draw statement immediately after.
** "'''M''' x, y" can move to another coordinate area of the screen. When a + or - sign is used before a coordinate, it is a relative coordinate move similar to using the [[STEP]] graphics keyword. DRAW "M+=" + [[VARPTR$]](variable%)
** "'''N'''" before a line move designates that the graphic cursor will return to the starting position after the line is drawn.
** "'''P''' f [, b]" is used to [[PAINT|paint]] enclosed objects. f denotes the fill color and b the border color, if needed.
** "'''S''' n" changes the pixel move size of the lines. Default is 4 (1 pixel) minimum. "S8" would double the pixel line moves.
** "'''X'''" + [[VARPTR$]](value) can draw another substring.
* Certain letter designations create line moves on the SCREEN. Each move is followed by the number of pixels:
** "'''D''' n" draws a line vertically DOWN n pixels.
** "'''E''' n" draws a diagonal / line going UP and RIGHT n pixels each direction.
** "'''F''' n" draws a diagonal \ line going DOWN and RIGHT n pixels each direction.
** "'''G''' n" draws a diagonal / LINE going DOWN and LEFT n pixels each direction.
** "'''H''' n" draws a diagonal \ LINE going UP and LEFT n pixels each direction.
** "'''L''' n" draws a line horizontally LEFT n pixels.
** "'''R''' n" draws a line horizontally RIGHT n pixels.
** "'''U''' n" draws a line vertically UP n pixels.
* Angles are used to rotate all subsequent draw moves.
** "'''A''' n" can use values of 1 to 3 to rotate up to 3 90 degree(270) angles.
** '''TA''' n" can use any n angle from -360 to 0 to 360 to rotate a DRAW (Turn Angle). "TA0" resets to normal.
** When [[VARPTR$]] is used, DRAW functions such as '''TA''' angles use an equal sign: "TA=" + VARPTR$(angle%)
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
* '''DRAW can be used in any graphic screen mode, but cannot be used in the default screen mode 0 as it is text only.'''
{{PageExamples}}
''Example 1:'' Placing an octagon shape DRAW across the the screen using PSET.
{{CodeStart}}
SCREEN 12
octagon$ = "C12 R10 F10 D10 G10 L10 H10 U10 E10" 'create a DRAW string value
{{Cl|SCREEN (statement)|SCREEN}} 12
FOR i% = 1 TO 11
{{Cl|PSET}} (i% * 50, 100), 15
{{Cl|_DELAY}} .5 ' delay for demo
{{Cl|DRAW}} octagon$ ' DRAW the octagon using variable
{{Cl|_DELAY}} .5 ' delay for demo
NEXT i%
{{CodeEnd}}
''Explanation:'' Once a DRAW string variable is created, it can be used to draw a shape throughout the program at any time.
''Example 2:'' Creating an analog clock's hour markers using "TA=" + [[VARPTR$]](angle).
{{CodeStart}}
SCREEN 12
FOR angle = 0 TO 360 {{Cl|STEP}} 30 ' 360/12 hour circles = 30 degrees apart
PSET (175, 250), 6 ' stay at center point of clock
{{Cl|DRAW}} "TA=" + {{Cl|VARPTR$}}(angle) + "BU100" ' move invisibly to set next circle's center point
{{Cl|CIRCLE}} {{Cl|STEP}}(0, 0), 5, 12 ' circle placed at end of blind line
{{Cl|DRAW}} "P9, 12" ' paint inside of circle
{{Cl|SLEEP}} 1 ' slowed for demo only
NEXT
{{CodeEnd}}
''Explanation:'' To place 12 circles in a circle each move is 30 degrees. PSET sets the center of the circular path every loop. TA moves counter-clockwise with positive degree angles. Once TA sets the angle a blind Up move is at that angle. The hour circles use the end point of the blind line as centers using the STEP relative coordinates of 0. After the circles are drawn, a draw "P" string paints the circle centers. DRAW paint strings use the last coordinate position also.
''Example 3:'' Creating a moving second hand for the clock above (SCREEN 12). (See [[TIME$]] example 1)
{{CodeStart}}
DO: sec$ = {{Cl|RIGHT$}}({{Cl|TIME$}}, 2) ' get actual seconds from TIME$ function
degree$ = {{Cl|STR$}}({{Cl|VAL}}(sec$) * -6) ' 60 second moves. TA uses negative angles for clockwise moves
{{Cl|PSET}} (175, 250), 9 ' stay at clock center
DRAW "TA" + degree$ + "U90" ' up becomes TA directional line
DO: LOOP UNTIL RIGHT$(TIME$, 2) <> sec$ ' wait for a new second value
IF INKEY$ <> "" THEN {{Cl|EXIT DO}} ' any key exit
PSET (175, 250), 0 ' set at clock center to erase line
DRAW "TA" + degree$ + "U90" ' erases old second hand line using color 0 from PSET
LOOP
{{CodeEnd}}
''Explanation:'' The degrees to move from the original UP line move is calculated by dividing 360/60 seconds in a full rotation. That value of 6 is made negative to use TA correctly and multiplied by the [[VAL]]ue of seconds from the TIME$ function. The degree angle is converted by [[STR$]] to a string and added to the DRAW string using the [[STRING]] '''concatenation +''' operator. Do not use semicolons to create DRAW strings. Once the second hand is placed on the screen, a loop waits for the second value to change. It then erases the hand and it repeats the process again.
''Example 4:'' Creating digital displays using DRAW format strings to create the LED segments. (See [[SELECT CASE|SELECT EVERYCASE]] example 5)
{{CodeStart}}
{{Cl|SCREEN}} 12
DO
{{Cl|LOCATE}} 1, 1: {{Cl|INPUT}} "Enter a number 0 to 9: ", num
{{Cl|CLS}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 3, 5 {{Cl|TO}} 9: {{Cl|PSET}} (20, 20), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'top horiz
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 4 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 20), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'left top vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 6, 8: {{Cl|PSET}} (20, 54), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12, 12" 'left bot vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 2 {{Cl|TO}} 6, 8, 9: {{Cl|PSET}} (20, 54), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12, 12" 'middle horiz
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0 {{Cl|TO}} 4, 7 {{Cl|TO}} 9: {{Cl|PSET}} (54, 20), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'top right vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 1, 3 {{Cl|TO}} 9: {{Cl|PSET}} (54, 54), 12
{{Cl|DRAW}} "F2D30G2H2U30E2BD5P12,12" 'bottom right vert
{{Cl|END SELECT}}
{{Cl|SELECT CASE}} num
{{Cl|CASE}} 0, 2, 3, 5, 6, 8: {{Cl|PSET}} (20, 88), 12
{{Cl|DRAW}} "E2R30F2G2L30H2BR5P12,12" 'bottom horiz
{{Cl|END SELECT}}
{{Cl|LOOP}} {{Cl|UNTIL}} num > 9
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The DRAW strings can be used more than once with different [[PSET]] positions to create more digits.
''Example 5:'' Using 32 bit or [[_RGB]] color [[STR$|string]] values when using the DRAW C text statement
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 12)
{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10)
{{Cl|SLEEP}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 800, 32) 'comment out this line to use the non-32 bit screen mode 12
{{Cl|PRINT}} {{Cl|_ALPHA}}(10), {{Cl|_RED}}(10), {{Cl|_GREEN}}(10), {{Cl|_BLUE}}(10)
{{Cl|PSET}} (400, 400), 0 ' move to 320, 240... draw will start where pset leaves off
c = 14
{{Cl|DIM}} k {{Cl|AS}} {{Cl|_UNSIGNED}} {{Cl|LONG}}
k = {{Cl|_RGB}}(80, 255, 80)
{{Cl|FOR...NEXT|FOR}} repeat = 1 {{Cl|TO}} 16
{{Cl|FOR...NEXT|FOR}} p = 0 {{Cl|TO}} 359
c = c + 1: d = c / 14
{{Cl|DRAW}} "c" + {{Cl|STR$}}(k) + " ta" + {{Cl|STR$}}(p) + " bu " + {{Cl|STR$}}(d) + "l7 u7 r7 d7 bd " + {{Cl|STR$}}(d)
{{Cl|NEXT}} p
{{Cl|NEXT}} repeat
{{CodeEnd}}
: ''Explanation:'' DRAW strings will ignore spaces between letters and numbers so string trimming is not necessary.
{{PageSeeAlso}}
* [[LINE]], [[PSET]], [[PRESET]], [[CIRCLE]]
* [[PAINT]], [[SCREEN (statement)|SCREEN]]
* [[COLOR]], [[PLAY]]
* [[TIME$]]
{{PageNavigation}}

View file

@ -1,22 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:53:58}}
The '''$''' is used to denote QBasic [[Metacommand]]s or as a [[STRING]] variable type suffix.
''Usage:'' $INCLUDE: 'QB.bi'
* [[$STATIC]] denotes that all arrays can only be dimensioned once using [[DIM]].
* [[$DYNAMIC]] denotes that all arrays can be redimensioned using [[REDIM]] ONLY.
* [[$INCLUDE]] includes a BI file or QBasic Library in a program. The file name requires a comment before and after the name.
* The [[STRING|string]] variable suffix MUST be used if the variable is not dimensioned in a DIM statement. The statement can also set a fixed string [[LEN|length]].
''See also:
* [[DIM]], [[REDIM]]
* [[Metacommand]]
{{PageNavigation}}

View file

@ -1,57 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:05}}
[[ELSEIF]] is used in an [[IF...THEN]] block statement to offer an alternative condition.
{{PageSyntax}}
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
{{PageDescription}}
* ELSEIF statements require a '''separate''' code block line with [[THEN]] for each alternative condition.
* There can be more than one [[ELSE]] IF statement in a single-line IF statement.
* If there is only one possible alternative condition (such as 0 or [[NOT]] 0), use [[ELSE]] instead.
* If the comparisons are based on multiple conditions being true, it may require many ELSEIF comparisons. ELSE could help cover some of those conditions.
* You can use [[SELECT CASE]] when IF blocks have a long list of alterative ELSEIF conditions.
{{RelationalTable}}
{{PageExamples}}
''Example 1:'' IF statement using ELSE IF in one statement line.
{{CodeStart}}
IF x = 100 THEN COLOR 10: PRINT x ELSE IF x > 100 THEN COLOR 12: PRINT x ELSE PRINT "< 100"
{{CodeEnd}}
''Example 2:'' IF statement block
{{CodeStart}}
IF x = 100 THEN ' must place ANY code on next line!
COLOR 10: PRINT x
ELSEIF x > 100 THEN COLOR 12: PRINT x
ELSE : PRINT "< 100"
END IF
{{CodeEnd}}
{{PageSeeAlso}}
*[[ELSE]], [[END IF]]
*[[IF...THEN]]
{{PageNavigation}}

View file

@ -1,64 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:03}}
[[ELSE]] is used in [[IF...THEN]] or [[SELECT CASE]] statements to offer an alternative to other conditional statements.
{{PageSyntax}}
''Single-line syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]] ''{code}'' [[ELSE]] ''{alternative-code}''
''Block syntax:''
: [[IF]] {{Parameter|condition}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSEIF]] {{Parameter|condition2}} [[THEN]]
:: ''{code}''
:: ⋮
: [[ELSE]]
:: ''{alternative-code}''
:: ⋮
: [[END IF]]
{{PageDescription}}
* ELSE is used in a IF block statement to cover any remaining conditions not covered in the main block by IF or [[ELSEIF]].
* [[CASE ELSE]] covers any remaining conditions not covered by the other CASE statements.
* ELSE can also be used as a false comparison to a true IF statement when a condition will only be true or false.
* Other [[IF...THEN]] statements can be inside of an ELSE statement.
{{PageExamples}}
''Example 1:'' One line IF statement
{{CodeStart}}
IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"
{{CodeEnd}}
''Example 2:'' Multiple line IF statement block
{{CodeStart}}
IF x = 100 THEN ' code executed MUST be on next statement line!
PRINT "100"
ELSE PRINT "Not 100"
END IF
{{CodeEnd}}
''Example 3:'' To alternate between any two values (as long as the value after ELSE is the same as the condition)
{{CodeStart}}
IF a = 3 THEN a = 5 ELSE a = 3
{{CodeEnd}}
{{PageSeeAlso}}
* [[ELSEIF]]
* [[IF...THEN]]
{{PageNavigation}}

View file

@ -1,54 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:06}}
The [[END]] statement terminates a program without an immediate exit or ends a procedure or statement block.
{{PageSyntax}}
: [[END]] [{{Parameter|returnCode%}}]
: [[END]] [[IF...THEN|IF]]
: [[END]] [[TYPE]]
: [[END]] [[SELECT CASE|SELECT]]
: [[END]] [[SUB]]
: [[END]] [[FUNCTION]]
: END [[DECLARE LIBRARY|DECLARE]]
{{PageDescription}}
* In '''QB64''', [[END]] can be followed by a code that can be read by another module using the [[SHELL (function)|_SHELL]] or [[_SHELLHIDE]] function (known as [https://blogs.msdn.microsoft.com/oldnewthing/20080926-00/?p=20743 '''errorlevel'''])
* When END is used to end a program, there is a pause and the message "Press any key to continue..." is displayed at the bottom of the program's window.
* If the program does not use END or [[SYSTEM]], the program will still end with a pause and display "Press any key to continue...".
* In '''QB64''', [[SYSTEM]] will end the program immediately and close the window.
* The '''QB64''' [[_EXIT (function)]] can block a user's Ctrl + Break key presses and clicks on the window's close button (X button) until the program is ready to close.
{{PageExamples}}
''Example:'' In QB64 you won't return to the IDE unless you are using it to run or edit the program module.
{{CodeStart}}
{{Cl|PRINT}} "Hello world!"
{{Cl|END}}
{{Cl|PRINT}} "Hello no one!"
{{CodeEnd}}
''Returns:''
{{OutputStart}}
Hello world!
Press any key to continue...
{{OutputEnd}}
:''Explanation:''"Hello no one!" isn't returned because the program ended with the END statement no matter what is after that.
:The message "Press any key to continue..." is displayed after the program ends, both in QBasic and in '''QB64'''.
{{PageSeeAlso}}
* [[SYSTEM]] {{text|(immediate exit)}}
* [[SHELL (function)]], [[_SHELLHIDE]]
* [[EXIT]] (statement), [[_EXIT (function)]]
{{PageNavigation}}

View file

@ -1,129 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:09}}
The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windows'''' environmental settings list.
{{PageSyntax}}
: {{Parameter|setting$}} = [[ENVIRON$]]({{{Parameter|listIndex%}}|{{Parameter|systemID$}}})
{{PageDescription}}
* The function can use an [[INTEGER]] {{Parameter|listIndex%}} value or [[STRING]] {{Parameter|systemID$}} parameter.
* {{Parameter|listIndex%}} refers to the number order of the environmental list. Returns are not in any particular numerical order.
* {{Parameter|systemID$}} is the specific [[STRING]] parameter requested. Returns only the specified environmental [[STRING]] setting:
** "BLASTER" = current Sound Blaster settings if installed.
** "COMPUTERNAME" or "USERDOMAIN" = OEM PC serial number or the computer name assigned by owner.
** "HOMEDRIVE" or "SystemDrive" = Windows root drive, normally C: on single partition drives.
** "HOMEPATH" = current user's Administrator or the single user's "OWNER" folder path.
** "OS" = Windows Operating System version. Often WindowsNT in modern computers.
** "PATH" = full path setting that Windows uses to look for file extensions in PATHEXT below.
** "PATHEXT = Windows extensions used: COM, EXE, BAT, CMD, VBS, VBE, JS, JSE, WSF, WSH, MSC
** "PROCESSOR_ARCHITECTURE" = x86 for 32 or 64 bit.
** "PROGRAMFILES" = path to ''Program files'' folder, normally "C:\PROGRAM FILES"
** "PROMPT" = normally "$P$G" on Windows NT.
** "SYSTEMROOT" or "windir" = path to the Windows folder including the drive letter like "C:\WINDOWS"
** "TEMP" or "TMP" = path to TEMP folder. "C:\TEMP" or the user specific temp folder on later versions.
** "USERNAME" = current Administrator name or "OWNER".
: ''Note:'' There are other possible system settings that are not listed or never used on older versions. Run ''Example 1'' below for a complete list in your system.
<!-- Sentence removed for being unclear/needs revision: * The OS in Win 9X or ME can be found in the "PROMPT" parameter ID. Returns are limited in Win 9X and ME. -->
* ''Note:'' '''QB64''' may not return the same environment list as QBasic or SET did in DOS.
{{PageExamples}}
''Example 1:'' Viewing the list of environmental parameter settings using a counter loop like SET does in DOS.
{{CodeStart}}
{{Cl|DO}}
i = i + 1
setting$ = {{Cl|ENVIRON$}}(i) ' get a setting from the list
{{Cl|PRINT}} setting$
{{Cl|IF...THEN|IF}} i {{Cl|MOD}} 20 = 0 {{Cl|THEN}} {{Cl|PRINT}} "Press a key": {{Cl|SLEEP}}: {{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} setting$ = ""
{{CodeEnd}}
{{OutputStart}}
ALLUSERSPROFILE=C:\ProgramData
COMPUTERNAME=TED-LAPTOP
ComSpec=C:\WINDOWS\system32\cmd.exe
HOMEDRIVE=C:
HOMEPATH=\Users\Ted
LOCALAPPDATA=C:\Users\Ted\AppData\Local
OS=Windows_NT
Path=C:\PROGRAMDATA\ORACLE\JAVA\JAVAPATH;C:\WINDOWS\SYSTEM32;C:\WINDOWS;
C:\WINDOWS\SYSTEM32\WBEM;C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\;C:\
WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32
\WindowsPowerShell\v1.0\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 14 Stepping 8, GenuineIntel
ProgramFiles=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
SystemRoot=C:\WINDOWS
TEMP=C:\Users\TED\AppData\Local\Temp
TMP=C:\Users\TED\AppData\Local\Temp
USERDOMAIN=TED-LAPTOP
USERNAME=Ted
USERPROFILE=C:\Users\Ted
{{OutputEnd}}
:''Note:'' Windows environmental settings are listed alphabetically, 20 at a time. '''QB64 may not read all of them or may return an empty string.''' The settings above were returned with SET in DOS. PROMPT returned nothing where SET returned $P$G.
''Example 2:'' Creating a shortcut on a user's desktop for QB64.EXE using the program's icon. Must be run in program's folder to work!
{{CodeStart}}
'=== Enter the EXE file and ICON or BMP image for the shortcut.
Program$ = "QB64.EXE" '<<<<<<<<<< Enter the '''exact''' program name for shortcut
ICON$ = "QB64ICON.BMP" '<<<<<<<<<< Enter icon or bitmap to use from program's folder
DeskTopShortcut Program$, ICON$
{{Cl|END}} '====== END DEMO CODE ======
{{Cl|SUB}} DeskTopShortcut (Program$, ICON$)
f = {{Cl|FREEFILE}}
{{Cl|SHELL}} {{Cl|_HIDE}} "CD > PRGMDIR.INF" 'get the current program path
{{Cl|OPEN}} "PRGMDIR.INF" {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #f
{{Cl|LINE INPUT (file statement)|LINE INPUT}} #f, PATH$
{{Cl|CLOSE}} #f
{{Cl|KILL}} "PRGMDIR.INF"
PATH$ = PATH$ + "\": FILE$ = PATH + Program$
PRINT PATH$ 'DEMO print
A$ = {{Cl|ENVIRON$}}("HOMEDRIVE") '=== Get Current User setting from Environment.
B$ = {{Cl|ENVIRON$}}("HOMEPATH")
C$ = A$ + B$ 'shortcut to user's desktop if found
{{Cl|IF...THEN|IF}} C$ = "" {{Cl|THEN}} C$ = {{Cl|ENVIRON$}}("ALLUSERSPROFILE") 'try desktop for all users
PRINT C$ 'DEMO print
URLFILE$ = {{Cl|MID$}}(Program$, 1, {{Cl|INSTR}}(Program$, ".")) + "URL" 'change EXE to URL
{{Cl|IF...THEN|IF}} C$ > "" {{Cl|THEN}}
SHORTCUT$ = C$ + "\Desktop\" + URLFILE$ 'create filename for the desktop
{{Cl|ELSE}} SHORTCUT$ = PATH$ + URLFILE$ 'if all else fails put in program folder
{{Cl|END IF}}
PRINT SHORTCUT 'DEMO print
{{Cl|OPEN}} SHORTCUT$ {{Cl|FOR (file statement)|FOR}} {{Cl|APPEND}} {{Cl|AS}} #f
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(f) {{Cl|THEN}} {{Cl|CLOSE}} #f: {{Cl|EXIT SUB}} '=== if filesize is NOT Zero don't overwrite!
Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
{{Cl|PRINT (file statement)|PRINT}} #f, "[InternetShortcut]" 'URL type
{{Cl|PRINT (file statement)|PRINT}} #f, "URL=" + Q$ + "file://" + FILE$ + Q$ 'URL program file
{{Cl|PRINT (file statement)|PRINT}} #f, "WorkingDirectory=" + Q$ + PATH$ + Q$ 'Working path
{{Cl|PRINT (file statement)|PRINT}} #f, "IconIndex = " + Q$ + "0" + Q$ '0 is first index
{{Cl|PRINT (file statement)|PRINT}} #f, "IconFile = " + Q$ + PATH$ + ICON$ + Q$ 'Icon path in working folder
{{Cl|CLOSE}} #f
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Adapted from code by Dav}}
: ''Explanation:'' The SUB program finds the current program's path and user's desktop path. It then creates the shortcut on the desktop with a program icon. The custom icon should be in the program's folder. If an environmental path is not found, the shortcut is placed in the program's folder. The SUB can be added to any program.
:{{Text|'''NOTE:''' A temorary file named PRGMDIR.INF is created and deleted in the example above.}}
''See also:''
* [[ENVIRON]] (statement)
* [[_DEVICES]], [[_DEVICE$]]
* [[_LASTBUTTON]], [[_OS$]]
* [[Windows Environment]]
* [[Windows Libraries#Windows User|Windows User Paths Library]]
{{PageNavigation}}

View file

@ -1,24 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:08}}
The [[ENVIRON]] statement is used to temporarily set or change an environmental string value.
{{PageSyntax}}
: [[ENVIRON]] {{Parameter|stringExpression$}}
{{PageDescription}}
* The {{Parameter|stringExpression$}} must include the environmental parameter ID and the setting:
** Using an '''=''' sign: [[ENVIRON]] "parameterID=setting"
** Using a space: [[ENVIRON]] "parameterID setting"
* If the parameter ID did not previously exist in the environmental string table, it is appended to the end of the table.
* If a parameter ID did exist, it is deleted and the new value is appended to end of the list.
* Any changes made at runtime are discarded when your program ends.
{{PageSeeAlso}}
* [[ENVIRON$]]
* [[Windows Environment]]
{{PageNavigation}}

View file

@ -1,26 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:10}}
The [[EOF]] function indicates that the end of a file has been reached.
{{PageSyntax}}
: {{Parameter|endReached%%}} = EOF([#]{{Parameter|fileNumber&}})
{{PageDescription}}
* {{Parameter|fileNumber&}} is the number of the file being read. '''#''' is not required.
* Returns 0 until the end of a file. This avoids a file read error.
* Returns -1 (true) at the end of the file.
<!-- confusing statement; further details are required: * [[CHR$]](26) can be used to denote the end of a file. -->
* '''Note that [[GET]] can return invalid data at the end of a file.''' Read [[EOF]] after a GET operation to see if the end of the file has been reached and discard last read.
{{PageSeeAlso}}
* [[OPEN]]
* [[LOF]], [[LEN]]
* [[INPUT (file statement)]]
* [[LINE INPUT (file statement)]]
* [[GET]], [[PUT]]
{{PageNavigation}}

View file

@ -1,23 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:11}}
The [[EQV]] operator returns a value based on the ''equivalence'' of two conditions or values.
{{PageSyntax}}
: {{Parameter|result}} = {{Parameter|firstValue}} [[EQV]] {{Parameter|secondValue}}
{{PageDescription}}
* Returns true (-1) when both values are the same (''equivalent'').
* Turns a bit on if both bits are the same, turns a bit off if both bits are different.
{{LogicalTruthTable}}
{{PageSeeAlso}}
* [[Binary]]
* [[Boolean]]
{{PageNavigation}}

View file

@ -1,26 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:13}}
The [[ERASE]] statement is used to clear all data from an array. [[$STATIC]] [[Arrays|array]] dimensions are not affected.
{{PageSyntax}}
: ERASE ''arrayName'' [, ''arrayName2''...]
{{PageDescription}}
* All string array elements become null strings ("") and all numerical array elements become 0.
* Multiple arrays can be erased using commas between the array names.
* [[$DYNAMIC|Dynamic]] arrays must be [[REDIM]]ensioned if they are referenced after erased.
* Dimension subprocedure arrays as [[STATIC]] to use [[ERASE]] and not have to REDIM.
* You do not have to include array brackets in an [[ERASE]] call.
{{PageSeeAlso}}
* [[DIM]], [[REDIM]]
* [[CLEAR]]
* [[STATIC]]
* [[$DYNAMIC]]
* [[Arrays]]
{{PageNavigation}}

View file

@ -1,45 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:14}}
The [[ERL]] function returns the closest previous line number before the last error.
{{PageSyntax}}
: ''lastErrorLine&'' = [[ERL]]
{{PageDescription}}
* Used in an error handler to report the last line number used before the error.
* If the program does not use line numbers, then ERL returns 0.
* Use [[_ERRORLINE]] to return the actual code line position of an error in a QB64 program.
{{PageExamples}}
''Example:'' Using a fake error code to return the line number position in a program.
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} errorfix
1
{{Cl|ERROR}} 250
{{Cl|ERROR}} 250
5 {{Cl|ERROR}} 250
{{Cl|END}}
errorfix:
{{Cl|PRINT}} {{Cl|ERL}}
{{Cl|RESUME}} {{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}1
1
5
{{OutputEnd}}
{{PageSeeAlso}}
* [[ERR]]
* [[ERROR]]
* [[ON ERROR]]
* [[_ERRORLINE]], [[_INCLERRORLINE]], [[_INCLERRORFILE$]]
* [[ERROR Codes]]
{{PageNavigation}}

View file

@ -1,43 +0,0 @@
{{QBDLDATE:07-31-2022}}
{{QBDLTIME:23:42:16}}
The [[ERROR]] statement is used to simulate a program error or to troubleshoot error handling procedures.
{{PageSyntax}}
: [[ERROR]] {{Parameter|codeNumber%}}
{{PageDescription}}
* Can be used to test an error handling routine by simulating an error.
* Error code 97 can be used to invoke the error handler for your own use, no real error in the program will trigger error 97.
* Use error codes between 100 and 200 for custom program errors that will not be responded to by QB64.
{{PageExamples}}
''Example:'' Creating custom error codes for a program that can be handled by an [[ON ERROR]] handling routine.
{{CodeStart}}
{{Cl|ON ERROR}} {{Cl|GOTO}} handler
{{Cl|IF...THEN|IF}} x = 0 {{Cl|THEN}} {{Cl|ERROR}} 123
x = x + 1
{{Cl|IF...THEN|IF}} x {{Cl|THEN}} {{Cl|ERROR}} 111
{{Cl|END}}
handler:
{{Cl|PRINT}} {{Cl|ERR}}, {{Cl|_ERRORLINE}}
{{Cl|BEEP}}
{{Cl|RESUME}} {{Cl|NEXT}}
{{CodeEnd}}
: '''Note: Don't use error codes under 97 or over 200 as QB64 may respond to those errors and interrupt the program.'''
{{PageSeeAlso}}
*[[ON ERROR]]
*[[ERR]], [[ERL]]
*[[_ERRORLINE]]
*[[ERROR Codes]] (list)
{{PageNavigation}}

Some files were not shown because too many files have changed in this diff Show more