1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 12:50:37 +00:00

Add temp folder to repo. It's necessary as well!

Just more initial setting on... nothing much to see here.
This commit is contained in:
SteveMcNeill 2022-04-22 09:46:06 -04:00 committed by Matthew Kilgore
parent 218c6124a5
commit 33adc04fc4
882 changed files with 5846 additions and 2748 deletions

4
.gitignore vendored
View file

@ -1,12 +1,12 @@
internal/c/c_compiler
internal/temp*
*.o
*.a
*.exe
*.bas
internal/config*.txt
internal/config.ini
internal/help
internal/version.txt
tempfoldersearch.bin
internal/c/mingw32

View file

@ -10,8 +10,8 @@ The [[$ASSERTS]] metacommand enables debug tests with the [[_ASSERT]] macro.
* If an error message is passed to the [[_ASSERT]] statement, it is displayed in the console window if [[$ASSERTS|$ASSERTS:CONSOLE]] is used.
{{PageAvailability}}
* Version 1.4 and up.
==Availability==
* '''Version 1.4 and up'''.
{{PageExamples}}
@ -43,3 +43,4 @@ The [[$ASSERTS]] metacommand enables debug tests with the [[_ASSERT]] macro.
{{PageNavigation}}
<

View file

@ -24,3 +24,4 @@ The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
{{PageNavigation}}
<

View file

@ -10,7 +10,7 @@
* [[$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.
* ''NOTE'': When using [[$NOPREFIX]], the color constants change to '''C_<old name>''' (ex: '''Blue''' becomes '''C_Blue''').
* Not compatible with [[$NOPREFIX]].
{{PageExamples}}
@ -18,7 +18,7 @@
{{CodeStart}}
{{Cl|$COLOR}}:0
{{Cl|COLOR}} BrightWhite, Red
{{Cl|PRINT}} "BrightWhite on red."
{{Cl|PRINT}} "Bright white on red."
{{CodeEnd}}
@ -31,20 +31,11 @@
{{CodeEnd}}
''Example 3:'' Using [[$COLOR]] with [[$NOPREFIX]]:
{{CodeStart}}
{{Cl|$NOPREFIX}}
{{Cl|$COLOR}}:0
{{Cl|COLOR}} C_BrightWhite, C_Red
{{Cl|PRINT}} "BrightWhite on Red."
{{CodeEnd}}
{{PageSeeAlso}}
* [[COLOR]], [[SCREEN]]
* [[_NEWIMAGE]], [[$INCLUDE]]
* [[$NOPREFIX]]
* [[Metacommand]]
{{PageNavigation}}
<

View file

@ -1,21 +1,19 @@
The [[$CONSOLE]] [[metacommand]] creates a console window that can be used throughout a QB64 program module.
The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throughout a QB64 program module.
{{PageSyntax}}
: [[$CONSOLE]][:ONLY]
{{Description}}
* [[_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]] and [[_SOURCE]] are automatically set to [[_CONSOLE]] when the ''':ONLY''' option is used, in order to send screen output to the console window and get input from it too.
** In normal [[$CONSOLE]] mode (dual screen) you have to manually set [[_DEST]] and [[_SOURCE]] to [[_CONSOLE]] in order to work with the console 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.
* [[_CONSOLETITLE]] can be used to change the title of the console window.
* '''QB64 [[Metacommand]]s are not commented out with ' or REM, differently from Qbasic 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''
* QB64 [[Metacommand]]s are not commented out with ' or REM, differently from QBasic metacommands.
:: To copy console text output, right click the title bar and select ''Edit'' for ''Mark'' to highlight and repeat to ''Copy''
{{PageExamples}}
@ -76,3 +74,4 @@ Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
{{PageNavigation}}
<

View file

@ -1,42 +1 @@
{{DISPLAYTITLE:$DEBUG}}
'''$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 (=, &lt;>, >=, &lt;=, >, &lt;) 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}}
<

View file

@ -1,12 +1,12 @@
The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (resizable) arrays.
The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (changeable) arrays.
{{PageSyntax}}
:{[[REM]] | [[apostrophe|']] } [[$DYNAMIC]]
:{[[REM]] | ' } [[$DYNAMIC]]
{{PageDescription}}
* QBasic [[Metacommand|metacommands]] require [[REM]] or [[Apostrophe|apostrophe]] (') before them and are normally placed at the start of the main module.
* QBasic [[Metacommand|metacommands]] require [[REM]] or [[Apostrophe|apostrophe]] (') before them and are always 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.
@ -44,3 +44,4 @@ The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (res
{{PageNavigation}}
<

View file

@ -1 +1,67 @@
#REDIRECT [[$IF]]
'''$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]]
* $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 for us. 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.
* [[$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.
{{PageSeeAlso}}
* [[$LET]]
* [[Metacommand]]s
{{PageNavigation}}
<

View file

@ -1 +1,67 @@
#REDIRECT [[$IF]]
'''$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]]
* $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 for us. 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.
* [[$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.
{{PageSeeAlso}}
* [[$LET]]
* [[Metacommand]]s
{{PageNavigation}}
<

View file

@ -1 +1,67 @@
#REDIRECT [[$IF]]
'''$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]]
* $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 for us. 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.
* [[$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.
{{PageSeeAlso}}
* [[$LET]]
* [[Metacommand]]s
{{PageNavigation}}
<

View file

@ -1,30 +1 @@
The [[$ERROR]] metacommand triggers a compilation error.
{{PageSyntax}}
: [[$ERROR]] MESSAGE
{{PageDescription}}
* The Metacommand does '''not''' require a comment or REM before it.
* MESSAGE is any text. Quotation marks are not required.
* When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and MESSAGE is shown to the user. This is useful in [[$IF]] blocks.
===Details===
* If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with [[$IF]].
* An [[$ERROR]] directive not inside an [[$IF]] (or [[$ELSEIF]]) block is useless because the program will never compile.
{{PageExamples}}
{{CodeStart}} '' ''
{{Cl|$IF}} VERSION &lt; 2.1 OR WINDOWS = 0 THEN
{{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above
{{Cl|$END IF}}
{{CodeEnd}}
''Output'': Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements).
{{PageSeeAlso}}
* [[Metacommand]]
* [[$IF]]
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@
: [[$EXEICON]]:'{{Parameter|iconfile.ico}}'
{{PageParameters}}
{{Parameters}}
* '{{Parameter|iconfile.ico}}' is a valid [https://en.wikipedia.org/wiki/ICO_(file_format) ICO file]
@ -19,7 +19,7 @@
{{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|$EXEICON}}:'myexe.ico'
{{Cl|_ICON}}
{{CodeEnd}}{{small|Code and command by Fellippe Heitor}}
@ -31,3 +31,4 @@
{{PageNavigation}}
<

View file

@ -14,16 +14,9 @@
* $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.
* 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 for us. 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.
* [[$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.
@ -65,20 +58,10 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''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 &lt; 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}}
<

View file

@ -2,7 +2,7 @@
{{PageSyntax}}
: {[[REM]] | [[apostrophe|']] } [[$INCLUDE]]: '{{Parameter|sourceFile}}'
: {[[REM]] | [[REM|']] } $INCLUDE: '{{Parameter|sourceFile}}'
{{PageDescription}}
@ -40,3 +40,4 @@
{{PageNavigation}}
<

View file

@ -1,4 +1,4 @@
[[$LET]] is a precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
[[$LET]] is precompiler command, which is now usable by modern day [[cavemen]] to help include and exclude which sections of code compiles in their program based on OS/bit-size or other predefined conditions.
{{PageSyntax}}
@ -7,16 +7,9 @@
{{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.
* $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 can contain numbers, letters, and periods in any order. [[$LET]] '''3.2 = TRUE''' is a perfectly valid variable and expression.
* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. [[$LET]] '''3.2 = "TRUE"''' is also perfectly valid, but [[$LET]] '''3.2 = ""TRUE""''' will error because of the double quotes.
{{PageExamples}}
@ -32,3 +25,4 @@
{{PageNavigation}}
<

View file

@ -11,11 +11,11 @@ The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be use
* 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]] can be placed anywhere in a program.
* [[$NOPREFIX]] must be the first line in a program.
{{PageAvailability}}
* Version 1.4 and up.
==Availability==
* '''Version 1.4 and up'''.
{{PageSeeAlso}}
@ -24,3 +24,4 @@ The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be use
{{PageNavigation}}
<

View file

@ -12,8 +12,8 @@ The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can b
* $RESIZE:SMOOTH the screen will be stretched also, but with linear filtering applied to the pixels.
{{PageAvailability}}
* Version 1.000 and up.
==Availability==
* '''Version 1.000 and up'''.
{{PageExamples}}
@ -112,3 +112,4 @@ DO
{{PageNavigation}}
<

View file

@ -24,7 +24,7 @@ The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main pro
{{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)
ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET(function)|_OFFSET}}(s1), 0)
{{CodeEnd}}{{small|Code by Michael Calkins}}
@ -35,3 +35,4 @@ ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET (
{{PageNavigation}}
<

View file

@ -1,21 +1,19 @@
The [[$SCREENSHOW]] [[Metacommand|metacommand]] can be used to display the main program window throughout the program.
{{DISPLAYTITLE:_SCREENSHOW}}
The [[_SCREENSHOW]] statement can be used to display the main program window in a section of code.
{{PageSyntax}}
: $SCREENSHOW
: [[_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]].'''
* [[_SCREENHIDE]] or [[$SCREENHIDE]] must be used before _SCREENSHOW or [[$SCREENSHOW]] can be used!
{{PageSeeAlso}}
* [[$CONSOLE]], [[$SCREENHIDE]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_SCREENSHOW]]
* [[_CONSOLE]]
* [[$SCREENHIDE]], [[$SCREENSHOW]], [[$CONSOLE]] (QB64 [[Metacommand]]s)
* [[_SCREENHIDE]], [[_CONSOLE]]
{{PageNavigation}}
<

View file

@ -1,19 +1,18 @@
The [[$STATIC]] [[Metacommand|metacommand]] allows the creation of static (unresizable) arrays.
The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) arrays.
{{PageSyntax}}
:{[[REM]] | [[apostrophe|']] } [[$STATIC]]
::: REM '''$STATIC'''
{{PageDescription}}
* QBasic [[Metacommand]]s require a REM or apostrophy (') before them and are normally placed at the start of the main module.
* 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.
* A [[REDIM]] statement has no effect on [[$STATIC]] arrays except perhaps a [[ERROR Codes|duplicate definition error]] at the [[REDIM]] code.
* 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}}
@ -28,9 +27,10 @@ The [[$STATIC]] [[Metacommand|metacommand]] allows the creation of static (unres
: ''Note:'' [[DIM]] using a literal numerical size will create a Duplicate definition error.
{{PageSeeAlso}}
''See also:''
* [[$DYNAMIC]], [[STATIC]]
* [[Arrays]], [[Metacommand]]
{{PageNavigation}}
<

View file

@ -6,7 +6,7 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
: [[$VERSIONINFO]]:{{Parameter|key}}={{Parameter|value}}
{{PageParameters}}
{{Parameters}}
* Text ''keys'' can be: '''CompanyName, FileDescription, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, Web, Comments'''
* Numeric {{Parameter|keys}} can be:'''FILEVERSION#''' and '''PRODUCTVERSION#'''
@ -14,12 +14,11 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
{{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}}
* Build 20170429/52 and up.
==Availability==
* '''Build 20170429/52 and up'''.
{{PageExamples}}
@ -38,3 +37,4 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
{{PageNavigation}}
<

View file

@ -1,5 +1,5 @@
{{DISPLAYTITLE:$VIRTUALKEYBOARD}}
[DEPRECATED] The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
[DEPRACATED] The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
{{PageSyntax}}
@ -8,7 +8,7 @@
{{PageDescription}}
* Places a virtual keyboard on screen, which can be used in touch-enabled devices like Windows tablets.
* Deprecated.
* Depracated.
{{PageExamples}}
@ -24,3 +24,4 @@
{{PageNavigation}}
<

View file

@ -136,3 +136,4 @@ d = &amp;B1111111111111111 '&amp; 'or ~%
{{PageNavigation}}
<

View file

@ -48,31 +48,31 @@ Min _INTEGER64 value = 8000000000000000 with 16 digits
''Example 2:'' Converting a decimal number to a binary string value using [[HEX$]].
{{CodeStart}} '' ''
{{Cl|FUNCTION}} BIN$ (n&amp;)
FUNCTION BIN$ (n&amp;)
h$ = {{Cl|HEX$}}(n&amp;) '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&amp; = 0
{{Cl|END FUNCTION}} '' ''
FOR i = 1 TO {{Cl|LEN}}(h$) 'scan the HEX$ digits
SELECT CASE {{Cl|MID$}}(h$, i, 1) 'read each HEX$ digit
CASE "0": b$ = b$ + "0000"
CASE "1": b$ = b$ + "0001"
CASE "2": b$ = b$ + "0010"
CASE "3": b$ = b$ + "0011"
CASE "4": b$ = b$ + "0100"
CASE "5": b$ = b$ + "0101"
CASE "6": b$ = b$ + "0110"
CASE "7": b$ = b$ + "0111"
CASE "8": b$ = b$ + "1000"
CASE "9": b$ = b$ + "1001"
CASE "A": b$ = b$ + "1010"
CASE "B": b$ = b$ + "1011"
CASE "C": b$ = b$ + "1100"
CASE "D": b$ = b$ + "1101"
CASE "E": b$ = b$ + "1110"
CASE "F": b$ = b$ + "1111"
END SELECT
NEXT i
b$ = {{Cl|RIGHT$}}(b$, LEN(b$) - {{Cl|INSTR}}(b$, "1") + 1) 'eliminate leading zeroes
IF {{Cl|VAL}}(b$) THEN BIN$ = b$ ELSE BIN$ = "0" 'return zero if n&amp; = 0
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.
@ -85,3 +85,4 @@ Min _INTEGER64 value = 8000000000000000 with 16 digits
{{PageNavigation}}
<

View file

@ -1,7 +1,8 @@
The '''&amp;O''' prefix denotes that a integer value is expressed in an Octal base 8 format.
{{PageSyntax}} a&amp; = &amp;O12345671234
{{PageSyntax}}
:::: a&amp; = &amp;O12345671234
* The base eight numbering system only uses octal digit values of 0 to 7.
@ -39,3 +40,4 @@ Max octal _INTEGER64 = 1777777777777777777777 with 22 digits =-1
{{PageNavigation}}
<

View file

@ -1,24 +1,28 @@
The [[/]] mathematical operator performs decimal point division on a numerical value.
The '''/''' mathematical operator performs decimal point division on a numerical value.
{{PageSyntax}}
:return_value = number [[/]] divisor
::: return_value = number '''/''' 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 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.
* Division and multiplication operations are performed before addition and subtraction in Qbasic's order of operations.
{{PageSeeAlso}}
''See also:''
* [[MOD|MOD (remainder division operator)]]
* [[\|\ (integer division operator)]]
* [[*|* (multiplication operator)]]
* [[INT]], [[CINT]], [[FIX]], [[_ROUND]]
* [[Mathematical Operations]]
{{PageNavigation}}
<

189
internal/help/+.txt Normal file
View file

@ -0,0 +1,189 @@
<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title>Bad title - QB64 Phoenix Edition Wiki</title>
<script>document.documentElement.className="client-js";RLCONF={"wgBreakFrames":!0,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"YmKotPy6oUYLdp3-E9jrRAAAAYM","wgCSPNonce":!1,"wgCanonicalNamespace":"Special","wgCanonicalSpecialPageName":"Badtitle","wgNamespaceNumber":-1,"wgPageName":"Special:Badtitle","wgTitle":"Badtitle","wgCurRevisionId":0,"wgRevisionId":0,"wgArticleId":0,"wgIsArticle":!1,"wgIsRedirect":!1,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"Special:Badtitle","wgRelevantArticleId":0,"wgIsProbablyEditable":!1,"wgRelevantPageIsProbablyEditable":!1,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},
"wgEditSubmitButtonLabelPublish":!1};RLSTATE={"site.styles":"ready","noscript":"ready","user.styles":"ready","user":"ready","user.options":"loading","skins.vector.styles.legacy":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready"};RLPAGEMODULES=["site","mediawiki.page.ready","skins.vector.legacy.js","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader"];</script>
<script>(RLQ=window.RLQ||[]).push(function(){mw.loader.implement("user.options@1hzgi",function($,jQuery,require,module){/*@nomin*/mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"});
});});</script>
<link rel="stylesheet" href="/qb64wiki/load.php?lang=en&amp;modules=ext.visualEditor.desktopArticleTarget.noscript%7Cskins.vector.styles.legacy&amp;only=styles&amp;skin=vector"/>
<script async="" src="/qb64wiki/load.php?lang=en&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;skin=vector"></script>
<meta name="generator" content="MediaWiki 1.37.2"/>
<meta name="robots" content="noindex,nofollow"/>
<meta name="format-detection" content="telephone=no"/>
<link rel="shortcut icon" href="/favicon.ico"/>
<link rel="search" type="application/opensearchdescription+xml" href="/qb64wiki/opensearch_desc.php" title="QB64 Phoenix Edition Wiki (en)"/>
<link rel="EditURI" type="application/rsd+xml" href="https://qb64phoenix.com/qb64wiki/api.php?action=rsd"/>
<link rel="alternate" type="application/atom+xml" title="QB64 Phoenix Edition Wiki Atom feed" href="/qb64wiki/index.php?title=Special:RecentChanges&amp;feed=atom"/>
</head>
<body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns--1 ns-special mw-special-Badtitle page-Special_Badtitle rootpage-Special_Badtitle skin-vector action-view skin-vector-legacy"><div id="mw-page-base" class="noprint"></div>
<div id="mw-head-base" class="noprint"></div>
<div id="content" class="mw-body" role="main">
<a id="top"></a>
<div id="siteNotice"></div>
<div class="mw-indicators">
</div>
<h1 id="firstHeading" class="firstHeading" >Bad title</h1>
<div id="bodyContent" class="vector-body">
<div id="contentSub"></div>
<div id="contentSub2"></div>
<div id="jump-to-nav"></div>
<a class="mw-jump-link" href="#mw-head">Jump to navigation</a>
<a class="mw-jump-link" href="#searchInput">Jump to search</a>
<div id="mw-content-text" class="mw-body-content"><p>The requested page title is empty or contains only the name of a namespace.
</p><p id="mw-returnto">Return to <a href="/qb64wiki/index.php/Main_Page" title="Main Page">Main Page</a>.</p>
<div class="printfooter">Retrieved from "<a dir="ltr" href="https://qb64phoenix.com/qb64wiki/index.php/Special:Badtitle">https://qb64phoenix.com/qb64wiki/index.php/Special:Badtitle</a>"</div></div>
<div id="catlinks" class="catlinks catlinks-allhidden" data-mw="interface"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
<div id="mw-head">
<nav id="p-personal" class="mw-portlet mw-portlet-personal vector-user-menu-legacy vector-menu" aria-labelledby="p-personal-label" role="navigation"
>
<h3 id="p-personal-label" class="vector-menu-heading"> <span>Personal tools</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"><li id="pt-anonuserpage" class="mw-list-item">Not logged in</li><li id="pt-anontalk" class="mw-list-item"><a href="/qb64wiki/index.php/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n">Talk</a></li><li id="pt-anoncontribs" class="mw-list-item"><a href="/qb64wiki/index.php/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y">Contributions</a></li><li id="pt-createaccount" class="mw-list-item"><a href="/qb64wiki/index.php?title=Special:CreateAccount&amp;returnto=Special%3ABadtitle&amp;returntoquery=action%3Dedit" title="You are encouraged to create an account and log in; however, it is not mandatory">Create account</a></li><li id="pt-login" class="mw-list-item"><a href="/qb64wiki/index.php?title=Special:UserLogin&amp;returnto=Special%3ABadtitle&amp;returntoquery=action%3Dedit" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li></ul>
</div>
</nav>
<div id="left-navigation">
<nav id="p-namespaces" class="mw-portlet mw-portlet-namespaces vector-menu vector-menu-tabs" aria-labelledby="p-namespaces-label" role="navigation"
>
<h3 id="p-namespaces-label" class="vector-menu-heading"> <span>Namespaces</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"><li id="ca-nstab-special" class="selected mw-list-item"><a href="/qb64wiki/index.php?title=+&amp;action=edit" title="This is a special page, and it cannot be edited">Special page</a></li></ul>
</div>
</nav>
<nav id="p-variants" class="mw-portlet mw-portlet-variants emptyPortlet vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-variants-label" role="navigation"
>
<input type="checkbox"
id="p-variants-checkbox"
role="button"
aria-haspopup="true"
data-event-name="ui.dropdown-p-variants"
class=" vector-menu-checkbox" aria-labelledby="p-variants-label" />
<h3 id="p-variants-label" class="vector-menu-heading"> <span>Variants</span>
<span class="vector-menu-checkbox-expanded">expanded</span>
<span class="vector-menu-checkbox-collapsed">collapsed</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"></ul>
</div>
</nav>
</div>
<div id="right-navigation">
<nav id="p-views" class="mw-portlet mw-portlet-views emptyPortlet vector-menu vector-menu-tabs" aria-labelledby="p-views-label" role="navigation"
>
<h3 id="p-views-label" class="vector-menu-heading"> <span>Views</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"></ul>
</div>
</nav>
<nav id="p-cactions" class="mw-portlet mw-portlet-cactions emptyPortlet vector-menu-dropdown-noicon vector-menu vector-menu-dropdown" aria-labelledby="p-cactions-label" role="navigation" title="More options"
>
<input type="checkbox"
id="p-cactions-checkbox"
role="button"
aria-haspopup="true"
data-event-name="ui.dropdown-p-cactions"
class=" vector-menu-checkbox" aria-labelledby="p-cactions-label" />
<h3 id="p-cactions-label" class="vector-menu-heading"> <span>More</span>
<span class="vector-menu-checkbox-expanded">expanded</span>
<span class="vector-menu-checkbox-collapsed">collapsed</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"></ul>
</div>
</nav>
<div id="p-search" role="search" class="vector-search-box">
<div>
<h3 >
<label for="searchInput">Search</label>
</h3>
<form action="/qb64wiki/index.php" id="searchform">
<div id="simpleSearch" data-search-loc="header-navigation">
<input type="search" name="search" placeholder="Search QB64 Phoenix Edition Wiki" autocapitalize="sentences" title="Search QB64 Phoenix Edition Wiki [f]" accesskey="f" id="searchInput"/>
<input type="hidden" name="title" value="Special:Search"/>
<input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton mw-fallbackSearchButton"/>
<input type="submit" name="go" value="Go" title="Go to a page with this exact name if it exists" id="searchButton" class="searchButton"/>
</div>
</form>
</div>
</div>
</div>
</div>
<div id="mw-panel">
<div id="p-logo" role="banner">
<a class="mw-wiki-logo" href="/qb64wiki/index.php/Main_Page"
title="Visit the main page"></a>
</div>
<nav id="p-navigation" class="mw-portlet mw-portlet-navigation vector-menu vector-menu-portal portal" aria-labelledby="p-navigation-label" role="navigation"
>
<h3 id="p-navigation-label" class="vector-menu-heading"> <span>Navigation</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"><li id="n-mainpage-description" class="mw-list-item"><a href="/qb64wiki/index.php/Main_Page" title="Visit the main page [z]" accesskey="z">Main page</a></li><li id="n-recentchanges" class="mw-list-item"><a href="/qb64wiki/index.php/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li><li id="n-randompage" class="mw-list-item"><a href="/qb64wiki/index.php/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li><li id="n-help-mediawiki" class="mw-list-item"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents">Help about MediaWiki</a></li></ul>
</div>
</nav>
<nav id="p-tb" class="mw-portlet mw-portlet-tb vector-menu vector-menu-portal portal" aria-labelledby="p-tb-label" role="navigation"
>
<h3 id="p-tb-label" class="vector-menu-heading"> <span>Tools</span>
</h3>
<div class="vector-menu-content">
<ul class="vector-menu-content-list"><li id="t-specialpages" class="mw-list-item"><a href="/qb64wiki/index.php/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li><li id="t-print" class="mw-list-item"><a href="javascript:print();" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li></ul>
</div>
</nav>
</div>
</div>
<footer id="footer" class="mw-footer" role="contentinfo" >
<ul id="footer-info" >
</ul>
<ul id="footer-places" >
<li id="footer-places-privacy"><a href="/qb64wiki/index.php/QB64_Phoenix_Edition_Wiki:Privacy_policy" title="QB64 Phoenix Edition Wiki:Privacy policy">Privacy policy</a></li>
<li id="footer-places-about"><a href="/qb64wiki/index.php/QB64_Phoenix_Edition_Wiki:About" title="QB64 Phoenix Edition Wiki:About">About QB64 Phoenix Edition Wiki</a></li>
<li id="footer-places-disclaimer"><a href="/qb64wiki/index.php/QB64_Phoenix_Edition_Wiki:General_disclaimer" title="QB64 Phoenix Edition Wiki:General disclaimer">Disclaimers</a></li>
</ul>
<ul id="footer-icons" class="noprint">
<li id="footer-poweredbyico"><a href="https://www.mediawiki.org/"><img src="/qb64wiki/resources/assets/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" srcset="/qb64wiki/resources/assets/poweredby_mediawiki_132x47.png 1.5x, /qb64wiki/resources/assets/poweredby_mediawiki_176x62.png 2x" width="88" height="31" loading="lazy"/></a></li>
</ul>
</footer>
<script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgBackendResponseTime":55});});</script>
</body></html>

View file

@ -1,21 +1,28 @@
The [[-]] mathematical operator performs subtraction on two numerical values or [[negation|negates]] a single value.
The '''-''' mathematical operator performs subtraction on two numerical values or [[negation|negates]] a single value.
{{PageSyntax}}
:return_value = number1 [[-]] number2
''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.
* Addition and subtraction are the last operations performed in Qbasic's normal order of operations.
* Subtraction cannot be performed on [[STRING]] values.
{{PageSeeAlso}}
* [[+|+ positive]] (addition operator)
* [[Mathematical Operations]]
''See also:''
[[+|+ positive]] (addition operator)
[[Mathematical Operations]]
{{PageNavigation}}
<

View file

@ -1,43 +1,59 @@
The [[\]] mathematical operator performs [[INTEGER]] division on a numerical value.
==Welcome to the QB64 Wiki==
QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.
[[File:IDE_macos.png|thumb|left|QB64's IDE running on macOS Catalina]]
{| align="right"
| __TOC__
|}
==Getting started==
* Grab the latest version of QB64 from [https://github.com/QB64Team/qb64/releases/latest the releases page].
===FAQ===
* [[QB64 FAQ|Frequently asked questions about QB64]]
===Get in touch===
* [https://qb64phoenix.com/forum/index.php QB64 Phoenix Edition Forum]
* [https://discord.com/invite/2t9HTYK Discord invitation]
{{PageSyntax}}
:return_value = number [[\]] divisor
==Keywords==
* [[Keyword Reference - Alphabetical]]
* [[Keyword Reference - By usage]]
* [[Syntax Reference - QB64]]
===Known issues===
* [[Keywords currently not supported by QB64|Legacy keywords not supported by QB64]]
* [[Keywords currently not supported by QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keywords not supported in Linux or macOS versions]]
{{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 [[/]] integer 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}}
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}}
* [[MOD|MOD (remainder division operator)]]
* [[/|/ (normal division operator)]]
* [[INT]], [[CINT]], [[FIX]], [[_ROUND]]
==Articles and Tutorials==
* [http://www.qb64sourcecode.com Terry Ritchie's QB64 Game Programming]
* [https://www.youtube.com/watch?v=hE-Voij5k5Q&amp;list=PLF6199808BD4901E1 School Freeware series on QB64 (YouTube)]
* [[Arrays]]
* [[ASCII|ASCII Character Codes]]
* [[Binary|Binary Numbers]]
* [[Boolean|Boolean Operations]]
* [[_CLIPBOARD$|Clipboard]]
* [[Converting Bytes to Bits]]
* [[Console Window]]
* [[Controller Devices]] (Keyboard, Mouse, Joystick, Gamepad)
* [[Downloading Files]] (TCP/IP)
* [[Windows Environment|Environment (Windows Registry)]]
* [[Hardware images]]
* [[Images|Image file procedures]]
* [[Keyboard scancodes|Keyboard Scan Codes]]
* [[Libraries]] ([[C Libraries|C++]], [[Windows Libraries|Windows]], [[DLL Libraries|DLL]])
* [[Mathematical Operations]]
{{PageNavigation}}
* [[PDS (7.1) Procedures]]
* [[Port Access Libraries]]
* [[QB 4.5 Library Ports For QB64]]
* [[Relational Operations]]
* [[Line numbers]]
* [[Line number|Removing line numbers]]
* [[Resource Table extraction]] {{text|([[Resource_Table_extraction#Extract_Icon|Icon Extraction]])}}
* [[Screen Memory]]
* [[Text Using Graphics|Text, Fonts and Unicode Using Graphics]]
* [[Variable Types]]
<

View file

@ -35,3 +35,4 @@ c = {{Cl|ABS}}(c)
{{PageNavigation}}
<

View file

@ -1,27 +1,162 @@
#REDIRECT [[OPEN#File_ACCESS_and_LOCK_Permissions]]
The [[ACCESS]] clause is used in an [[OPEN]] statement when working over a network.
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
:OPEN "file.dat" FOR APPEND ['''ACCESS {READ|WRITE}'''] AS #1
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{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&amp;}} 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}}
* Valid Options:
**Default: When specified, all other processes are denied file access.
**READ: When specified, read access is denied to other file procedures.
**WRITE: When specified, write access is denied to other file procedures.
**READ WRITE: When specified any access is denied to other file procedures.
* '''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&amp;}} 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'''.
===Limitations===
*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.
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : &lt; > '''. 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.
{{PageSeeAlso}}
* [[LOCK]], [[LOCK (access)]]
* [[OPEN]]
* [[ON ERROR]]
==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}}&lt;nowiki> = &lt;/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,44 +1,2 @@
#REDIRECT [[DECLARE LIBRARY]]
The [[ALIAS]] clause in a [[DECLARE LIBRARY]] statement block tells the program the name of the procedure used in the external library.
{{PageSyntax}}
: SUB ''pseudoname'' [[ALIAS]] ''actualname'' [(''parameters'')]
{{PageParameters}}
* The ''pseudo name'' is the name of the [[SUB]] or [[FUNCTION]] the QB64 program will use.
* The ''actual name'' is the same procedure name as it is inside of the DLL library.
* QB64 must use all parameters of imported procedures including optional ones.
{{PageDescription}}
* The ALIAS name clause is optional as the original library procedure name can be used.
* The procedure name does not have to be inside of quotes when using [[DECLARE LIBRARY]].
* QB64 does not support optional parameters.
{{PageExamples}}
''Example:'' Instead of creating a SUB with the Library statement inside of it, just rename it:
{{CodeStart}} '' ''
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} glutWarpPointer ({{Cl|BYVAL}} xoffset&amp;, {{Cl|BYVAL}} yoffset&amp;)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|_SCREENEXISTS}}: {{Cl|LOOP}}
{{Cl|PRINT}} "Hit a key..."
{{Cl|SLEEP}}
MouseMove 1, 1
{{CodeEnd}}
:''Explanation:'' When a Library procedure is used to represent another procedure name use ALIAS instead. Saves creating a SUB! Just place your name for the procedure first with the actual Library name after ALIAS.
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]
* [[DECLARE LIBRARY]], [[BYVAL]]
* [[DECLARE DYNAMIC LIBRARY]]
{{PageNavigation}}
<

View file

@ -74,3 +74,4 @@ The logical [[AND]] numerical operator compares two values in respect of their b
{{PageNavigation}}
<

View file

@ -61,3 +61,4 @@ True
{{PageNavigation}}
<

View file

@ -1,20 +1,162 @@
#REDIRECT [[OPEN#File_Access_Modes]]
[[APPEND]] is used in an output type [[OPEN]] statement to add data to the end of a file.
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 APPEND''' AS #1
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{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&amp;}} 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}}
* Creates an empty file using the filename if none exists.
* Mode places new data after the previous data in the file.
* Mode can use [[PRINT (file statement)]], [[WRITE (file statement)]] or [[PRINT USING (file statement)]] to output file data or text.
* '''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&amp;}} 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'''.
{{PageSeeAlso}}
[[OUTPUT]], [[RANDOM]], [[INPUT (file mode)]], [[BINARY]]
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : &lt; > '''. 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}}&lt;nowiki> = &lt;/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,9 +1,9 @@
The [[AS]] keyword defines a variable data [[Variable Types|type]].
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 [[Variable Types|type]] in a declarative statement or parameter list using:
* Specifies a variable's [[type]] in a declarative statement or parameter list using:
** [[DIM]] or [[REDIM]]
** [[DECLARE LIBRARY]]
** [[SUB]]
@ -15,7 +15,7 @@ The [[AS]] keyword defines a variable data [[Variable Types|type]].
===Details===
* Specifies a '''[[parameter]]''' variable's type in a [[SUB]] or [[FUNCTION]] procedure. '''Cannot be used to define a function's [[Variable Types|type]]'''
* 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]])
@ -31,3 +31,4 @@ The [[AS]] keyword defines a variable data [[Variable Types|type]].
{{PageNavigation}}
<

View file

@ -91,9 +91,9 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
{{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) '' ''
{{Cl|PRINT}} ASC("A")
{{Cl|PRINT}} ASC("Be a rockstar")
{{Cl|PRINT}} ASC("QB64 is not only COMPATIBLE, it can find any part of the string!", 18) '' ''
{{CodeEnd}}
''Returns:''
@ -114,8 +114,8 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
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$ &lt;> "" ' prevent ASC empty string read error
DO
DO: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ &lt;> "" ' 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):
@ -133,18 +133,18 @@ Q$ = {{Cl|CHR$}}(34) ' quote character
''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$}}
DO: {{Cl|SLEEP}} ' requires a keypress to run loop once
K$ = {{Cl|{{Cl|INKEY$}}}}
code = {{Cl|ASC}}(K$)
{{Cl|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code &lt;= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|CHR$}}(code) ' numbers only
{{Cl|IF}} code = 46 {{Cl|AND (boolean)|AND}} flag = 0 {{Cl|THEN}}
{{Cl|IF...THEN|IF}} code >= 48 {{Cl|AND (boolean)|AND}} code &lt;= 57 {{Cl|THEN}} entry$ = entry$ + {{Cl|{{Cl|CHR$}}}}(code) ' numbers only
{{Cl|IF...THEN|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 &lt; 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
L = {{Cl|{{Cl|LEN}}}}(entry$) ' check entry length for possible backspace
{{Cl|IF...THEN|IF}} code = 8 {{Cl|AND (boolean)|AND}} L > 0 {{Cl|THEN}} ' backspace pressed and entry has a length
entry$ = {{Cl|{{Cl|MID$}}}}(entry$, 1, L - 1) ' remove one character from entry$
{{Cl|IF...THEN|IF}} L - 1 &lt; mark {{Cl|THEN}} flag = 0 ' allow another decimal point if removed.
{{Cl|LOCATE}} 10, {{Cl|POS}}(0) - 1: {{Cl|PRINT}} {{Cl|{{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)
@ -164,3 +164,4 @@ Q$ = {{Cl|CHR$}}(34) ' quote character
{{PageNavigation}}
<

View file

@ -43,3 +43,4 @@ The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a ch
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[ATN]] or arctangent function returns the angle in radians of a numerical [
: {{Parameter|radianAngle}} = [[ATN]]({{Parameter|tangent!}})
{{PageParameters}}
{{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 &lt;nowiki>=&lt;/nowiki> 4 * ATN(1)|green}}'''
@ -30,7 +30,7 @@ y = 100 * {{Cl|SIN}}({{Cl|ATN}}(1))
{{CodeStart}} '' ''
Pi = 4 * {{Cl|ATN}}(1) '{{Cl|SINGLE}} precision
Pi# = 4 * {{Cl|ATN}}(1#) '{{Cl|DOUBLE}} precision
{{Cl|PRINT}} Pi, Pi# '' ''
PRINT Pi, Pi# '' ''
{{CodeEnd}}
:''Note:'' You can use QB64's native [[_PI]] function.
@ -41,38 +41,38 @@ Pi# = 4 * {{Cl|ATN}}(1#) '{{Cl|DOUBLE}} precision
x1! = 320
y1! = 240
{{Cl|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}}
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$}} &lt;> ""
{{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# &lt; 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|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# &lt; 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}}
@ -86,3 +86,4 @@ y1! = 240
{{PageNavigation}}
<

View file

@ -1,15 +1,10 @@
The '''apostrophe''' allows explanatory comments, or remarks, to be inserted in a program. These may be included anywhere in the source code and extend to the end of the line. Comments are ignored when the program is run.
{{PageSyntax}}
:: [[apostrophe|']] this is a comment
:: [[REM]] this is also a comment
The '''apostrophe''' is used to tell the compiler to ignore a statement or programmer comment.
{{PageDescription}}
* [[REM]] can also be used to insert comments but may only be used as the last, or only, statement on a line.
* QBasic [[metacommand]]s like [[$INCLUDE]] must be included in a comment using either [[REM]] or [[apostrophe|']].
* [[Apostrophe]] comments, unavailable in earlier dialects of the BASIC language, are now generally favored over [[REM]] statements for their greater flexibility.
* Comments are also useful for disabling code for program testing and debugging purposes.
* 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}}
@ -23,8 +18,9 @@ COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{PageSeeAlso}}
* [[Comma]], [[Semicolon]]
* [[REM]]
* [[$DYNAMIC]], [[$STATIC]], [[$INCLUDE]]
{{PageNavigation}}
<

View file

@ -10,7 +10,7 @@ The [[BEEP]] statement produces a beep sound through the sound card.
* '''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].
{{PageQBasic}}
==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.
@ -22,3 +22,4 @@ The [[BEEP]] statement produces a beep sound through the sound card.
{{PageNavigation}}
<

View file

@ -1,84 +1,162 @@
#REDIRECT [[OPEN#File_Access_Modes]]
[[BINARY]] is used in an [[OPEN]] statement to work with the file or port device manipulating its bytes directly.
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]] [[BINARY]] [[AS]] {{Parameter|#fileNumber%}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{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&amp;}} 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}}
* [[OPEN]] FOR BINARY creates the file if the {{Parameter|fileName$}} does not exist.
* {{Parameter|fileName$}} is the name of the file to open, but could also configure a port.
* {{Parameter|#fileNumber%}} is the number that will represent the file when performing file operations.
* BINARY files use [[GET|GET #]] and [[PUT|PUT #]] to read or write the file at any byte position.
* In '''version 1.000 and up''' you can use [[LINE INPUT]] in [[BINARY]] mode for faster access to text file data.
* QBasic's [[BSAVE]] or BINARY save files can be read using BINARY mode.
* BINARY mode ignores any [[LEN]] = recordlength statement in the [[OPEN]] statement.
* Ports can also be opened in [[BINARY]] mode. See: [[OPEN COM]]
* '''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&amp;}} 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 ''' " * / \ | ? : &lt; > '''. 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:'' Shows how a PUT variable value is converted to an [[ASCII]] string [[_MK$]] format in a BINARY file.
{{CodeStart}} '' ''
{{Cl|DIM}} int64 {{Cl|AS}} {{Cl|_INTEGER64}}
{{Cl|DIM}} byte8 {{Cl|AS}} {{Cl|STRING}} * 8
int64 = 12345678
{{Cl|PRINT}} int64
''Example 1:'' Function that displays errors and the number of errors in QBasic filenames. Returns 0 when filename is OK.
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|PUT}} #1, , int64 'the file size will be 8 bytes
{{Cl|CLOSE}}
{{CodeStart}}
file$ = "Hello,~1.mp3" 'example call below
{{Cl|LOCATE}} 20, 30: errors% = CheckName%(file$): {{Cl|COLOR}} 14: {{Cl|PRINT}} " Total Errors ="; errors%
{{Cl|PRINT}} "Press a key to read the file!"
K$ = {{Cl|INPUT$}}(1)
{{Cl|OPEN}} "temp64.tmp" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|GET}} #1, , byte8 'GET the value as a string
{{Cl|PRINT}} "text string: "; byte8 'show that string is in {{Cl|_MK$}} format
{{Cl|PRINT}} {{Cl|_CV}}({{Cl|_INTEGER64}}, byte8) 'convert to numerical value
{{Cl|CLOSE}} '' ''
{{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 numerical value does not need to be converted if the file is read using the same numerical variable type as written.
''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}}&lt;nowiki> = &lt;/nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' A binary file viewer that can view integer values. The type of value can be changed at [[DIM]].
''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}} '' ''
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(1000, 600, 256)
{{Cl|_SCREENMOVE}} {{Cl|_SCREENMOVE|_MIDDLE}}
{{Cl|DIM}} value AS {{Cl|INTEGER}} 'value type can be changed
{{Cl|LINE INPUT}} ; "Enter a {{Cl|BINARY}} filename to open: ", file$
{{Cl|PRINT}} " Press S to restart!"
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|IF...THEN|IF}} {{Cl|LEN}}(file$) {{Cl|THEN}} {{Cl|OPEN}} file$ {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 {{Cl|ELSE}} {{Cl|END}}
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) = 0 {{Cl|THEN}} {{Cl|PRINT}} "Empty file!": {{Cl|END}}
DO
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 16
x = x + 1
{{Cl|GET}} #1, , value
{{Cl|IF...THEN|IF}} {{Cl|EOF}}(1) {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|PRINT}} value;
{{Cl|NEXT}}
{{Cl|PRINT}} {{Cl|CHR$}}(27); x; "@"; row
K$ = {{Cl|INPUT$}}(1)
{{Cl|IF...THEN|IF}} {{Cl|UCASE$}}(K$) = "S" {{Cl|THEN}} {{Cl|CLS}}: x = 0: row = 0: {{Cl|PRINT}} "Restarted!": {{Cl|SEEK}} 1, 1
{{Cl|IF...THEN|IF}} x = 256 {{Cl|THEN}} x = 0: row = row + 1: {{Cl|PRINT}}
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27)
{{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|PRINT}} "Press Escape to exit!"
DO: {{Cl|_LIMIT}} 100
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27)
{{Cl|SYSTEM}} '' ''
{{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}}
* [[OPEN]], [[CLOSE]]
* [[GET]], [[PUT]], [[LINE INPUT]]
* [[SEEK]] (function), [[SEEK (statement)]]
* [[INPUT (file mode)]], [[RANDOM]], [[APPEND]], [[OUTPUT]]
* [[Bitmaps]], [[Binary]] (numbers)
{{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,6 +1,6 @@
[[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array.
{{PageLegacySupport}}
==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.'''
@ -8,7 +8,7 @@
: [[BLOAD]] {{Parameter|fileName$}}, [[VARPTR]]({{Parameter|imageArray%({{Parameter|index}})}})
{{PageParameters}}
{{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.
@ -53,3 +53,4 @@
{{PageNavigation}}
<

View file

@ -1,15 +1,15 @@
[[BSAVE]] saves the contents of an image array to a [[BINARY]] file.
{{PageLegacySupport}}
* QB64 can save larger arrays directly to binary files using [[PUT]] # and [[GET]] # without [[BSAVE]]. For that reason, use of [[BSAVE]] is no longer recommended practice but is supported to maintain compatibility with legacy code.
==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.
{{PageSyntax}}
: [[BSAVE]] {{Parameter|saveFile$}}, [[VARPTR]]({{Parameter|array(index)}}), {{Parameter|fileSize&amp;}}
{{PageParameters}}
{{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&amp;}} must be a bit over twice the size of the elements used in an [[INTEGER]] [[Arrays|array]].
@ -65,16 +65,16 @@
{{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%) &lt;> 0 {{Cl|THEN}} {{Cl|EXIT FOR}} 'find image color not black
{{Cl|IF...THEN|IF}} Graphic%(i%) &lt;> 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 (file statement)|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file
{{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 (file statement)|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen
{{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}}
@ -102,3 +102,4 @@ K$ = {{Cl|INPUT$}}(1) 'Press any key
{{PageNavigation}}
<

View file

@ -1 +1,103 @@
#REDIRECT [[DECLARE LIBRARY]]
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.
&lt;center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''&lt;/center>
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&amp;, {{Cl|BYVAL}} row&amp;)
{{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&amp; ({{Cl|BYVAL}} value&amp;)
{{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.'''
&lt;center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''&lt;/center>
&lt;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.'''&lt;/center>
''See also:''
* [[DECLARE DYNAMIC LIBRARY]]
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
* [[SQL Client]]
{{PageNavigation}}
<

View file

@ -14,6 +14,12 @@
* 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}} '' ''
@ -52,6 +58,8 @@ Hello World!
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]
* DECLARE, [[DECLARE (non-BASIC statement)]]
{{PageNavigation}}
<

1
internal/help/CALLS.txt Normal file
View file

@ -0,0 +1 @@
<

View file

@ -5,7 +5,7 @@
: [[CALL ABSOLUTE]]([{{Parameter|argumentList}},] {{Parameter|integerOffset}})
{{PageLegacySupport}}
==Legacy support==
* [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, the '''use [[_MOUSEINPUT]] and related functions'''.
@ -13,13 +13,15 @@
* [[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.
* '''QB64''' has the ABSOLUTE statement built in and requires no external library, like QuickBASIC did.
* 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]]
* [[DECLARE (non-BASIC statement)]]
* [[_MOUSEINPUT]]
{{PageNavigation}}
<

View file

@ -1,65 +1,2 @@
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE]] is used within a [[SELECT CASE]] block to specify a conditional value of the compared variable.
{{PageSyntax}}
: [[CASE]] {{Parameter|comparisonValues}}[:] {code}
{{PageDescription}}
*{{Parameter|comparisonValues}} can be any literal string or number, depending on the value specified in the [[SELECT CASE]] statement.
*Code is executed until the next case, so each case can handle multiple lines of code.
*[[CASE]] conditions are normally listed in some logical order going down the page.
*[[CASE]] order can affect the SELECT CASE code execution when more than one CASE can be true. This is specially true when multiple conditional operators, CASE IS or TO ranges are used.
* [[CASE]] lists can also be listed horizontally by using colon separators between cases.
* Supports individual CASE values and ranges or lists of values as below:
** [[CASE]] value
** [[CASE]] value1 [[TO]] value2
** [[CASE]] value1, value2, value3
** [[CASE IS]] value1 > value2
** [[CASE ELSE]]
* The first time a [[CASE]] value matches the compared variable's value, that [[CASE]] code is executed and [[SELECT CASE]] is exited, unless '''EVERYCASE''' is used.
{{PageExamples}}
{{CodeStart}}
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} 1, 3, 5, 7, 9: {{Cl|PRINT}} "Odd values under 10 will be shown."
{{Cl|CASE}} 10: {{Cl|PRINT}} "10 will be shown."
{{Cl|CASE}} 50: {{Cl|PRINT}} "50 will be shown."
{{Cl|CASE}} 100: {{Cl|PRINT}} "This will be shown. (a is 100)"
{{Cl|PRINT}} "(and this)"
{{Cl|CASE}} 150: {{Cl|PRINT}} "150 will be shown."
{{Cl|CASE IS}} &lt; 150: {{Cl|PRINT}} "Less than 150 will be shown. (a which is 100 is under 150)"
{{Cl|CASE}} 50 {{Cl|TO}} 150: {{Cl|PRINT}} "50 to 150 will be shown. (a which is 100 is between 50 TO 150)"
{{Cl|END SELECT}}
{{CodeEnd}}
''Returns:''
{{OutputStart}}
This will be shown. (a is 100)
(and this)
{{OutputEnd}}
: ''Explanation:'' [[SELECT CASE]] compares the variable's value to each descending {{KW|CASE}} until ONE is true, executes the [[CASE]] code and exits the SELECT CASE. [[CASE]] statements should be placed in a increasing or decreasing order for the best results.
: What happens is that since 5 isn't 100 then the code until the next CASE is ignored, the same obviously goes for 10 and 50 but then comes 100 which is what {{Parameter|a}} is so the code in that [[CASE]] is executed.
:* A [[CASE]] can list several values separated by commas for the same program option to be executed.
:* [[CASE IS]] is used when we need to compare the value to a conditional expression range such as a value is "=" equal to, "&lt;" less than, ">" greater than, "&lt;>" not equal to or [[NOT]] a value.
:* A [[CASE]] range can be specified (in the example; 50 [[TO]] 150) if needed.
&lt;center>''Note:'' A [[SELECT CASE]] block has to end with [[END SELECT]].&lt;/center>
{{PageSeeAlso}}
* [[CASE ELSE]], [[CASE IS]]
* [[SELECT CASE]], [[END SELECT]]
* [[IF...THEN]]
{{PageNavigation}}
#REDIRECT [[SELECT CASE]]
<

View file

@ -1,62 +1,2 @@
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE ELSE]] is used in a [[SELECT CASE]] procedure as an alternative if no other [[CASE]] statements are true.
{{PageDescription}}
* [[CASE ELSE]] should be listed at the bottom of the case list as it will supersede any case statements after it.
* Use it as a "safety net" or as an alternative for all values not covered in the [[CASE]] statements.
{{PageExamples}}
''Example 1:''
{{CodeStart}}
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} {{Cl|IS}} &lt; 99: {{Cl|PRINT}} "a is &lt; 99"
{{Cl|CASE}} 99: {{Cl|PRINT}} "a is 99"
{{Cl|CASE}} {{Cl|IS}} > 100: {{Cl|PRINT}} "a is > 100"
{{Cl|CASE ELSE}}
{{Cl|PRINT}} "a is 100"
{{Cl|END SELECT}}
{{CodeEnd}}
{{OutputStart}}
a is 100
{{OutputEnd}}
''Example 2:''
{{CodeStart}}
a = 100
{{Cl|SELECT CASE}} a
{{Cl|CASE}} 10: {{Cl|PRINT}} "a is 10"
{{Cl|CASE}} 20: {{Cl|PRINT}} "a is 20"
{{Cl|CASE}} 30: {{Cl|PRINT}} "a is 30"
{{Cl|CASE ELSE}}: {{Cl|PRINT}} "a is something other than 10, 20 and 30"
{{Cl|END SELECT}}
{{CodeEnd}}
{{OutputStart}}
a is something other than 10, 20 and 30
{{OutputEnd}}
{{PageSeeAlso}}
*[[SELECT CASE]]
*[[IF...THEN]], [[ELSE]]
{{PageNavigation}}
#REDIRECT [[SELECT CASE]]
<

View file

@ -1,27 +1,2 @@
#REDIRECT [[SELECT CASE#allCASES]]
[[CASE IS]] can be used in a [[SELECT CASE]] routine where you need to use relational conditional expressions.
{{PageSyntax}}
: [[CASE IS]] '''{=|&lt;|>|&lt;=|>=|&lt;>|[[NOT]]} {{Parameter|expression}}'''
{{PageDescription}}
* [[AND (boolean)|AND]] can be used to add extra conditions to a [[CASE IS]] statement evaluation.
* [[OR (boolean)|OR]] can be used to add alternate conditions to a [[CASE IS]] statement evaluation.
* Parenthesis are allowed in [[CASE IS]] statements to clarify an evaluation.
* [[CASE IS]] > 100 uses the greater than expression.
* [[CASE IS]] &lt;= 100 uses the less than or equal to expression.
* [[CASE IS]] &lt;> 100 uses the not equal to expression(same as [[NOT]] 100).
{{Template:RelationalTable}}
{{PageSeeAlso}}
* [[CASE]], [[CASE ELSE]]
* [[SELECT CASE]]
{{PageNavigation}}
#REDIRECT [[SELECT CASE]]
<

35
internal/help/CDBL.txt Normal file
View file

@ -0,0 +1,35 @@
[[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}}
<

1
internal/help/CDECL.txt Normal file
View file

@ -0,0 +1 @@
<

View file

@ -1,14 +1,14 @@
[[CHAIN]] is used to change seamlessly from one module to another one in a program.
{{PageLegacySupport}}
==Legacy support==
* The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 [[CHAIN]] 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.'''
{{PageSyntax}}
: [[CHAIN]] {{Parameter|moduleName$}}
{{PageParameters}}
{{Parameters}}
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
@ -17,12 +17,16 @@
* 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 [[Variable Types|type]]s and names.
* 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}} '' ''
@ -36,6 +40,8 @@
* [[RUN]]
* [[COMMON]], [[COMMON SHARED]]
* [[SHARED]]
* [[LINKed or Merged Modules]]
{{PageNavigation}}
<

View file

@ -60,3 +60,4 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
{{PageNavigation}}
<

View file

@ -84,3 +84,4 @@ Send$ = ""
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[CINT]] function rounds decimal point numbers up or down to the nearest [[I
: {{Parameter|value%}} = [[CINT]]({{Parameter|expression}})
{{PageParameters}}
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
@ -33,3 +33,4 @@ a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes
: [[CIRCLE]] [{{KW|STEP}}]'''('''{{Parameter|column}}''',''' {{Parameter|row}}'''),''' {{Parameter|radius%}}''',''' [{{Parameter|drawColor%}}][, {{Parameter|startRadian!}}, {{Parameter|stopRadian!}}] [, {{Parameter|aspect!}}]
{{PageParameters}}
{{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.
@ -143,3 +143,4 @@ previoushour% = hours% 'hold current hour for later use
* [[Alternative circle routine]] {{text|(member-contributed program)}}
{{PageNavigation}}
<

View file

@ -36,3 +36,4 @@ array(5) = 23
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[L
: {{Parameter|value&amp;}} = [[CLNG]]({{Parameter|expression}})
{{PageParameters}}
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
@ -34,3 +34,4 @@ The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[L
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@
: [[CLOSE]] [{{Parameter|fileNumber}}[, ...]]
{{PageParameters}}
{{Parameters}}
* {{Parameter|fileNumber}} indicates the file or list of file numbers to close. When not specified, all open files are closed.
@ -27,3 +27,4 @@
{{PageNavigation}}
<

View file

@ -5,9 +5,9 @@ The [[CLS]] statement clears the [[_DEST|current write page]].
: [[CLS]] [{{Parameter|method%}}] [, {{Parameter|bgColor&amp;}}]
{{PageParameters}}
{{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 - 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.
@ -31,7 +31,7 @@ The [[CLS]] statement clears the [[_DEST|current write page]].
{{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)
K$ = {{Cl|INPUT$}}(1
{{CodeEnd}}
:''Explanation:'' [[_PRINTMODE]] can be used with [[PRINT]] or [[_PRINTSTRING]] to make the text or the text background transparent.
@ -56,3 +56,4 @@ i = {{Cl|_LOADIMAGE}}('''"qb64_trans.png"''') 'see note below examples to get th
{{PageNavigation}}
<

View file

@ -10,8 +10,6 @@ The [[COLOR]] statement is used to change the foreground and background colors f
* To change the {{Parameter|background&amp;}} color only, use a comma and the desired color. Ex: [[COLOR]] , {{Parameter|background&amp;}}
* 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.
* [[COLOR]] works when outputting text to [[$CONSOLE]].
** On macOS, colors in console mode will not match the VGA palette. See [https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit 8-bit ANSI colors]
==Screen Mode Attributes==
@ -139,7 +137,7 @@ alpha$ = "FF" 'solid alpha colors only
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} ' used for fullscreen instead of window
{{Cl|COLOR}} 30, 6: {{Cl|LOCATE}} 12, 4: {{Cl|PRINT}} "Hello!" '' ''
{{CodeEnd}}
:''Result:'' Hello! is printed in flashing high intensity yellow with brown background behind text only when in QBasic [[_FULLSCREEN|fullscreen]].
:''Result:'' Hello! is printed in flashing high intensity yellow with brown background behind text only when in Qbasic [[_FULLSCREEN|fullscreen]].
''Example 4:'' Using [[CLS]] after setting the background color in SCREEN 0 to make the color cover the entire screen.
@ -238,3 +236,4 @@ K$ = {{Cl|INPUT$}}(1)
{{PageNavigation}}
<

View file

@ -71,3 +71,4 @@ count = count - 1 'save the number of parameters sent to this program when run
{{PageNavigation}}
<

View file

@ -1,6 +1,6 @@
[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules.
{{PageLegacySupport}}
==Legacy support==
* The multi-modular technique goes back to when QBasic and QuickBASIC had module size constraints. In QB64 [[COMMON]] 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.'''
@ -23,3 +23,4 @@
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[CONST]] statement globally defines one or more named numeric or string val
: [[CONST]] {{Parameter|constantName}} = {{Parameter|value}}[, ...]
{{PageParameters}}
{{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.
@ -14,8 +14,8 @@ The [[CONST]] statement globally defines one or more named numeric or string val
{{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 or [[FUNCTION]] return values.
** The exception to the above are the internal functions: [[_PI]], [[_ACOS]], [[_ASIN]], [[_ARCSEC]], [[_ARCCSC]], [[_ARCCOT]], [[_SECH]], [[_CSCH]], [[_COTH]], [[COS]], [[SIN]], [[TAN]], [[LOG]], [[EXP]], [[ATN]], [[_D2R]], [[_D2G]], [[_R2D]], [[_R2G]], [[_G2D]], [[_G2R]], [[ABS]], [[SGN]], [[INT]], [[_ROUND]], [[_CEIL]], [[FIX]], [[_SEC]], [[_CSC]], [[_COT]], [[ASC]], [[_RGB32]], [[_RGBA32]], [[_RGB]], [[_RGBA]], [[_RED32]], [[_GREEN32]], [[_BLUE32]], [[_ALPHA32]], [[_RED]], [[_GREEN]], [[_BLUE]], [[_ALPHA]] (See Example 2 below).
* 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.
@ -69,3 +69,4 @@ Enter the radius of a circle or zero to quit? ''0''
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@ The [[COS]] function returns the horizontal component or the cosine of an angle
: {{Parameter|value!}} = [[COS]]({{Parameter|radianAngle!}})
{{PageParameters}}
{{Parameters}}
* The {{Parameter|radianAngle!}} must be measured in radians.
@ -104,3 +104,4 @@ DEGREES% = RADIANS * 180 / PI = 45
{{PageNavigation}}
<

View file

@ -5,7 +5,7 @@
: {{Parameter|singleValue!}} = [[CSNG]]({{Parameter|expression}})
{{PageParameters}}
{{Parameters}}
* {{Parameter|expression}} is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
@ -30,3 +30,4 @@
{{PageNavigation}}
<

View file

@ -48,3 +48,4 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
{{PageNavigation}}
<

View file

@ -48,3 +48,4 @@ The string above, decoded using CVD: 77000.24523213
{{PageNavigation}}
<

View file

@ -37,3 +37,4 @@ The string above, decoded using CVDMBF: 77000.24523213
{{PageNavigation}}
<

View file

@ -63,3 +63,4 @@ tmp4$ = " CVI Total = ##### "
{{PageNavigation}}
<

View file

@ -40,3 +40,4 @@ Y&amp; = {{Cl|CVL}}(N$) '' ''
{{PageNavigation}}
<

View file

@ -35,3 +35,4 @@ The string above, decoded using CVS: 700.2213
{{PageNavigation}}
<

View file

@ -35,3 +35,4 @@ The string above, decoded using CVSMBF: 700.2213
{{PageNavigation}}
<

View file

@ -20,3 +20,4 @@ A '''colon''' can be used to separate two unrelated procedure statements on the
{{PageNavigation}}
<

View file

@ -79,3 +79,4 @@ mydata2:
{{PageNavigation}}
<

View file

@ -62,9 +62,10 @@ Today is Wednesday, June 2, 2010
{{PageSeeAlso}}
* [[TIME$]]
* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]]
* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]]
{{PageNavigation}}
<

View file

@ -0,0 +1 @@
<

View file

@ -0,0 +1 @@
<

View file

@ -18,7 +18,7 @@
* ''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 with the format you wish, but '''if the size of the parameter list does not match the size expected within the library, then your code will probably cause a GPF (General Protection Fault).
* '''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.
@ -26,9 +26,10 @@
* '''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.'''
{{PageAvailability}}
* Version 0.923 and up (Windows).
* Version 0.94 and up (Linux and macOS).
==Availability==
* '''Version 0.923 and up (Windows)'''
* '''Version 0.94 and up (Linux and macOS)'''
{{PageExamples}}
@ -96,8 +97,9 @@ QuickUTF16toUTF32$ = b$
* [[SUB]], [[FUNCTION]]
* [[BYVAL]], [[ALIAS]]
* [[_OFFSET (function)]], [[_OFFSET]] {{text|(variable type)}}
* [[C Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[C Libraries]], [[SDL Libraries]], [[DLL Libraries]], [[Windows Libraries]]
* [[Port Access Libraries]]
{{PageNavigation}}
<

View file

@ -10,7 +10,7 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
: '''END DECLARE'''
{{PageParameters}}
{{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.
@ -33,22 +33,61 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
* 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 guarantee any troubleshooting help.'''
* '''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:'' Don't know if a C function is defined by C++ or QB64? Try using empty quotes.
''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.
&lt;center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''&lt;/center>
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&amp;, {{Cl|BYVAL}} row&amp;)
{{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&amp; ({{Cl|BYVAL}} value&amp;)
{{Cl|END DECLARE}} '' ''
{{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: Which 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.'''
: '''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.'''
&lt;center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''&lt;/center>
&lt;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.'''&lt;/center>
''See also:''
@ -61,3 +100,4 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
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.
{{PageLegacySupport}}
==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'''.
@ -14,11 +14,11 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec
* {{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 [[Variable Types|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).
* [[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.'''
{{PageQBasic}}
==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.
@ -38,3 +38,4 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
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.
{{PageLegacySupport}}
==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'''.
@ -14,12 +14,12 @@ The [[DEFINT]] statement defines all variables with names starting with the spec
* {{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 [[Variable Types|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).
* [[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.'''
{{PageQBasic}}
==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.
@ -39,3 +39,4 @@ The [[DEFINT]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
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.
{{PageLegacySupport}}
==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'''.
@ -14,12 +14,12 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec
* {{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 [[Variable Types|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).
* [[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.'''
{{PageQBasic}}
==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.
@ -39,3 +39,4 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables.
{{PageLegacySupport}}
==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'''.
@ -15,11 +15,11 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec
* {{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 [[Variable Types|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).
* [[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.'''
{{PageQBasic}}
==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.
@ -39,3 +39,4 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
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.
{{PageLegacySupport}}
==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'''.
@ -14,11 +14,11 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec
* {{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 [[Variable Types|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).
* [[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 ($).'''
{{PageQBasic}}
==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.
@ -38,3 +38,4 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,7 @@
[[DEF SEG]] is used to define the area in memory to access QB64's emulated conventional memory.
{{PageLegacySupport}}
==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.'''
@ -19,7 +19,7 @@
&lt;!--
{{PageExamples}}
''Example:'' In a QBasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
''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
@ -70,3 +70,4 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{PageNavigation}}
<

View file

@ -2,15 +2,11 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
{{PageSyntax}}
::''To declare variables:''
:::[[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]]
::''Syntax 1:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]]
::''To declare arrays:''
:::[[DIM]] [{{KW|SHARED}}] ''array([lowest% {{KW|TO}}] highest%])''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
::''Syntax 2:'' [[DIM]] [{{KW|SHARED}}] ''array(lowest% [{{KW|TO}}) highest%])''[{suffix| {{KW|AS}} ''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)''...]
:'' '''QB64''' Syntax:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
{{PageDescription}}
@ -30,8 +26,7 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
** [[_FLOAT]] (or use variable suffix '''##''')
** [[_OFFSET]] (or use variable suffix '''%&amp;''')
** 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.
* '''Note: When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* 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.
@ -89,13 +84,6 @@ x = 1 'x is a {{Cl|SINGLE}} variable
: ''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]]
@ -107,3 +95,4 @@ x = 1 'x is a {{Cl|SINGLE}} variable
{{PageNavigation}}
<

View file

@ -25,7 +25,6 @@
::[[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.
* Use [[_CONTINUE]] to skip the remaining lines in the iteration without leaving the loop.
** 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.
@ -37,9 +36,9 @@
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}
{{Cl|DO}} {{Cl|WHILE}} {{Cl|INKEY$}} &lt;> "": {{Cl|LOOP}} ' checks evaluation before running loop code
DO WHILE {{Cl|INKEY$}} &lt;> "": LOOP ' checks evaluation before running loop code
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|WHILE}} {{Cl|INKEY$}} &lt;> "" ' checks evaluation after one run of loop code
DO: LOOP WHILE INKEY$ &lt;> "" ' checks evaluation after one run of loop code
{{CodeEnd}}
@ -47,9 +46,9 @@
''Example 2:'' Using UNTIL to clear the keyboard buffer.
{{CodeStart}}
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|INKEY$}} = "": {{Cl|LOOP}} ' checks evaluation before running loop code
DO UNTIL {{Cl|INKEY$}} = "": LOOP ' checks evaluation before running loop code
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
{{CodeEnd}}
@ -65,70 +64,70 @@ CheckScreen filenm$
{{Cl|DEFINT}} A-Z
{{Cl|SUB}} CheckScreen (Filename$) 'find Screen mode (12 or 13) and image dimensions
{{Cl|DIM}} Bsv {{Cl|AS}} {{Cl|STRING}} * 1
{{Cl|DIM}} Header {{Cl|AS}} {{Cl|STRING}} * 6
DIM Bsv AS {{Cl|STRING}} * 1
DIM Header AS STRING * 6
Scr = 0: MaxColors = 0
{{Cl|OPEN}} Filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1
{{Cl|OPEN}} Filename$ FOR {{Cl|BINARY}} AS #1
{{Cl|GET}} #1, , Bsv '1 check for small 2 character
{{Cl|GET}} #1, , Header '2 - 7 rest of file header
GET #1, , Header '2 - 7 rest of file header
{{Cl|IF}} Bsv &lt;> {{Cl|CHR$}}(253) {{Cl|THEN}} ' small 2 character denotes a {{Cl|BSAVE}} file
{{Cl|COLOR}} 12: {{Cl|LOCATE}} 15, 33: {{Cl|PRINT}} "Not a BSAVE file!": {{Cl|SLEEP}} 3: {{Cl|EXIT SUB}}
{{Cl|END IF}}
IF Bsv &lt;> {{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
{{Cl|GET}} #1, , widN '8 no color info bmp sizes
{{Cl|GET}} #1, , depN '9 " " "
GET #1, , widN '8 no color info bmp sizes
GET #1, , depN '9 " " "
{{Cl|DO}}
{{Cl|IF}} widN > 63 {{Cl|OR}} depN > 63 {{Cl|THEN}} {{Cl|EXIT DO}} ' width and depth already found
DO
IF widN > 63 OR depN > 63 THEN {{Cl|EXIT DO}} ' width and depth already found
{{Cl|FOR}} i = 10 {{Cl|TO}} 55 'check for Screen 12 embedded colors
{{Cl|GET}} #1, , RGB
FOR i = 10 TO 55 'check for Screen 12 embedded colors
GET #1, , RGB
tot12&amp; = tot12&amp; + RGB
'PRINT i; RGB; : SOUND 300, 1 'test sound slows loop in QB
{{Cl|IF}} RGB > 63 {{Cl|OR}} RGB &lt; 0 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|IF}} i = 55 {{Cl|AND}} tot12&amp; = 0 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|NEXT}}
IF RGB > 63 OR RGB &lt; 0 THEN {{Cl|EXIT DO}}
IF i = 55 AND tot12&amp; = 0 THEN {{Cl|EXIT DO}}
NEXT
{{Cl|GET}} #1, , wid12 '56
{{Cl|GET}} #1, , dep12 '57
{{Cl|IF}} wid12 > 63 {{Cl|OR}} dep12 > 63 {{Cl|THEN}} {{Cl|EXIT DO}}
GET #1, , wid12 '56
GET #1, , dep12 '57
IF wid12 > 63 OR dep12 > 63 THEN {{Cl|EXIT DO}}
{{Cl|FOR}} i = 58 TO 775 'check for Screen 13 embedded colors
{{Cl|GET}} #1, , RGB
FOR i = 58 TO 775 'check for Screen 13 embedded colors
GET #1, , RGB
tot13&amp; = tot13&amp; + RGB
'PRINT i; RGB; : SOUND 300, 1 'test
{{Cl|IF}} RGB > 63 {{Cl|OR}} RGB &lt; 0 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|IF}} i = 775 {{Cl|AND}} tot13&amp; = 0 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|NEXT}}
{{Cl|GET}} #1, , wid13 '776
{{Cl|GET}} #1, , dep13 '777
{{Cl|LOOP}} {{Cl|UNTIL}} 1 = 1 'TRUE statement exits one-time LOOP
{{Cl|CLOSE}} #1
IF RGB > 63 OR RGB &lt; 0 THEN {{Cl|EXIT DO}}
IF i = 775 AND tot13&amp; = 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
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 25
COLOR 14: LOCATE 10, 25
{{Cl|SELECT CASE}} i
{{Cl|CASE IS}} &lt; 56:
{{Cl|IF}} widN > 640 {{Cl|THEN}}
IF widN > 640 THEN
Scr = 13: MaxColors = 0
{{Cl|PRINT}} "Default Screen 13:"; widN \ 8; "X"; depN
{{Cl|ELSE}}
{{Cl|LOCATE}} 10, 15
{{Cl|PRINT}} "Screen 12 ("; widN; "X"; depN; ") OR 13 ("; widN \ 8; "X"; depN; ")"
{{Cl|DO}}: {{Cl|SOUND}} 600, 4
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 12, 23 'ask if no data found. Prevents ERROR opening in wrong mode
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 = {{Cl|VAL}}(Scrn$)
{{Cl|LOOP}} {{Cl|UNTIL}} Scr = 12 {{Cl|OR}} Scr = 13
{{Cl|END IF}}
{{Cl|IF}} Scr = 12 {{Cl|THEN}} MaxColors = 0: PWidth = widN: PDepth = depN
{{Cl|IF}} Scr = 13 {{Cl|THEN}} MaxColors = 0: PWidth = widN \ 8: PDepth = depN
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
{{Cl|PRINT}} "Custom Screen 12:"; wid12; "X"; dep12
PRINT "Custom Screen 12:"; wid12; "X"; dep12
Scr = 12: MaxColors = 16: PWidth = wid12: PDepth = dep12
{{Cl|CASE}} 776: {{Cl|PRINT}} "Custom Screen 13:"; wid13 \ 8; "X"; dep13
{{Cl|CASE}} 776: PRINT "Custom Screen 13:"; wid13 \ 8; "X"; dep13
Scr = 13: MaxColors = 256: PWidth = wid13 \ 8: PDepth = dep13
{{Cl|END SELECT}}
@ -149,3 +148,4 @@ CheckScreen filenm$
{{PageNavigation}}
<

View file

@ -16,7 +16,7 @@
* '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.'''
{{PageQBasic}}
==QBasic/QuickBASIC==
* Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5.
@ -29,3 +29,4 @@
{{PageNavigation}}
<

View file

@ -166,3 +166,4 @@ k = {{Cl|_RGB}}(80, 255, 80)
{{PageNavigation}}
<

View file

@ -1,4 +1,4 @@
The '''$''' is used to denote QBasic [[Metacommand]]s or as a [[STRING]] variable type suffix.
The '''$''' is used to denote Qbasic [[Metacommand]]s or as a [[STRING]] variable type suffix.
@ -7,7 +7,7 @@ The '''$''' is used to denote QBasic [[Metacommand]]s or as a [[STRING]] variabl
* [[$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.
* [[$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]].
@ -18,3 +18,4 @@ The '''$''' is used to denote QBasic [[Metacommand]]s or as a [[STRING]] variabl
{{PageNavigation}}
<

View file

@ -60,3 +60,4 @@ IF a = 3 THEN a = 5 ELSE a = 3
{{PageNavigation}}
<

View file

@ -53,3 +53,4 @@ END IF
{{PageNavigation}}
<

View file

@ -50,3 +50,4 @@ Press any key to continue...
{{PageNavigation}}
<

View file

@ -1,4 +1,4 @@
The [[ENVIRON$]] function returns a [[STRING]] environmental value from the Operating System's environmental settings list.
The [[ENVIRON$]] function returns a [[STRING]] environmental value from '''Windows'''' environmental settings list.
{{PageSyntax}}
@ -8,7 +8,7 @@ The [[ENVIRON$]] function returns a [[STRING]] environmental value from the Oper
{{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 (examples based on Windows):
* {{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.
@ -117,7 +117,7 @@ Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
''See also:''
* [[ENVIRON]] (statement), [[_ENVIRONCOUNT]]
* [[ENVIRON]] (statement)
* [[_DEVICES]], [[_DEVICE$]]
* [[_LASTBUTTON]], [[_OS$]]
* [[Windows Environment]]
@ -125,3 +125,4 @@ Q$ = {{Cl|CHR$}}(34) '=== Write URL Shortcut file info.
{{PageNavigation}}
<

View file

@ -11,13 +11,13 @@ The [[ENVIRON]] statement is used to temporarily set or change an environmental
** 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.
* The [[_ENVIRONCOUNT]] function returns the number of key/value pairs that currently exist.
* Any changes made at runtime are discarded when your program ends.
{{PageSeeAlso}}
* [[ENVIRON$]], [[_ENVIRONCOUNT]]
* [[ENVIRON$]]
* [[Windows Environment]]
{{PageNavigation}}
<

View file

@ -22,3 +22,4 @@ The [[EOF]] function indicates that the end of a file has been reached.
{{PageNavigation}}
<

View file

@ -19,3 +19,4 @@ The [[EQV]] operator returns a value based on the ''equivalence'' of two conditi
{{PageNavigation}}
<

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