1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 12:40:36 +00:00

Merge pull request #75 from QB64-Phoenix-Edition/wiki-dev

Wiki dev
- suggestions noted in my TODO list
- will talk back to you later on Discord, thanks Matt
This commit is contained in:
Roland Heyder 2022-05-22 11:57:38 +02:00 committed by GitHub
commit ccd72ab277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
958 changed files with 10356 additions and 6492 deletions

View file

@ -1,46 +0,0 @@
The [[$ASSERTS]] metacommand enables debug tests with the [[_ASSERT]] macro.
{{PageSyntax}}
:[[$ASSERTS]]
:[[$ASSERTS]]:CONSOLE
{{PageDescription}}
* If an error message is passed to the [[_ASSERT]] statement, it is displayed in the console window if [[$ASSERTS|$ASSERTS:CONSOLE]] is used.
==Availability==
* '''Version 1.4 and up'''.
{{PageExamples}}
''Example:'' Adding test checks for parameter inputs in a function.
{{CodeStart}}
{{Cl|$ASSERTS}}:CONSOLE
{{Cl|DO}}
a = {{Cl|INT}}({{Cl|RND}} * 10)
b$ = myFunc$(a)
{{Cl|PRINT}} a, , b$
{{Cl|_LIMIT}} 3
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_KEYHIT}}
{{Cl|FUNCTION}} myFunc$ (value {{Cl|AS}} {{Cl|SINGLE}})
{{Cl|_ASSERT}} value > 0, "Value cannot be zero"
{{Cl|_ASSERT}} value <= 10, "Value cannot exceed 10"
{{Cl|IF}} value > 1 {{Cl|THEN}} plural$ = "s"
myFunc$ = {{Cl|STRING$}}(value, "*") + {{Cl|STR$}}(value) + " star" + plural$ + " :-)"
{{Cl|END}} {{Cl|FUNCTION}}
{{CodeEnd}}
{{PageSeeAlso}}
* [[_ASSERT]]
* [[$CHECKING]]
* [[Relational Operations]]
{{PageNavigation}}
<

View file

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

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:06:53}}
The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
@ -24,4 +26,4 @@ The [[$CHECKING]] metacommand turns C++ event checking ON or OFF.
{{PageNavigation}}
<

View file

@ -1,41 +0,0 @@
[[$COLOR]] is a metacommand that adds named color [[CONST|constants]] in a program.
{{PageSyntax}}
: [[$COLOR]]:0
: [[$COLOR]]:32
{{PageDescription}}
* [[$COLOR]]:0 adds [[CONST|constants]] for colors 0-15. The actual constant names can be found in the file '''source/utilities/color0.bi'''.
* [[$COLOR]]:32 adds [[CONST|constants]] for 32-bit colors, similar to HTML color names. The actual constant names can be found in the file '''source/utilities/color32.bi'''.
* [[$COLOR]] is a shorthand to manually using [[$INCLUDE]] pointing to the files listed above.
* Not compatible with [[$NOPREFIX]].
{{PageExamples}}
''Example 1:'' Adding named color constants for SCREEN 0:
{{CodeStart}}
{{Cl|$COLOR}}:0
{{Cl|COLOR}} BrightWhite, Red
{{Cl|PRINT}} "Bright white on red."
{{CodeEnd}}
''Example 2:'' Adding named color constants for 32-bit modes:
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 400, 32)
{{Cl|$COLOR}}:32
{{Cl|COLOR}} CrayolaGold, DarkCyan
{{Cl|PRINT}} "CrayolaGold on DarkCyan."
{{CodeEnd}}
{{PageSeeAlso}}
* [[COLOR]], [[SCREEN]]
* [[_NEWIMAGE]], [[$INCLUDE]]
* [[Metacommand]]
{{PageNavigation}}
<

View file

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

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:07:11}}
The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throughout a QB64 program module.
@ -10,7 +12,7 @@ The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throu
* [[_DEST]] [[_CONSOLE]] may be used to send screen output to the console window.
* [[_SCREENHIDE]] and [[_SCREENSHOW]] can be used to hide or show the main program window.
* [[_DELAY]] or [[SLEEP]] can be used to allow the console window to be set in front of the main program window.
* '''QB64 [[Metacommand]]s are not commented out with ' or REM, differently from Qbasic metacommands'''
* '''QB64 [[Metacommand]]s are not commented out with ' or REM, unlike QuickBASIC metacommands'''
* Change the title of the [[$CONSOLE]] windows created using [[_CONSOLETITLE]]
* '''Note:''' Text can be copied partially or totally from console screens in Windows by highlighting and using the title bar menu.
:: To copy console text output, right click the title bar and select ''Edit'' for ''Mark'' to highlight and repeat to ''Copy''
@ -18,7 +20,7 @@ The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throu
{{PageExamples}}
''Example 1:'' Hiding and displaying a console window. Use [[_DELAY]] to place console in front of main program window.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$CONSOLE}}
{{Cl|_DELAY}} 4
@ -27,28 +29,28 @@ The [[$CONSOLE]] [[Metacommand]] creates a console window that can be used throu
{{Cl|_CONSOLE}} ON
{{Cl|_DEST}} {{Cl|_CONSOLE}}
{{Cl|PRINT}} "Close this console window or click main window and press a key!" '' ''
{{Cl|PRINT}} "Close this console window or click main window and press a key!"
{{CodeEnd}}
''Example 2:'' How to use a Console window to copy screen output using the ''Edit'' menu by right clicking the console title bar.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$CONSOLE}}
{{Cl|_DEST}} {{Cl|_CONSOLE}}
c&amp;&amp; = -1: d&amp; = -1: e% = -1: f%% = -1
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&amp;)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&amp;&amp;)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
hx$ = {{Cl|HEX$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" '' ''
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{CodeEnd}}
{{OutputStart}}Max hex _BYTE = FF with 2 digits = 255
Max hex INTEGER = FFFF with 4 digits = 65535
@ -74,4 +76,4 @@ Max hex _INTEGER64 = FFFFFFFFFFFFFFFF with 16 digits =-1
{{PageNavigation}}
<

View file

@ -1 +0,0 @@
<

View file

@ -0,0 +1,44 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:07:28}}
'''$DEBUG''' is precompiler [[Metacommand|metacommand]], which enables debugging features, allowing you to step through your code running line by line and to inspect variables and change their values in real time.
{{PageSyntax}}
:[[$DEBUG]]
{{PageDescription}}
* '''$DEBUG''' injects extra code in the resulting binary, allowing the IDE to control the execution flow of your program.
* When '''$DEBUG''' is used, the IDE will connect to your running program using a local TCP/IP connection.
** You may get a prompt from your Operating System regarding this, so it may be necessary to allow the IDE to receive connections.
** No external connections are created, and your running program will only attempt to connect locally to the IDE.
* The default TCP/IP port starts at 9001. Multiple running instances of the IDE will attempt to open ports 9002 and up.
** You can change the base port in the Debug menu.
* The metacommand is supposed to be removed once your program is ready for release, although leaving it in won't have any effect if your program isn't run from the IDE.
** The only drawback of leaving the metacommand in is that your binary will end up being larger than required.
== $DEBUG Mode Operation ==
* To start execution in pause mode, you can use '''F7''' or '''F8'''.
* There will be an arrow next to the line number where execution is paused, indicating the next line that will be run.
* When you enable '''$DEBUG''' mode, you can set breakpoints by clicking the line number at which you wish to stop execution. This can also be achieved by using the '''F9''' key.
** Breakpoints are indicated by a red dot next to the line number.
** To clear all breakpoints, hit '''F10'''.
* To skip a line during execution, shift-click a line number
** Lines marked for skipping are indicated by an exclamation mark next to the line number.
* '''F4''' opens the Variable List dialog, which allows you to add variables to the Watch List.
* During execution, the Variable List dialog also allows you to set the values of variables and also to create Watchpoints.
* Watchpoints halt execution, similarly to breakpoints, but do so when a variable matches the condition you specify.
** You can use relational operators (=, <>, >=, <=, >, <) to create watchpoint conditions.
* After a breakpoint or a watchpoint is reached, '''F5''' can be used to continue execution.
* '''F6''' can be used when the execution pointer is inside a sub/function. When used, execution will proceed until the procedure is ended.
* '''F7''' can be used to run line by line, and can be used to debug code inside subs/functions (Step Into).
* '''F8''' can be used to run line by line without entering sub/function calls (Step Over).
* '''F12''' can be used to show the current call stack (which procedure calls led to the current line).
{{PageSeeAlso}}
* [[Metacommand]]s
{{PageNavigation}}

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:56}}
The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (changeable) arrays.
@ -16,7 +18,7 @@ The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (cha
{{PageExamples}}
''Example:'' [[REDIM]]ing a $DYNAMIC array using [[_PRESERVE]] to retain previous array values.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|REM}} {{Cl|$DYNAMIC}} 'create dynamic arrays only
{{Cl|DIM}} array(10) 'create array with 11 elements
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} 10
@ -27,7 +29,7 @@ The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (cha
{{Cl|FOR...NEXT|FOR}} i = 10 {{Cl|TO}} 20
{{Cl|PRINT}} array(i);
{{Cl|NEXT}}
{{Cl|END}} '' ''
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}0 1 2 3 4 5 6 7 8 9 10
@ -44,4 +46,4 @@ The [[$DYNAMIC]] [[Metacommand|metacommand]] allows the creation of dynamic (cha
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:03}}
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
@ -25,7 +27,7 @@
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
@ -45,7 +47,7 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''Example 2:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
@ -64,4 +66,4 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:02}}
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
@ -25,7 +27,7 @@
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
@ -45,7 +47,7 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''Example 2:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
@ -64,4 +66,4 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:05}}
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
@ -25,7 +27,7 @@
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
@ -45,7 +47,7 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''Example 2:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
@ -64,4 +66,4 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
{{PageNavigation}}
<

View file

@ -1 +0,0 @@
<

View file

@ -0,0 +1,36 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:06}}
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.
{{PageDescription}}
* If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with [[$IF]].
* An [[$ERROR]] directive not inside an [[$IF]] (or [[$ELSEIF]]) block is useless because the program will never compile.
{{PageExamples}}
{{CodeStart}}
{{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN
{{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above
{{Cl|$END IF}}
{{CodeEnd}}
''Output'': 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

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:10}}
'''$EXEICON''' pre-compiler metacommand embeds a designated icon file into the compiled EXE file to be viewed in Windows Explorer.
@ -11,7 +13,7 @@
{{PageDescription}}
* Calling [[_ICON]] without an {{Parameter|imageHandle&amp;}} uses the embeded icon, if available.
* Calling [[_ICON]] without an {{Parameter|imageHandle&}} uses the embeded icon, if available.
** Starting with '''build 20170906/64''', the window will automatically use the icon embedded by [[$EXEICON]], without having to call _ICON.
* '''[[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]'''.
@ -31,4 +33,4 @@
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:38}}
'''$IF''' is precompiler [[Metacommand|metacommand]], which determines which sections of code inside its blocks are included into the final code for compliing.
@ -25,7 +27,7 @@
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$LET}} ScreenMode = 32
{{Cl|$IF}} ScreenMode = 0 THEN
{{Cl|CONST}} Red = 4
@ -45,7 +47,7 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
''Example 2:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$IF}} WIN THEN
{{Cl|CONST}} Slash = "\"
{{Cl|$ELSE}}
@ -64,4 +66,4 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:13:39}}
[[$INCLUDE]] is a metacommand that is used to insert a source code file into your program which is then executed at the point of the insertion.
@ -40,4 +42,4 @@
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:08:51}}
[[$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.
@ -25,4 +27,4 @@
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:09:37}}
The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be used without the leading underscore (_).
@ -14,8 +16,9 @@ The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be use
* [[$NOPREFIX]] must be the first line in a program.
==Availability==
* '''Version 1.4 and up'''.
{{PageAvailability}}
* '''QB64 1.4 and up''' (QB64 Team)
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
{{PageSeeAlso}}
@ -24,4 +27,4 @@ The [[$NOPREFIX]] metacommand allows all QB64 functions and statements to be use
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:10:13}}
The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can be resized by the user.
@ -27,7 +29,7 @@ The [[$RESIZE]] [[Metacommand|metacommand]] determines if a program window can b
{{Cl|_DISPLAY}}
' CLEAR _RESIZE FLAG BY READING IT ONCE
temp&amp; = {{Cl|_RESIZE (function)|_RESIZE}}
temp& = {{Cl|_RESIZE (function)|_RESIZE}}
DO
@ -45,9 +47,9 @@ DO
{{Cl|_DISPLAY}}
k&amp; = {{Cl|_KEYHIT}}
k& = {{Cl|_KEYHIT}}
{{Cl|LOOP}} {{Cl|UNTIL}} k&amp; = 27 {{Cl|OR (boolean)|OR}} k&amp; = 32
{{Cl|LOOP}} {{Cl|UNTIL}} k& = 27 {{Cl|OR (boolean)|OR}} k& = 32
{{Cl|SYSTEM}}
@ -112,4 +114,4 @@ DO
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:10:28}}
The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main program window throughout a program.
@ -12,13 +14,13 @@ The [[$SCREENHIDE]] [[Metacommand|metacommand]] can be used to hide the main pro
{{PageExamples}}
''Example:'' Hiding a program when displaying a message box in Windows.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$SCREENHIDE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "user32"
{{Cl|FUNCTION}} MessageBoxA&amp; ({{Cl|BYVAL}} hWnd%&amp;, {{Cl|BYVAL}} lpText%&amp;, {{Cl|BYVAL}} lpCaption%&amp;, {{Cl|BYVAL}} uType~&amp;)
{{Cl|FUNCTION}} MessageBoxA& ({{Cl|BYVAL}} hWnd%&, {{Cl|BYVAL}} lpText%&, {{Cl|BYVAL}} lpCaption%&, {{Cl|BYVAL}} uType~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "kernel32"
{{Cl|SUB}} ExitProcess ({{Cl|BYVAL}} uExitCode~&amp;)
{{Cl|SUB}} ExitProcess ({{Cl|BYVAL}} uExitCode~&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|DIM}} s0 {{Cl|AS}} {{Cl|STRING}}
{{Cl|DIM}} s1 {{Cl|AS}} {{Cl|STRING}}
@ -35,4 +37,4 @@ ExitProcess MessageBoxA(0, {{Cl|_OFFSET (function)|_OFFSET}}(s0), {{Cl|_OFFSET(f
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:10:36}}
{{DISPLAYTITLE:_SCREENSHOW}}
The [[_SCREENSHOW]] statement can be used to display the main program window in a section of code.
@ -16,4 +18,4 @@ The [[_SCREENSHOW]] statement can be used to display the main program window in
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:16:45}}
The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) arrays.
@ -6,7 +8,7 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
::: REM '''$STATIC'''
* 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]] code.
* The array's type cannot be changed once [[DIM]] and a literal value sets the dimensions and element size.
@ -14,7 +16,7 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
''Example:'' When a variable is used, the array can be resized despite $STATIC. The array becomes [[$DYNAMIC]].
{{CodeStart}} '' ''
{{CodeStart}}
'{{Cl|$STATIC}}
{{Cl|INPUT}} "Enter array size: ", size
@ -22,7 +24,7 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
{{Cl|REDIM}} array(2 * size)
{{Cl|PRINT}} {{Cl|UBOUND}}(array) '' ''
{{Cl|PRINT}} {{Cl|UBOUND}}(array)
{{CodeEnd}}
: ''Note:'' [[DIM]] using a literal numerical size will create a Duplicate definition error.
@ -33,4 +35,4 @@ The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) array
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:32}}
{{DISPLAYTITLE:$VERSIONINFO}}
The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resulting executable for identification purposes across the OS. Windows-only.
@ -7,8 +9,9 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
{{Parameters}}
* Text ''keys'' can be: '''CompanyName, FileDescription, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, Web, Comments'''
* Text ''keys'' can be: '''Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, ProductName, ProductVersion, Web'''
* Numeric {{Parameter|keys}} can be:'''FILEVERSION#''' and '''PRODUCTVERSION#'''
**When provided, the numerical keys '''FILEVERSION#''' and '''PRODUCTVERSION#''' will also provide values to the text keys '''FileVersion''' and '''ProductVersion,''' if the text versions are not provided separately. (Phoenix Edition v0.6.0 and above)
{{PageDescription}}
@ -17,8 +20,9 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Not available in Linux or macOS]].
==Availability==
* '''Build 20170429/52 and up'''.
{{PageAvailability}}
* '''QB64 1.2 and up''' (QB64 Team)
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
{{PageExamples}}
@ -37,4 +41,4 @@ The [[$VERSIONINFO]] [[Metacommand|metacommand]] adds text metadata to the resul
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:34}}
{{DISPLAYTITLE:$VIRTUALKEYBOARD}}
[DEPRACATED] The [[$VIRTUALKEYBOARD]] [[Metacommand|metacommand]] turns the virtual keyboard ON or OFF.
@ -15,7 +17,7 @@
{{CodeStart}}
{{Cl|$VIRTUALKEYBOARD}}:ON
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) '' ''
{{Cl|DO}}: {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27)
{{CodeEnd}}
@ -24,4 +26,4 @@
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
The '''&amp;B''' prefix denotes that an integer value is expressed in a binary base 2 format using '''QB64''' only.
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:48}}
The '''&B''' prefix denotes that an integer value is expressed in a binary base 2 format using '''QB64''' only.
{{PageSyntax}}
:::: a&amp; = '''&amp;B1110110000111111'''
:::: a& = '''&B1110110000111111'''
* The base 2 numbering system uses binary digit values of 1 or 0, or bits on or bits off in computer register switches or memory.
@ -12,10 +14,10 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
** [[INTEGER]]: 16 binary digits or a decimal value range from -32,768 to 32,767
** [[LONG]]: 32 binary digits or a decimal value range from -2,147,483,648 to 2,147,483,647
** [[_INTEGER64]]: 64 binary digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
* [[LONG]] values can be returned by appending the &amp; or ~%([[_UNSIGNED]] [[INTEGER]]) symbols after the binary number.
* [[VAL]] can be used to convert "&amp;B" prefixed string values to decimal.
* [[LONG]] values can be returned by appending the & or ~%([[_UNSIGNED]] [[INTEGER]]) symbols after the binary number.
* [[VAL]] can be used to convert "&B" prefixed string values to decimal.
&lt;center>'''[[_BIT|BITS]]'''&lt;/center>
<center>'''[[_BIT|BITS]]'''</center>
* The '''MSB''' is the most significant(largest) bit value and '''LSB''' is the least significant bit of a binary or register memory address value. The order in which the bits are read determines the binary or decimal byte value. There are two common ways to read a byte:
:* '''"Big-endian"''': MSB is the first bit encountered, decreasing to the LSB as the last bit by position, memory address or time.
@ -26,9 +28,9 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
'''Big-Endian Bit On Value:''' 128 64 32 16 8 4 2 1 240
'''Little-Endian Bit On Value:''' 1 2 4 8 16 32 64 128 15
{{WhiteEnd}}
::The big-endian method compares exponents of 2 &lt;sup>7&lt;/sup> down to 2 &lt;sup>0&lt;/sup> while the little-endian method does the opposite.
::The big-endian method compares exponents of 2<sup>7</sup> down to 2<sup>0</sup> while the little-endian method does the opposite.
&lt;center>'''[[_BYTE|BYTES]]'''&lt;/center>
<center>'''[[_BYTE|BYTES]]'''</center>
* [[INTEGER]] values consist of 2 bytes called the '''HI''' and '''LO''' bytes. Anytime that the number of binary digits is a multiple of 16 (2bytes, 4 bytes, etc.) and the HI byte's MSB is on(1), the value returned will be negative. Even with [[SINGLE]] or [[DOUBLE]] values!
{{WhiteStart}} '''16 BIT INTEGER OR REGISTER'''
'''AH (High Byte Bits) AL (Low Byte Bits)'''
@ -60,7 +62,7 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
12 1100 C 14
13 1101 D 15
14 1110 E 16
15 ------------- 1111 &lt;--- Match ---> F ---------------- 17 -- max 2
15 ------------- 1111 <--- Match ---> F ---------------- 17 -- max 2
16 10000 10 20
When the Decimal value is 15, the other 2 base systems are all maxed out!
@ -69,22 +71,22 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
value to Binary just add the 4 binary digits for each HEX digit place so:
F A C E
&amp;HFACE = 1111 + 1010 + 1100 + 1101 = &amp;B1111101011001101
&HFACE = 1111 + 1010 + 1100 + 1101 = &B1111101011001101
To convert a Binary value to HEX you just need to divide the number into
sections of four digits starting from the right(LSB) end. If one has less
than 4 digits on the left end you could add the leading zeros like below:
&amp;B101011100010001001 = 0010 1011 1000 1000 1001
hexadecimal = 2 + B + 8 + 8 + 9 = &amp;H2B889
&B101011100010001001 = 0010 1011 1000 1000 1001
hexadecimal = 2 + B + 8 + 8 + 9 = &H2B889
See the Decimal to Binary conversion function that uses '''[[HEX$]]''' on the '''[[&amp;H]]''' page.
See the Decimal to Binary conversion function that uses '''[[HEX$]]''' on the '''[[&H]]''' page.
{{TextEnd}}
''Example 1:'' A Decimal to Binary [[STRING]] function that does not return leading zeroes.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|PRINT}} BIN$(255) '1 byte(8 bits) maximum
{{Cl|PRINT}} BIN$(32767) 'integer(2 byte, 15 bits) maximum
{{Cl|PRINT}} BIN$(-32768) 'integer(2 byte, 16 bits) minimum
@ -96,7 +98,7 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
{{Cl|IF...THEN|IF}} (n% {{Cl|AND (boolean)|AND}} 2 ^ i) {{Cl|THEN}} MSB% = 1: B$ = B$ + "1" {{Cl|ELSE}} {{Cl|IF...THEN|IF}} MSB% {{Cl|THEN}} B$ = B$ + "0"
{{Cl|NEXT}}
{{Cl|IF...THEN|IF}} B$ = "" {{Cl|THEN}} BIN$ = "0" {{Cl|ELSE}} BIN$ = B$ 'check for empty string
{{Cl|END FUNCTION}} '' ''
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
{{OutputStart}}
@ -109,19 +111,19 @@ The '''&amp;B''' prefix denotes that an integer value is expressed in a binary b
''Example 2:'' QB64 converts the binary values from the example above to [[INTEGER]] decimal values automatically.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DEFLNG}} A-Z
a = &amp;B11111111
b = &amp;B111111111111111
c = &amp;B1000000000000000 '&amp; 'or ~%
d = &amp;B1111111111111111 '&amp; 'or ~%
a = &B11111111
b = &B111111111111111
c = &B1000000000000000 '& 'or ~%
d = &B1111111111111111 '& 'or ~%
{{Cl|PRINT}} a, b, c, d '' ''
{{Cl|PRINT}} a, b, c, d
{{CodeEnd}}
{{OutputStart}}
255 32767 -32768 -1
{{OutputEnd}}
:''Bonus example:'' Add an '''&amp;''' symbol after the negative binary numbers to see the [[LONG]] decimal values below.
:''Bonus example:'' Add an '''&''' symbol after the negative binary numbers to see the [[LONG]] decimal values below.
{{OutputStart}}
255 32767 32768 65535
{{OutputEnd}}
@ -131,9 +133,9 @@ d = &amp;B1111111111111111 '&amp; 'or ~%
{{PageSeeAlso}}
* [[_BIT]], [[_BYTE]]
* [[_SHL]], [[_SHR]]
* [[OCT$]], [[&amp;O]] {{text|(octal)}}
* [[HEX$]], [[&amp;H]] {{text|(hexadecimal)}}
* [[OCT$]], [[&O]] {{text|(octal)}}
* [[HEX$]], [[&H]] {{text|(hexadecimal)}}
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
The '''&amp;H''' prefix denotes that an integer value is expressed in a Hexadecimal base 16 format. Every 2 digits represent a [[_BYTE]].
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:51}}
The '''&H''' prefix denotes that an integer value is expressed in a Hexadecimal base 16 format. Every 2 digits represent a [[_BYTE]].
{{PageSyntax}}
:::: a&amp; = &amp;HFACE
:::: a& = &HFACE
* The base 16 numbering system uses hexadecimal digit values of 0 to F. A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
@ -14,28 +16,28 @@ The '''&amp;H''' prefix denotes that an integer value is expressed in a Hexadeci
::* [[_INTEGER64]]: 16 hex digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
::* [[_UNSIGNED]] [[_INTEGER64]]: 0 to 18446744073709551615.
* The maximum hexadecimal value for each numerical type is the maximum number of digits listed above, each valued at F.
* Convert hexadecimal to [[LONG]] values by appending the values with &amp;. Example: &amp;H8000 = -32768: &amp;H8000&amp; = 32768
* [[LONG]] 32 bit [[_RGB]] values can be made using hexadecimal values from '''&amp;HFF{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&amp;HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with full [[_ALPHA]] only.
* [[LONG]] 32 bit [[_RGBA]] values can be made using hexadecimal values from '''&amp;H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&amp;HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with any [[_ALPHA]].
* Hexadecimal '''0x''' is often used to prefix [[HEX$]] port addresses in documentation. Replace 0x with [[&amp;H]] in QB64 or QBasic.
* To convert hex strings returned from [[HEX$]] with [[VAL]] you need to prefix the string with &amp;H (for example; if the string is "FF" you should do VAL("&amp;HFF") or VAL("&amp;H" + hexvalue$).
* Convert hexadecimal to [[LONG]] values by appending the values with &. Example: &H8000 = -32768: &H8000& = 32768
* [[LONG]] 32 bit [[_RGB]] values can be made using hexadecimal values from '''&HFF{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with full [[_ALPHA]] only.
* [[LONG]] 32 bit [[_RGBA]] values can be made using hexadecimal values from '''&H00{{text|00|red}}{{text|00|green}}{{text|00|blue}}''' to '''&HFF{{text|FF|red}}{{text|FF|green}}{{text|FF|blue}}''' with any [[_ALPHA]].
* Hexadecimal '''0x''' is often used to prefix [[HEX$]] port addresses in documentation. Replace 0x with [[&H]] in QB64 or QBasic.
* To convert hex strings returned from [[HEX$]] with [[VAL]] you need to prefix the string with &H (for example; if the string is "FF" you should do VAL("&HFF") or VAL("&H" + hexvalue$).
''Example 1:'' The maximum octal values of decimal value -1 in each numerical type are:
{{CodeStart}} '' ''
c&amp;&amp; = -1: d&amp; = -1: e% = -1: f%% = -1
{{CodeStart}}
c&& = -1: d& = -1: e% = -1: f%% = -1
hx$ = {{Cl|HEX$}}(f%%)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|_BYTE}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(e%)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&amp;)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&amp;&amp;)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;H}}" + hx$)
{{Cl|PRINT}} "Max hex {{Cl|INTEGER}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(d&)
{{Cl|PRINT}} "Max hex {{Cl|LONG}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(c&&)
{{Cl|PRINT}} "Max hex {{Cl|_INTEGER64}} = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits ="; {{Cl|VAL}}("{{Cl|&H}}" + hx$)
hx$ = {{Cl|HEX$}}(9223372036854775807)
{{Cl|PRINT}} "Max {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
hx$ = {{Cl|HEX$}}(-9223372036854775808)
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits" '' ''
{{Cl|PRINT}} "Min {{Cl|_INTEGER64}} value = "; hx$; " with"; {{Cl|LEN}}(hx$); "digits"
{{CodeEnd}}
{{OutputStart}}Max hex _BYTE = FF with 2 digits = 255
Max hex INTEGER = FFFF with 4 digits = 65535
@ -47,9 +49,9 @@ Min _INTEGER64 value = 8000000000000000 with 16 digits
''Example 2:'' Converting a decimal number to a binary string value using [[HEX$]].
{{CodeStart}} '' ''
FUNCTION BIN$ (n&amp;)
h$ = {{Cl|HEX$}}(n&amp;) 'get hexadecimal string value
{{CodeStart}}
FUNCTION BIN$ (n&)
h$ = {{Cl|HEX$}}(n&) 'get hexadecimal string value
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"
@ -71,8 +73,8 @@ FUNCTION BIN$ (n&amp;)
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 '' ''
IF {{Cl|VAL}}(b$) THEN BIN$ = b$ ELSE BIN$ = "0" 'return zero if n& = 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.
@ -80,9 +82,9 @@ END FUNCTION '' ''
''See also:''
* [[HEX$]], [[OCT$]]
* [[&amp;B]] {{text|(binary)}}, [[&amp;O]] {{text|(octal)}}
* [[&B]] {{text|(binary)}}, [[&O]] {{text|(octal)}}
* [[Base Comparisons]]
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
The '''&amp;O''' prefix denotes that a integer value is expressed in an Octal base 8 format.
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:49}}
The '''&O''' prefix denotes that a integer value is expressed in an Octal base 8 format.
{{PageSyntax}}
:::: a&amp; = &amp;O12345671234
:::: a& = &O12345671234
* The base eight numbering system only uses octal digit values of 0 to 7.
@ -11,20 +13,20 @@ The '''&amp;O''' prefix denotes that a integer value is expressed in an Octal ba
:: * [[INTEGER]]: 6 octal digits or a decimal value range from -32,768 to 32,767
:: * [[LONG]]: 11 octal digits or a decimal value range from -2,147,483,648 to 2,147,483,647
:: * [[_INTEGER64]]: 22 octal digits or decimal values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
* [[LONG]] Octal values can be expressed by appending &amp; after the number. Example: &amp;O100000&amp; = 32768
* [[LONG]] Octal values can be expressed by appending & after the number. Example: &O100000& = 32768
''Example:'' The maximum octal values of decimal value -1 in each numerical type are:
{{CodeStart}}
c&amp;&amp; = -1: d&amp; = -1: e% = -1: f%% = -1
c&& = -1: d& = -1: e% = -1: f%% = -1
oc$ = {{Cl|OCT$}}(f%%)
{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;O}}" + oc$)
{{Cl|PRINT}} "Max octal {{Cl|_BYTE}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(e%)
{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;O}}" + oc$)
oc$ = {{Cl|OCT$}}(d&amp;)
{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;O}}" + oc$)
oc$ = {{Cl|OCT$}}(c&amp;&amp;)
{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&amp;O}}" + oc$) '' ''
{{Cl|PRINT}} "Max octal {{Cl|INTEGER}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(d&)
{{Cl|PRINT}} "Max octal {{Cl|LONG}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
oc$ = {{Cl|OCT$}}(c&&)
{{Cl|PRINT}} "Max octal {{Cl|_INTEGER64}} = "; oc$; " with"; {{Cl|LEN}}(oc$); "digits ="; {{Cl|VAL}}("{{Cl|&O}}" + oc$)
{{CodeEnd}}
{{OutputStart}}Max octal _BYTE = 377 with 3 digits = 255
Max octal INTEGER = 177777 with 6 digits = 65535
@ -35,9 +37,9 @@ Max octal _INTEGER64 = 1777777777777777777777 with 22 digits =-1
''See also:''
* [[OCT$]], [[HEX$]], [[VAL]]
* [[&amp;B]] (binary), [[&amp;H]] (hexadecimal)
* [[&B]] (binary), [[&H]] (hexadecimal)
* [[Base Comparisons]]
{{PageNavigation}}
<

25
internal/help/%2A_%21.txt Normal file
View file

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

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:54}}
The '''/''' mathematical operator performs decimal point division on a numerical value.
@ -25,4 +27,4 @@ The '''/''' mathematical operator performs decimal point division on a numerical
{{PageNavigation}}
<

48
internal/help/%5C_%51.txt Normal file
View file

@ -0,0 +1,48 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:56}}
The '''\''' mathematical operator performs [[INTEGER]] division on a numerical value.
{{PageSyntax}}
::: 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 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.
''Example:'' Displays how floating decimal point values are rounded to the closest even [[INTEGER|integer]] value.
{{CodeStart}}
{{Cl|PRINT}} 0.5 \ 1
{{Cl|PRINT}} 1.5 \ 1
{{Cl|PRINT}} 2.5 \ 1
{{Cl|PRINT}} 3.5 \ 1
{{Cl|PRINT}} 4.5 \ 1
{{Cl|PRINT}} 5.5 \ 1
{{CodeEnd}}
{{OutputStart}}0
2
2
4
4
6
{{OutputEnd}}
''See also:''
* [[MOD|MOD (remainder division operator)]]
* [[/|/ (normal division operator)]]
* [[INT]], [[CINT]], [[FIX]], [[_ROUND]]
* [[Mathematical Operations]]
{{PageNavigation}}

View file

@ -1,189 +0,0 @@
<!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,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:52}}
The '''-''' mathematical operator performs subtraction on two numerical values or [[negation|negates]] a single value.
@ -11,7 +13,7 @@ The '''-''' mathematical operator performs subtraction on two numerical values o
* 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.
@ -25,4 +27,4 @@ The '''-''' mathematical operator performs subtraction on two numerical values o
{{PageNavigation}}
<

View file

@ -1,59 +0,0 @@
==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]
==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]]
==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]]
* [[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

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:40}}
The [[ABS]] function returns the unsigned numerical value of a variable or literal value.
@ -14,14 +16,14 @@ The [[ABS]] function returns the unsigned numerical value of a variable or liter
{{PageExamples}}
''Example:'' Finding the absolute value of positive and negative numerical values.
{{CodeStart}} '' ''
{{CodeStart}}
a = -6
b = -7
c = 8
{{Cl|IF...THEN|IF}} a &lt; 0 {{Cl|THEN}} a = {{Cl|ABS}}(a)
{{Cl|IF...THEN|IF}} a < 0 {{Cl|THEN}} a = {{Cl|ABS}}(a)
b = {{Cl|ABS}}(b)
c = {{Cl|ABS}}(c)
{{Cl|PRINT}} a, b, c '' ''
{{Cl|PRINT}} a, b, c
{{CodeEnd}}
{{OutputStart}} 6 7 8
{{OutputEnd}}
@ -35,4 +37,4 @@ c = {{Cl|ABS}}(c)
{{PageNavigation}}
<

View file

@ -1,19 +1,21 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:42}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&amp;}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
@ -21,7 +23,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
* '''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.'''
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
@ -32,7 +34,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : &lt; > '''. Multiple dots (periods) are allowed.
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
@ -88,18 +90,18 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}} '' ''
{{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}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}} '' ''
{{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
@ -107,7 +109,7 @@ g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT '' ''
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.
@ -159,4 +161,4 @@ It was overwritten with this and deleted.
{{PageNavigation}}
<

View file

@ -1,2 +0,0 @@
#REDIRECT [[DECLARE LIBRARY]]
<

View file

@ -0,0 +1,4 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:44}}
See page [[DECLARE LIBRARY]]

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:46}}
The [[AND (boolean)|AND]] conditonal operator is used to include another evaluation in an [[IF...THEN]] or [[Boolean]] statement.
@ -25,7 +27,7 @@ The [[AND (boolean)|AND]] conditonal operator is used to include another evaluat
a% = 100
b% = 50
{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% &lt; 200 {{Cl|THEN}} {{Cl|PRINT}} "True"
{{Cl|IF...THEN|IF}} a% > b% {{Cl|AND (boolean)|AND}} a% < 200 {{Cl|THEN}} {{Cl|PRINT}} "True"
{{CodeEnd}}
{{OutputStart}}
@ -35,18 +37,18 @@ True
''Example:'' Using a AND a more complex way.
{{CodeStart}} '' ''
{{CodeStart}}
a% = 100
b% = 50
c% = 25
d% = 50
e% = 100
{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% &lt; d% {{Cl|AND (boolean)|AND}} d% &lt; e%) {{Cl|THEN}}
{{Cl|IF...THEN|IF}} (a% > b% {{Cl|AND (boolean)|AND}} b% > c%) {{Cl|AND (boolean)|AND}} (c% < d% {{Cl|AND (boolean)|AND}} d% < e%) {{Cl|THEN}}
{{Cl|PRINT}} "True"
{{Cl|ELSE}}
{{Cl|PRINT}} "False"
{{Cl|END IF}} '' ''
{{Cl|END IF}}
{{CodeEnd}}
{{OutputStart}}
True
@ -61,4 +63,4 @@ True
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:45}}
The logical [[AND]] numerical operator compares two values in respect of their bits. If both bits at a certain position in both values are set, then that bit position is set in the result.
@ -50,13 +52,13 @@ The logical [[AND]] numerical operator compares two values in respect of their b
{{CodeStart}}
DO
{{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&amp;
IF INTvalue&amp; &lt; -32768 OR INTvalue&amp; > 32767 OR INTval&amp; = 0 THEN {{Cl|EXIT DO}}
{{Cl|INPUT}} "Enter Integer value from -32768 to 32767 (Enter quits): ", INTvalue&
IF INTvalue& < -32768 OR INTvalue& > 32767 OR INTval& = 0 THEN {{Cl|EXIT DO}}
{{Cl|FOR...NEXT|FOR}} exponent = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} (INTvalue&amp; {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|IF...THEN|IF}} (INTvalue& {{Cl|AND}} 2 ^ exponent) {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|NEXT}}
PRINT " "
LOOP UNTIL INTvalue&amp; = 0 'zero entry quits
LOOP UNTIL INTvalue& = 0 'zero entry quits
{{CodeEnd}}
@ -74,4 +76,4 @@ The logical [[AND]] numerical operator compares two values in respect of their b
{{PageNavigation}}
<

View file

@ -1,19 +1,21 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:47}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&amp;}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
@ -21,7 +23,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
* '''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.'''
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
@ -32,7 +34,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : &lt; > '''. Multiple dots (periods) are allowed.
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
@ -88,18 +90,18 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}} '' ''
{{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}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}} '' ''
{{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
@ -107,7 +109,7 @@ g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT '' ''
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.
@ -159,4 +161,4 @@ It was overwritten with this and deleted.
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:51}}
The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a character at any position of a [[STRING]] variable.
@ -43,4 +45,4 @@ The [[ASC (statement)|ASC]] statement allows a '''QB64''' program to change a ch
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:50}}
The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] text character or a keyboard press.
@ -10,7 +12,7 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
* If the optional {{Parameter|position%}} parameter is omitted, ASC will return the [[ASCII]] code of the first [[STRING]] character.
* [[ASCII]] code [[INTEGER]] or [[_UNSIGNED]] [[_BYTE]] values returned range from 0 to 255.
* ASC returns 0 when reading [[ASCII]] 2 byte codes returned by [[INKEY$]] when the arrow, function, Home/Page keys are used.
** Use QB64's {{Parameter|position%}} parameter to read the second byte if necessary. {{Text|IF ASC(key$) &lt;nowiki>=&lt;/nowiki> 0 THEN byte2 &lt;nowiki>=&lt;/nowiki> ASC(key$, 2)|green}}
** Use QB64's {{Parameter|position%}} parameter to read the second byte if necessary. {{Text|IF ASC(key$) <nowiki>=</nowiki> 0 THEN byte2 <nowiki>=</nowiki> ASC(key$, 2)|green}}
* In '''QB64''' ASC string byte position reads are about '''5 times faster''' than [[MID$]] when parsing strings. See [[MID$]] ''Example 2''.
@ -23,7 +25,7 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
'
'''' Esc F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Sys ScL Pause'''
' 27 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +133 +134 - - -
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7&amp; 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
'''' `~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ BkSp Ins Hme PUp NumL / * -'''
' 126 33 64 35 36 37 94 38 42 40 41 95 43 8 +82 +71 +73 - 47 42 45
''' 96 49 50 51 52 53 54 55 56 57 48 45 61''
'''' Tab Q W E R T Y U I O P [{ ]} \| Del End PDn 7Hme 8/▲ 9PU + '''
@ -32,7 +34,7 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
'''' CapL A S D F G H J K L ;: '" Enter 4/◄- 5 6/-►
' - 65 83 68 70 71 72 74 75 76 58 34 13 +75 +76 +77 '''E'''
''' 97 115 100 102 103 104 106 107 108 59 39 52 53 54 '' '''n'''
'''' Shift Z X C V B N M ,&lt; .> /? Shift ▲ 1End 2/▼ 3PD t'''
'''' Shift Z X C V B N M ,< .> /? Shift ▲ 1End 2/▼ 3PD t'''
' * 90 88 67 86 66 78 77 60 62 63 * +72 +79 +80 +81 '''e'''
''' 122 120 99 118 98 110 109 44 46 47 49 50 51 '' '''r'''
'''' Ctrl Win Alt Spacebar Alt Win Menu Ctrl ◄- ▼ -► 0Ins .Del '''
@ -44,13 +46,13 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
{{WhiteEnd}}
&lt;center>'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''&lt;/center>
<center>'''[[ASCII#Two_Byte_Codes|Two Byte Ctrl, Alt and Shift + Function key combinations]]'''</center>
{{WhiteStart}} '''Two Byte Characters    Key                 CHR$(0) + "?" '''
CHR$(0) + CHR$(16-50) [Alt] + letter
CHR$(0) + CHR$(59) [F1] ";"
CHR$(0) + CHR$(60) [F2] "&lt;"
CHR$(0) + CHR$(60) [F2] "<"
CHR$(0) + CHR$(61) [F3] "="
CHR$(0) + CHR$(62) [F4] ">"
CHR$(0) + CHR$(63) [F5] "?"
@ -90,10 +92,10 @@ 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}} '' ''
{{CodeStart}}
{{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) '' ''
{{Cl|PRINT}} ASC("QB64 is not only COMPATIBLE, it can find any part of the string!", 18)
{{CodeEnd}}
''Returns:''
@ -110,16 +112,16 @@ The [[ASC]] function returns the [[ASCII]] code number of a certain [[STRING]] t
''Example 2:'' Reading the ASCII and two byte code combinations with ASC in '''QB64'''.
{{CodeStart}} '' ''
{{CodeStart}}
Q$ = {{Cl|CHR$}}(34) ' quote character
{{Cl|COLOR}} 10: {{Cl|LOCATE}} 5, 22: {{Cl|PRINT}} "Press some keys or combinations!"
{{Cl|COLOR}} 13: {{Cl|LOCATE}} 23, 30: {{Cl|PRINT}} "Escape key Quits"
DO
DO: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ &lt;> "" ' prevent ASC empty string read error
DO: {{Cl|SLEEP}}: key$ = {{Cl|INKEY$}}: {{Cl|LOOP}} {{Cl|UNTIL}} key$ <> "" ' prevent ASC empty string read error
code% = {{Cl|ASC}}(key$): {{Cl|COLOR}} 11: {{Cl|LOCATE}} 10, 10
{{Cl|IF...THEN|IF}} code% {{Cl|THEN}} ' ASC returns any value greater than 0
{{Cl|PRINT}} "{{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}(code%)) + ")" + {{Cl|SPACE$}}(13):
{{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% &lt; 14 {{Cl|THEN}} code% = 32 ' unprintable control codes
{{Cl|IF...THEN|IF}} code% > 8 {{Cl|AND (boolean)|AND}} code% < 14 {{Cl|THEN}} code% = 32 ' unprintable control codes
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} {{Cl|CHR$}}(code%) + {{Cl|SPACE$}}(13)
{{Cl|ELSE}}: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + {{Cl|CHR$}}(" + {{Cl|LTRIM$}}({{Cl|STR$}}({{Cl|ASC}}(key$, 2))) + ")"
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 10, 50: {{Cl|PRINT}} "{{Cl|CHR$}}(0) + " + Q$ + {{Cl|CHR$}}({{Cl|ASC}}(key$, 2)) + Q$
@ -136,19 +138,19 @@ DO
DO: {{Cl|SLEEP}} ' requires a keypress to run loop once
K$ = {{Cl|{{Cl|INKEY$}}}}
code = {{Cl|ASC}}(K$)
{{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 >= 48 {{Cl|AND (boolean)|AND}} code <= 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|{{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|IF...THEN|IF}} L - 1 < 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)
{{Cl|LOOP}} {{Cl|UNTIL}} code = 13 {{Cl|AND}} L '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} code = 13 {{Cl|AND}} L
{{CodeEnd}}
''Explanation:'' [[SLEEP]] waits for a keypress allowing background programs to use the processor time. It also keeps the press in the keyboard buffer for [[INKEY$]] to read and guarantees that ASC will not read an empty string value to create an error. Filtered codes 48 to 57 are only number characters. One decimal point is allowed by using the flag. Code 8 is a backspace request which is ignored if the entry has no characters. If it is allowed it removes the last character from the entry and the screen. The loop exits when the user presses the [Enter] key and the entry has a length.
@ -164,4 +166,4 @@ DO
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:49}}
The [[AS]] keyword defines a variable data [[type]].
@ -31,4 +33,4 @@ The [[AS]] keyword defines a variable data [[type]].
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:52}}
The [[ATN]] or arctangent function returns the angle in radians of a numerical [[TAN|tangent]] value.
@ -7,36 +9,36 @@ The [[ATN]] or arctangent function returns the angle in radians of a numerical [
{{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}}'''
* {{Parameter|tangent!}} [[SINGLE]] or [[DOUBLE]] values are used by the function. EX:'''{{text|Pi <nowiki>=</nowiki> 4 * ATN(1)|green}}'''
{{PageDescription}}
* To convert from radians to degrees, multiply radians * (180 / &amp;pi;).
* The ''tangent'' value would be equal to the tangent value of an angle. Ex: '''{{text|[[TAN]](ATN(1)) &lt;nowiki>=&lt;/nowiki> 1|green}}'''
* The function return value is between -&amp;pi; / 2 and &amp;pi; / 2.
* To convert from radians to degrees, multiply radians * (180 / ã).
* The ''tangent'' value would be equal to the tangent value of an angle. Ex: '''{{text|[[TAN]](ATN(1)) <nowiki>=</nowiki> 1|green}}'''
* The function return value is between -ã / 2 and ã / 2.
{{PageExamples}}
''Example 1:'' When the [[TAN]]gent value equals 1, the line is drawn at a 45 degree angle (.7853982 radians) where [[SIN]] / [[COS]] = 1.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} 12
x = 100 * {{Cl|COS}}({{Cl|ATN}}(1))
y = 100 * {{Cl|SIN}}({{Cl|ATN}}(1))
{{Cl|LINE}} (200, 200)-(200 + x, 200 + y) '' ''
{{Cl|LINE}} (200, 200)-(200 + x, 200 + y)
{{CodeEnd}}
''Example 2:'' [[ATN]] can be used to define &amp;pi; in [[SINGLE]] or [[DOUBLE]] precision. The calculation cannot be used as a [[CONST]]ant.
{{CodeStart}} '' ''
''Example 2:'' [[ATN]] can be used to define ã in [[SINGLE]] or [[DOUBLE]] precision. The calculation cannot be used as a [[CONST]]ant.
{{CodeStart}}
Pi = 4 * {{Cl|ATN}}(1) '{{Cl|SINGLE}} precision
Pi# = 4 * {{Cl|ATN}}(1#) '{{Cl|DOUBLE}} precision
PRINT Pi, Pi# '' ''
PRINT Pi, Pi#
{{CodeEnd}}
:''Note:'' You can use QB64's native [[_PI]] function.
''Example 3:'' Finds the angle from the center point to the mouse pointer.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
x1! = 320
y1! = 240
@ -51,7 +53,7 @@ DO
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 200
{{Cl|CLS}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} &lt;> ""
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> ""
{{Cl|END}}
{{Cl|FUNCTION}} getangle# (x1#, y1#, x2#, y2#) 'returns 0-359.99...
@ -64,7 +66,7 @@ DO
{{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}} y2# < y1# {{Cl|THEN}}
{{Cl|IF...THEN|IF}} x2# > x1# {{Cl|THEN}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131
{{Cl|ELSE}}
@ -73,7 +75,7 @@ DO
{{Cl|ELSE}}
getangle# = {{Cl|ATN}}((x2# - x1#) / (y2# - y1#)) * -57.2957795131 + 180
{{Cl|END IF}}
{{Cl|END FUNCTION}} '' ''
{{Cl|END FUNCTION}}
{{CodeEnd}}{{small|Function by Galleon}}
@ -86,4 +88,4 @@ DO
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:40}}
The '''apostrophe''' is used to tell the compiler to ignore a statement or programmer comment.
{{PageDescription}}
@ -23,4 +25,4 @@ COLOR 11: PRINT "Print this...." ' PRINT "Don't print this program comment!"
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:54}}
The [[BEEP]] statement produces a beep sound through the sound card.
@ -22,4 +24,4 @@ The [[BEEP]] statement produces a beep sound through the sound card.
{{PageNavigation}}
<

View file

@ -1,19 +1,21 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:55}}
The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communications port for program input or output.
{{PageSyntax}}
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&amp;}} [LEN = {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|fileName$}} ['''FOR''' {{Parameter|mode}}] [{{{KW|ACCESS}}|{{{KW|LOCK}}|SHARED}} [{READ|WRITE}] [[AS]] [#]{{Parameter|fileNumber&}} [LEN = {{Parameter|recordLength}}]
===Legacy ''GW-BASIC'' syntax===
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&amp;}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
: [[OPEN]] {{Parameter|modeLetter$}}, [#]{{Parameter|fileNumber&}}, {{Parameter|fileName$}}[, {{Parameter|recordLength}}]
{{Parameters}}
* The {{Parameter|fileName$}} is a [[STRING]] variable or literal file name (path optional) in quotes.
* FOR mode can be: [[APPEND]] (write to end), [[BINARY]] (read/write), [[INPUT (file mode)|INPUT]] (read), [[OUTPUT]] (write new) or [[RANDOM]] (read/write).
* GW-BASIC's {{Parameter|modeLetter$}} is a [[STRING]] variable or the letter "A", "B", "I", "O" or "R" designating the OPEN modes above.
* {{Parameter|fileNumber&amp;}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* {{Parameter|fileNumber&}} can be any '''positive''' [[INTEGER]] or [[LONG]] whole number value or an unused value determined by the [[FREEFILE]] function.
* [[LEN]] = or {{Parameter|recordLength}} is optional to denote the RANDOM file record byte length (default = 128) or sequential (default = 512) load buffer.
@ -21,7 +23,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
* '''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.'''
* '''Only the {{Parameter|fileName$}}, {{Parameter|fileNumber&}} and LEN = {{Parameter|recordLength}} values can use variable values in the QBasic syntax.'''
* If [[LEN]] = is ommitted, sequential file record sizes default to 512 and [[RANDOM]] to 128 bytes in Qbasic.
* {{Parameter|fileName$}} can be up to 255 characters with no limit on file name extension length in '''QB64'''.
* Once a file or port is opened, it can be used in any program procedure using the assigned file number.
@ -32,7 +34,7 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{PageErrors}}
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : &lt; > '''. Multiple dots (periods) are allowed.
* Illegal '''QB64''' Windows filename characters are ''' " * / \ | ? : < > '''. Multiple dots (periods) are allowed.
* Possible OPEN [[ERROR Codes|errors]] include "Bad file name or number", "Bad File Mode", "File Not Found" or "Path Not Found".
** An OPEN file not found error may occur if [[CHR$]](0) to (31) are used in a Windows file name.
* '''QB64''' does not have DOS file name limitations.
@ -88,18 +90,18 @@ The [[OPEN]] statement is used to open a file or [[OPEN_COM|COM]] serial communi
{{Cl|PRINT}} {{Cl|CHR$}}(code%); 'use {{Cl|LOCATE}} before {{Cl|FUNCTION}} call to place print
{{Cl|NEXT}}
CheckName% = E%
{{Cl|END FUNCTION}} '' ''
{{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}}
{{text|Hello|#54FC54}}{{text|,|red}}{{text|~1.mp3|#54FC54}} {{text|Total Errors|yellow}}<nowiki> = </nowiki>{{text|1|yellow}}
{{OutputEnd}}
:''Note:'' The screen output displays filename characters in green except for red comma QBasic error.
''Example 2:'' When '''OPEN "SCRN:" FOR OUTPUT AS #f''' is used, '''PRINT #f''' will print the text to the screen instead of to a file:
{{CodeStart}} '' ''
{{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
@ -107,7 +109,7 @@ g% = {{Cl|FREEFILE}} 'should always be 2 after 1
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 2
{{Cl|PRINT (file statement)|PRINT}} #i, "Hello World, Screen and File version"
NEXT '' ''
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.
@ -159,4 +161,4 @@ It was overwritten with this and deleted.
{{PageNavigation}}
<

View file

@ -1,13 +1,15 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:56}}
[[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array.
==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.'''
{{PageSyntax}}
: [[BLOAD]] {{Parameter|fileName$}}, [[VARPTR]]({{Parameter|imageArray%({{Parameter|index}})}})
{{PageLegacySupport}}
* '''QB64''' can load larger arrays directly from binary files using [[PUT]] # and [[GET]] # without '''BLOAD'''. For that reason, '''BLOAD''' isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
{{Parameters}}
* {{Parameter|fileName$}} is the name of the file that the image should be [[BSAVE]]d to.
* {{Parameter|imageArray%(index)}} is the [[INTEGER]] [[arrays|array]] start index to store the image loaded.
@ -25,20 +27,20 @@
{{PageExamples}}
''Example 1:'' Loading data to an array from a BSAVED file.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0))
{{Cl|BLOAD}} filename$, {{Cl|VARPTR}}(Array({{Cl|LBOUND}}(Array))) ' changeable index
{{Cl|DEF SEG}} '' ''
{{Cl|DEF SEG}}
{{CodeEnd}}
:''Explanation:'' Referance any type of array that matches the data saved. Can work with Integer, Single, Double, Long, fixed length Strings or [[TYPE]] arrays. [[LBOUND]] determines the starting offset of the array or another index could be used.
''Example 2:'' Using a QB default colored image.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image%(0)) ' pointer to first image element of an array
{{Cl|BLOAD}} FileName$, {{Cl|VARPTR}}(Image%(0)) ' place data into array at index position 0
{{Cl|PUT (graphics statement)|PUT}}(Col, Row), Image%(0), PSET ' Put the image on the screen from index 0
{{Cl|DEF SEG}} '' ''
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Note:'' [[PSET]] is used as a [[PUT (graphics statement)|PUT]] action that places the image over any background objects.
@ -53,4 +55,4 @@
{{PageNavigation}}
<

View file

@ -1,18 +1,20 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:57}}
[[BSAVE]] saves the contents of an image array to a [[BINARY]] file.
==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;}}
: [[BSAVE]] {{Parameter|saveFile$}}, [[VARPTR]]({{Parameter|array(index)}}), {{Parameter|fileSize&}}
{{PageLegacySupport}}
* '''QB64''' can save larger arrays directly to binary files using [[PUT]] # and [[GET]] # without '''BSAVE'''. For that reason, '''BSAVE''' isn't recommended practice anymore and is supported to maintain compatibility with legacy code.
{{Parameters}}
* {{Parameter|saveFile$}} is the STRING file name of the file designated to be created.
* {{Parameter|array(index)}} is the image [[arrays|array]] that already holds the [[GET (graphics statement)|GET]] image data.
* {{Parameter|fileSize&amp;}} must be a bit over twice the size of the elements used in an [[INTEGER]] [[Arrays|array]].
* {{Parameter|fileSize&}} must be a bit over twice the size of the elements used in an [[INTEGER]] [[Arrays|array]].
{{PageDescription}}
@ -27,30 +29,30 @@
{{PageExamples}}
''Example 1:'' Saving array data to a file quickly.
{{CodeStart}} '' ''
{{CodeStart}}
LB% = {{Cl|LBOUND}}(Array)
bytes% = {{Cl|LEN}}(Array(LB%))
filesize&amp; = (({{Cl|UBOUND}}(Array) - LB%) + 1) * bytes%
filesize& = (({{Cl|UBOUND}}(Array) - LB%) + 1) * bytes%
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Array(0))
{{Cl|BSAVE}} filename$, {{Cl|VARPTR}}(Array(LB%)), filesize&amp; ' changeable index
{{Cl|DEF SEG}} '' ''
{{Cl|BSAVE}} filename$, {{Cl|VARPTR}}(Array(LB%)), filesize& ' changeable index
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Explanation:'' Procedure determines the filesize from the array size automatically. [[LBOUND]] is used with [[UBOUND]] to determine array size and byte size. Works with any type of array except variable-length strings. Used for saving program data fast.
''Example 2:'' [[BSAVE]]ing a bitmap and calculating the file size
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DEF SEG}} = {{Cl|VARSEG}}(Image(0))
{{Cl|PSET}}(BMPHead.PWidth - 1, BMPHead.PDepth - 1) 'color lower right corner if black
{{Cl|GET (graphics statement)|GET}} (0, 0)-(BMPHead.PWidth - 1, BMPHead.PDepth - 1), Image(NColors * 3) ' for 16 or 256 colors
{{Cl|FOR...NEXT|FOR}} a&amp; = 26000 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} Image(a&amp;) {{Cl|THEN}} ArraySize&amp; = a&amp;: {{Cl|EXIT FOR}}
{{Cl|FOR...NEXT|FOR}} a& = 26000 {{Cl|TO}} 0 {{Cl|STEP}} -1
{{Cl|IF...THEN|IF}} Image(a&) {{Cl|THEN}} ArraySize& = a&: {{Cl|EXIT FOR}}
{{Cl|NEXT}}
{{Cl|BSAVE}} SaveName$, {{Cl|VARPTR}}(Image(0)), (2 * ArraySize&amp;) + 200 'file size
{{Cl|DEF SEG}} '' ''
{{Cl|BSAVE}} SaveName$, {{Cl|VARPTR}}(Image(0)), (2 * ArraySize&) + 200 'file size
{{Cl|DEF SEG}}
{{CodeEnd}}
: ''Explanation:'' The [[FOR...NEXT|FOR]] loop reads backwards through the image array until it finds a value not 0. The [[LONG]] {{Parameter|ArraySize&amp;}} value is doubled and 200 is added. {{Parameter|BMPhead.PWidth}} and {{Parameter|BMPhead.PDepth}} are found by reading the bitmap's information header using a [[TYPE]] definition. See [[Bitmaps]].
: ''Explanation:'' The [[FOR...NEXT|FOR]] loop reads backwards through the image array until it finds a value not 0. The [[LONG]] {{Parameter|ArraySize&}} value is doubled and 200 is added. {{Parameter|BMPhead.PWidth}} and {{Parameter|BMPhead.PDepth}} are found by reading the bitmap's information header using a [[TYPE]] definition. See [[Bitmaps]].
''Example 3:'' Using [[PUT]] and [[GET]] to write and read array data from a file without using BSAVE or [[BLOAD]]:
@ -65,7 +67,7 @@
{{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}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|IF...THEN|IF}} Graphic%(i%) <> 0 {{Cl|THEN}} {{Cl|EXIT}} {{Cl|FOR...NEXT|FOR}} 'find image color not black
{{Cl|NEXT}}
size% = i% + 4 'size plus 2 integers(4 bytes) for dimensions
{{Cl|REDIM}} {{Cl|_PRESERVE}} Graphic%(size%) 'resize existing array in QB64 only!
@ -89,7 +91,7 @@ K$ = {{Cl|INPUT$}}(1) 'Press any key
{{CodeEnd}}{{small|Code by Ted Weissgerber}}
: ''Explanation:'' A 10 by 10 pixel box is saved to an array using the [[GET (graphics statement)]] and written to a BINARY file using [[PUT]] #1. Then [[GET]] #1 places the file contents into another INTEGER array and places it on the screen with the [[PUT (graphics statement)]].
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) &lt;> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
: The array contents: 88 is the width in the GET array for [[SCREEN]] 13 which needs divided by 8 in that mode only. The area is actually 11 X 11. The array size needed can be found by looping backwards through the array until a color value is found. '''{{text|IF array(i) <> 0 THEN EXIT FOR|green}}''' (66 integers) or by dividing the created BINARY file size in half (134 bytes) when known to be array sized already.
{{PageSeeAlso}}
@ -102,4 +104,4 @@ K$ = {{Cl|INPUT$}}(1) 'Press any key
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:59}}
The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64.
@ -38,7 +40,7 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
{{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}} '' ''
{{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}}
@ -55,39 +57,39 @@ DO
{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}})
SDL_WarpMouse x, y 'call SDL library procedure
{{Cl|END SUB}} '' ''
{{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}} '' ''
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&amp;, {{Cl|BYVAL}} row&amp;)
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_DELAY}} 2
MouseMove 100, 100
{{Cl|_DELAY}} 2
MouseMove 200, 200 '' ''
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}} '' ''
{{CodeStart}}
{{Cl|DECLARE LIBRARY}} ""
{{Cl|FUNCTION}} addone&amp; ({{Cl|BYVAL}} value&amp;)
{{Cl|END}} DECLARE '' ''
{{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE
{{CodeEnd}}
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.'''
&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>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
@ -100,4 +102,4 @@ MouseMove 200, 200 '' ''
{{PageNavigation}}
<

View file

@ -1 +0,0 @@
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:00}}
[[CALL]] sends code execution to a subroutine procedure in a program. In '''QB64''' the subroutine doesn't need to be declared.
@ -22,7 +24,7 @@
{{PageExamples}}
''Example:'' How parameters are passed in two [[SUB]] calls, one with CALL using brackets and one without CALL or brackets:
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DIM}} a {{Cl|AS}} {{Cl|INTEGER}} 'value not shared with SUB
{{Cl|DIM}} {{Cl|SHARED}} b {{Cl|AS}} {{Cl|INTEGER}} 'value shared with any SUB
a = 1
@ -40,7 +42,7 @@ helloworld a 'a passed to c parameter w/o CALL
a = a + 1 'a is a SUB value of 0 when printed which may increase inside SUB only
b = b + 1 'b is a shared value which can increase anywhere
c = c + 1 'c is a SUB parameter value from a in calls which may increase inside SUB only
{{Cl|END SUB}} '' ''
{{Cl|END SUB}}
{{CodeEnd}}
''Returns:''
@ -62,4 +64,4 @@ Hello World!
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:11:41}}
[[CALL ABSOLUTE]] is used to access interrupts on the computer or execute assembly type procedures.
@ -5,8 +7,8 @@
: [[CALL ABSOLUTE]]([{{Parameter|argumentList}},] {{Parameter|integerOffset}})
==Legacy support==
* [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, the '''use [[_MOUSEINPUT]] and related functions'''.
{{PageLegacySupport}}
* [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, use [[_MOUSEINPUT]] and related functions.
{{PageDescription}}
@ -24,4 +26,4 @@
{{PageNavigation}}
<

View file

@ -1,2 +0,0 @@
#REDIRECT [[SELECT CASE]]
<

View file

@ -0,0 +1,4 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:03}}
See page [[SELECT CASE]]

View file

@ -1,2 +0,0 @@
#REDIRECT [[SELECT CASE]]
<

View file

@ -0,0 +1,4 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:04}}
See page [[SELECT CASE]]

View file

@ -1,2 +0,0 @@
#REDIRECT [[SELECT CASE]]
<

View file

@ -0,0 +1,4 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:05}}
See page [[SELECT CASE]]

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:06}}
[[CDBL]] converts a value to the closest [[DOUBLE]]-precision value.
@ -32,4 +34,4 @@
{{PageNavigation}}
<

View file

@ -1 +0,0 @@
<

View file

@ -1,13 +1,16 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:09}}
[[CHAIN]] is used to change seamlessly from one module to another one in a program.
==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$}}
{{PageLegacySupport}}
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[CHAIN]] statement has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.
{{Parameters}}
* {{Parameter|moduleName$}} is a variable or a literal [[STRING]] value in quotation marks with the optional EXE or BAS file name extension.
@ -29,8 +32,8 @@
{{PageExamples}}
''Example:'' CHAIN looks for same file type extension as program module (BAS or EXE).
{{CodeStart}} '' ''
{{Cl|CHAIN}} "Level1" '' ''
{{CodeStart}}
{{Cl|CHAIN}} "Level1"
{{CodeEnd}}
''Explanation:'' The file referred to is "Level1.BAS" if the program module using the call is a BAS file. If the program was compiled, it would look for "Level1.EXE".
@ -44,4 +47,4 @@
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:10}}
The [[CHDIR]] statement changes the program's location from one working directory to another by specifying a literal or variable [[STRING]] path.
@ -14,16 +16,16 @@ The [[CHDIR]] statement changes the program's location from one working director
{{PageExamples}}
''Example 1:'' The following code is Windows-specific:
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|CHDIR}} "C:\" 'change to the root drive C (absolute path)
{{Cl|CHDIR}} "DOCUME~1" 'change to "C:\Documents and Settings" from root drive (relative path)
{{Cl|CHDIR}} "..\" 'change back to previous folder one up '' ''
{{Cl|CHDIR}} "..\" 'change back to previous folder one up
{{CodeEnd}}
:''Details:'' '''QB64''' can use long or short (8.3 notation) file and path names.
''Example 2:'' Using the Windows API to find the current program's name and root path. The PATH$ is a shared function value.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|_TITLE}} "My program"
{{Cl|PRINT}} TITLE$
{{Cl|PRINT}} PATH$
@ -48,7 +50,7 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
PATH$ = {{Cl|LEFT$}}(PATH$, last)
{{Cl|ELSE}} TITLE$ = "": PATH$ = ""
{{Cl|END IF}}
{{Cl|END FUNCTION}} '' ''
{{Cl|END FUNCTION}}
{{CodeEnd}}
: '''Note:''' The program's [[_TITLE]] name may be different from the actual program module's file name returned by Windows.
@ -60,4 +62,4 @@ Result = GetModuleFileNameA(0, FileName$, {{Cl|LEN}}(FileName$)) '0 designates
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:12}}
The [[CHR$]] function returns the character associated with a certain [[ASCII|character code]] as a [[STRING]].
@ -38,13 +40,13 @@ This text uses "quotation marks" that could have caused a syntax error!
''Example 3:'' Using [[ASC]] and [[CHR$]] to ''encrypt'' a text file size up to 32K bytes
{{CodeStart}}{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1 ' FileName to be encrypted
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) &lt;= 32000 {{Cl|THEN}} Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' get Text as one string
{{Cl|IF...THEN|IF}} {{Cl|LOF}}(1) <= 32000 {{Cl|THEN}} Text$ = {{Cl|INPUT$}}({{Cl|LOF}}(1), 1) ' get Text as one string
{{Cl|CLOSE}} #1
Send$ = "" ' clear value
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1) ' get each character in the text
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code &lt; 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code &lt; 123) {{Cl|THEN}}
{{Cl|IF...THEN|IF}} (Code > 64 {{Cl|AND (boolean)|AND}} Code < 91) {{Cl|OR (boolean)|OR}} (Code > 96 {{Cl|AND (boolean)|AND}} Code < 123) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code + 130) ' change letter's ASCII character by 130
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string with just letters encrypted
@ -64,14 +66,14 @@ Send$ = ""
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} {{Cl|LEN}}(Text$)
Letter$ = {{Cl|MID$}}(Text$, i, 1)
Code = {{Cl|ASC}}(Letter$)
{{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code &lt; 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code &lt; 253) {{Cl|THEN}}
{{Cl|IF...THEN|IF}} (Code > 194 {{Cl|AND (boolean)|AND}} Code < 221) {{Cl|OR (boolean)|OR}} (Code > 226 {{Cl|AND (boolean)|AND}} Code < 253) {{Cl|THEN}}
Letter$ = {{Cl|CHR$}}(Code - 130) ' change back to a Letter character
{{Cl|END IF}}
Send$ = Send$ + Letter$ ' reassemble string as normal letters
{{Cl|NEXT}} i
{{Cl|OPEN}} FileName$ {{Cl|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 ' Erase file for decrypted text
{{Cl|PRINT (file statement)|PRINT}} #1, Send$ ' place Text as one string
{{Cl|CLOSE}} #1 '' ''
{{Cl|CLOSE}} #1
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' Examples 3 and 4 encrypt and decrypt a file up to 32 thousand bytes. [[INPUT$]] can only get strings less than 32767 characters. The upper and lower case letter characters are the only ones altered, but the encryption and decryption rely on the fact that most text files do not use the code characters above 193. You could alter any character from ASCII 32 to 125 without problems using the 130 adder. No [[ASCII]] code above 255 is allowed. Don't alter the codes below code 32 as they are control characters. Specifically, characters 13 and 10 (CrLf) may be used for line returns in text files.
@ -84,4 +86,4 @@ Send$ = ""
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:13}}
The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value.
@ -18,9 +20,9 @@ The [[CINT]] function rounds decimal point numbers up or down to the nearest [[I
{{PageExamples}}
''Example:'' Shows how CINT rounds values up or down as in "bankers' rounding".
{{CodeStart}} '' ''
{{CodeStart}}
a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c '' ''
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c
{{CodeEnd}}
{{OutputStart}}{{text|1 2 11.5|red}}
{{OutputEnd}}
@ -33,4 +35,4 @@ a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:14}}
The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes to create circles, arcs or ellipses.
@ -10,13 +12,13 @@ The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes
* Coordinates designate the center position of the circle. Can be partially drawn offscreen.
* {{Parameter|radius%}} is an [[INTEGER]] value for half of the total circle diameter.
* {{Parameter|drawColor%}} is any available color attribute in the [[SCREEN (statement)|SCREEN]] mode used.
* {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} can be any [[SINGLE]] value from 0 to 2 * &amp;pi; to create partial circles or ellipses.
* {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} can be any [[SINGLE]] value from 0 to 2 * ã to create partial circles or ellipses.
* {{Parameter|aspect!}} [[SINGLE]] values of 0 to 1 affect the vertical height and values over 1 affect the horizontal width of an ellipse. Aspect = 1 is a normal circle.
{{PageDescription}}
* When using {{Parameter|aspect!}} the {{Parameter|startRadian!}} and {{Parameter|stopRadian!}} commas must be included even if not used.
* Radians move in a counter clockwise direction from 0 to 2 * &amp;pi;. Zero and 2 * &amp;pi; are the same circle radian at 3 o'clock.
* Radians move in a counter clockwise direction from 0 to 2 * ã. Zero and 2 * ã are the same circle radian at 3 o'clock.
* Negative radian values can be used to draw lines from the end of an arc or partial ellipse to the circle center.
* Commas after the {{Parameter|drawColor%}} parameter are not required when creating a normal circle. {{Parameter|drawColor%}} can also be omitted to use the last color used in a draw statement.
* The graphic cursor is set to the center of the program window on program start for [[STEP]] relative coordinates.
@ -25,26 +27,26 @@ The [[CIRCLE]] statement is used in graphic [[SCREEN (statement)|SCREEN]] modes
{{PageExamples}}
''Example 1:'' Finding when the mouse is inside of a circular area:
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} 12
r&amp; = 200 'radius change circle size and position here
cx&amp; = 320 'center x horizontal
cy&amp; = 240 'center y vertical
r& = 200 'radius change circle size and position here
cx& = 320 'center x horizontal
cy& = 240 'center y vertical
DO
i = {{Cl|_MOUSEINPUT}}
x&amp; = {{Cl|_MOUSEX}}
y&amp; = {{Cl|_MOUSEY}}
xy&amp; = ((x&amp; - cx&amp;) ^ 2) + ((y&amp; - cy&amp;) ^ 2) 'Pythagorean theorem
{{Cl|IF...THEN|IF}} r&amp; ^ 2 >= xy&amp; {{Cl|THEN}} {{Cl|CIRCLE}} (cx&amp;, cy&amp;), r&amp;, 10 {{Cl|ELSE}} {{Cl|CIRCLE}} (cx&amp;, cy&amp;), r&amp;, 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit '' ''
x& = {{Cl|_MOUSEX}}
y& = {{Cl|_MOUSEY}}
xy& = ((x& - cx&) ^ 2) + ((y& - cy&) ^ 2) 'Pythagorean theorem
{{Cl|IF...THEN|IF}} r& ^ 2 >= xy& {{Cl|THEN}} {{Cl|CIRCLE}} (cx&, cy&), r&, 10 {{Cl|ELSE}} {{Cl|CIRCLE}} (cx&, cy&), r&, 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit
{{CodeEnd}}
: ''Explanation:'' The square of the circle radius will be greater than or equal to the sum of the square of the mouse coordinates minus the center position when the pointer is inside of the circle. In this example the circle color will change from red to green.
''Example 2:'' Program illustrates how the CIRCLE command using a negative radian value can be used to create the hands of a clock.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|CONST}} PI = 3.141593 'The mathematical value of PI to six places. You can also use QB64's native _PI.
{{Cl|DIM}} clock(60) 'A dimensioned array to hold 60 radian points
clockcount% = 15 'A counter to keep track of the radians
@ -95,7 +97,7 @@ previoushour% = hours% 'hold current hour for later use
'* Start of main program loop
'*
{{Cl|DO}}
{{Cl|IF...THEN|IF}} seconds% &lt;> previoussecond% {{Cl|THEN}} 'has a second elapsed?
{{Cl|IF...THEN|IF}} seconds% <> previoussecond% {{Cl|THEN}} 'has a second elapsed?
{{Cl|LOCATE}} 22, 17 'print the time on the screen at
{{Cl|PRINT}} {{Cl|TIME$}}; 'position 22, 17
'* Since a second has elapsed we need to erase the old second hand
@ -104,7 +106,7 @@ previoushour% = hours% 'hold current hour for later use
{{Cl|CIRCLE}} (160, 100), 100, 0, -clock(previoussecond%), clock(previoussecond%)
{{Cl|CIRCLE}} (160, 100), 100, 15, -clock(seconds%), clock(seconds%)
previoussecond% = seconds% 'hold current second for later use
{{Cl|IF...THEN|IF}} minutes% &lt;> previousminute% {{Cl|THEN}} 'has a minute elapsed?
{{Cl|IF...THEN|IF}} minutes% <> previousminute% {{Cl|THEN}} 'has a minute elapsed?
'* Since a minute has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 90, 0, -clock(previousminute%), clock(previousminute%)
previousminute% = minutes% 'hold current minute for later use
@ -113,7 +115,7 @@ previoushour% = hours% 'hold current hour for later use
'* Draw the current minute hand position
'*
{{Cl|CIRCLE}} (160, 100), 90, 14, -clock(minutes%), clock(minutes%)
{{Cl|IF...THEN|IF}} hours% &lt;> previoushour% {{Cl|THEN}} 'has an hour elapsed?
{{Cl|IF...THEN|IF}} hours% <> previoushour% {{Cl|THEN}} 'has an hour elapsed?
'* Since an hour has elapsed we need to erase the old hour hand position
{{Cl|CIRCLE}} (160, 100), 75, 0, -clock(previoushour% * 5), clock(previoushour% * 5)
previoushour% = hours% 'hold current hour for later use
@ -130,8 +132,7 @@ previoushour% = hours% 'hold current hour for later use
hours% = {{Cl|VAL}}({{Cl|LEFT$}}({{Cl|TIME$}}, 2))
{{Cl|IF...THEN|IF}} hours% >= 12 {{Cl|THEN}} hours% = hours% - 12
{{Cl|IF...THEN|IF}} hours% = 0 {{Cl|THEN}} hours% = 12
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} &lt;> "" 'stop program if user presses a key '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'stop program if user presses a key
{{CodeEnd}}
{{small|code by Terry Ritchie}}
@ -143,4 +144,4 @@ previoushour% = hours% 'hold current hour for later use
* [[Alternative circle routine]] {{text|(member-contributed program)}}
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:15}}
The [[CLEAR]] statement clears all variable and array element values in a program.
{{PageSyntax}}
: [[CLEAR]] [, {{Parameter|ignored&amp;}} , {{Parameter|ignored&amp;}}]
: [[CLEAR]] [, {{Parameter|ignored&}} , {{Parameter|ignored&}}]
{{PageDescription}}
@ -15,7 +17,7 @@ The [[CLEAR]] statement clears all variable and array element values in a progra
{{PageExamples}}
''Example:'' Using CLEAR to clear array elements from [[STATIC|static]] arrays or arrays created using [[DIM]].
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|CLS}}
{{Cl|DIM}} array(10) 'create a {{Cl|$STATIC}} array
array(5) = 23
@ -24,7 +26,7 @@ array(5) = 23
{{Cl|CLEAR}}
{{Cl|PRINT}} array(5) '' ''
{{Cl|PRINT}} array(5)
{{CodeEnd}}
:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR.
@ -32,8 +34,8 @@ array(5) = 23
{{PageSeeAlso}}
* [[ERASE]]
* [[REDIM]], [[_PRESERVE]]
* [[Arrays]], [[&amp;B|_BIT arrays]]
* [[Arrays]], [[&B|_BIT arrays]]
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:17}}
The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[LONG]] integer value.
{{PageSyntax}}
: {{Parameter|value&amp;}} = [[CLNG]]({{Parameter|expression}})
: {{Parameter|value&}} = [[CLNG]]({{Parameter|expression}})
{{Parameters}}
@ -18,7 +20,7 @@ The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[L
{{PageExamples}}
{{CodeStart}}
a&amp; = {{Cl|CLNG}}(2345678.51)
a& = {{Cl|CLNG}}(2345678.51)
{{Cl|PRINT}}
{{CodeEnd}}
@ -34,4 +36,4 @@ The [[CLNG]] function rounds decimal point numbers up or down to the nearest [[L
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:18}}
[[CLOSE]] closes an open file or port using the number(s) assigned in an [[OPEN]] statement.
@ -27,4 +29,4 @@
{{PageNavigation}}
<

View file

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

View file

@ -1,239 +0,0 @@
The [[COLOR]] statement is used to change the foreground and background colors for printing text.
{{PageSyntax}}
: [[COLOR]] [{{Parameter|foreground&amp;}}][, {{Parameter|background&amp;}}]
{{PageDescription}}
* {{Parameter|background&amp;}} colors are available in all QB64 color SCREEN modes.
* [[SCREEN]] mode 10 has only 3 white foreground attributes including flashing.
* To change the {{Parameter|background&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.
==Screen Mode Attributes==
* '''SCREEN 0''' {{Parameter|background&amp;}} colors 0 to 7 can be changed each text character without affecting other text. Use [[CLS]] after a background color statement to create a fullscreen background color. 64 [[DAC]] hues with 16 high intensity blinking foreground (16 to 31) color attributes. See [[_BLINK]].
** See example 7 below for more SCREEN 0 background colors.
* '''SCREEN 1''' has '''4 background color attributes''': 0 = black, 1 = blue, 2 = green, 3 = grey. White foreground color only.
* '''SCREEN 2''' is '''monochrome''' with white forecolor and black background.
* '''SCREEN 7''' can use 16 ([[DAC]]) colors with background colors. RGB settings can be changed in colors 0 to 7 using [[_PALETTECOLOR]].
* '''SCREEN 8''' has 16 color attributes with 16 background colors.
* '''SCREEN 9''' can use up to 64 [[DAC]] color hues in 16 color attributes with background colors assigned to attribute 0 with a [[_PALETTECOLOR]] swap. RGB settings can be changed in colors 0 to 5 and 7 using [[_PALETTECOLOR]].
* '''SCREEN 10''' has '''only 4 color attributes''' with black background. COLOR 0 = black, 1 = grey, 2 = flash white and 3 = bright white.
* '''SCREEN 11''' is '''monochrome''' with white forecolor and a black background.
* '''SCREEN 12''' can use 16 color attributes with a black background. 256K possible RGB color hues. Background colors can be used with QB64.
* '''SCREEN 13''' can use 256 color attributes with a black background. 256K possible RGB hues.
* [[PALETTE]] swaps can be made in SCREEN 7 and 9 only. Those screens were [[DAC]] screen modes in QBasic.
* [[_DEST]] can be used to set the destination page or image to color using '''QB64'''.
* [[_DEFAULTCOLOR]] returns the current color being used on an image or screen page handle.
===24/32-Bit colors using QB64===
* Pixel color intensities for red, green, blue and alpha range from 0 to 255 when used with [[_RGB]], [[_RGBA]], [[_RGB32]] and [[RGBA32]].
* Combined RGB function values returned are [[LONG]] values. '''Blue intensity values may be cut off using [[SINGLE]] variables.'''
* [[_ALPHA]] transparency values can range from 0 as transparent up to 255 which is fully opaque.
* [[_CLEARCOLOR]] can also be used to set a color as transparent.
* Colors can be mixed by using [[_BLEND]] (default) in 32-bit screen modes. [[_DONTBLEND]] disables blending.
* '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.'''
&lt;p style="text-align: center">([[#toc|Return to Table of Contents]])&lt;/p>
==RGB Palette Intensities==
RGB intensity values can be converted to hexadecimal values to create the [[LONG]] [[_PALETTECOLOR]] value in non-32-bit screens:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
alpha$ = "FF" 'solid alpha colors only
{{Cl|OUT}} {{Cl|&amp;H}}3C8, 0: {{Cl|OUT}} {{Cl|&amp;H}}3C9, 0: {{Cl|OUT}} {{Cl|&amp;H}}3C9, 0: {{Cl|OUT}} {{Cl|&amp;H}}3C9, 20 'set black background to dark blue
{{Cl|PRINT}} "Attribute = Hex value Red Green Blue "
{{Cl|PRINT}}
{{Cl|COLOR}} 7
{{Cl|FOR...NEXT|FOR}} attribute = 0 {{Cl|TO}} 15
{{Cl|OUT}} {{Cl|&amp;H}}3C7, attribute 'set color attribute to read
red$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&amp;H}}3C9) * 4) 'convert port setting to 32 bit values
grn$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&amp;H}}3C9) * 4)
blu$ = {{Cl|HEX$}}({{Cl|INP}}({{Cl|&amp;H}}3C9) * 4)
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(red$) = 1 {{Cl|THEN}} red$ = "0" + red$ '2 hex digits required
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(grn$) = 1 {{Cl|THEN}} grn$ = "0" + grn$ 'for low or zero hex values
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(blu$) = 1 {{Cl|THEN}} blu$ = "0" + blu$
hex32$ = "{{Cl|&amp;H}}" + alpha$ + red$ + grn$ + blu$
{{Cl|_PALETTECOLOR}} attribute, {{Cl|VAL}}(hex32$) 'VAL converts hex string to a LONG 32 bit value
{{Cl|IF...THEN|IF}} attribute {{Cl|THEN}} {{Cl|COLOR}} attribute 'exclude black color print
{{Cl|PRINT}} "{{Cl|COLOR}}" + {{Cl|STR$}}(attribute) + " = " + hex32$, red$, grn$, blu$ 'returns closest attribute
{{Cl|NEXT}} '' ''
{{CodeEnd}}
{{OutputStart}}Attribute Hex value Red Green Blue
{{text|COLOR 0 &lt;nowiki>=&lt;/nowiki> &amp;HFF000050 00 00 50|#A8A8A8}}
{{text|COLOR 1 &lt;nowiki>=&lt;/nowiki> &amp;HFF0000A8 00 00 A8|#0050A8}}
{{text|COLOR 2 &lt;nowiki>=&lt;/nowiki> &amp;HFF00A800 00 A8 00|#00A800}}
{{text|COLOR 3 &lt;nowiki>=&lt;/nowiki> &amp;HFF00A8A8 00 A8 A8|#00A8A8}}
{{text|COLOR 4 &lt;nowiki>=&lt;/nowiki> &amp;HFFA80000 A8 00 00|#A80000}}
{{text|COLOR 5 &lt;nowiki>=&lt;/nowiki> &amp;HFFA800A8 A8 00 A8|#A800A8}}
{{text|COLOR 6 &lt;nowiki>=&lt;/nowiki> &amp;HFFA85400 A8 54 00|#A85400}}
{{text|COLOR 7 &lt;nowiki>=&lt;/nowiki> &amp;HFFA8A8A8 A8 A8 A8|#A8A8A8}}
{{text|COLOR 8 &lt;nowiki>=&lt;/nowiki> &amp;HFF545454 54 54 54|#545454}}
{{text|COLOR 9 &lt;nowiki>=&lt;/nowiki> &amp;HFF5454FC 54 54 FC|#5454FC}}
{{text|COLOR 10 &lt;nowiki>=&lt;/nowiki> &amp;HFF54FC54 54 FC 54|#54FC54}}
{{text|COLOR 11 &lt;nowiki>=&lt;/nowiki> &amp;HFF5454FC 54 FC FC|#54FCFC}}
{{text|COLOR 12 &lt;nowiki>=&lt;/nowiki> &amp;HFFFC5454 FC 54 54|#FC5454}}
{{text|COLOR 13 &lt;nowiki>=&lt;/nowiki> &amp;HFFFC54FC FC 54 FC|#FC54FC}}
{{text|COLOR 14 &lt;nowiki>=&lt;/nowiki> &amp;HFFFCFC54 FC FC 54|#FCFC54}}
{{text|COLOR 15 &lt;nowiki>=&lt;/nowiki> &amp;HFFFCFCFC FC FC FC|#FCFCFC}}
{{OutputEnd}}
:''Explanation:'' The RGB intensity values are multiplied by 4 to get the [[_RGB]] intensity values as [[HEX$|hexadecimal]] values. The individual 2 digit [[HEX$]] intensity values can be added to "&amp;HFF" to make up the 32-bit hexadecimal string value necessary for [[VAL]] to return to [[_PALETTECOLOR]]. The statement is only included in the example to show how that can be done with any 32-bit color value.
:'''Note:''' Black has a blue hex value of 50 due to the [[OUT]] background color setting which makes it dark blue.
===Reading and setting color port intensities using [[INP]] and [[OUT]]===
* Legacy code may use [[INP]] and [[OUT]] to read or set color port intensities. '''QB64''' emulates VGA memory to maintain compatibility.
* The same can be achieved using [[_PALETTECOLOR]] ('''recommended practice''').
:'''{{text|OUT &amp;H3C7, attribute|green}}''' 'Set port to read RGB settings with:
:'''{{text|color_intensity &lt;nowiki>=&lt;/nowiki> INP(&amp;H3C9)|green}}''' 'reads present intensity setting
:'''{{text|OUT &amp;H3C8, attribute|green}}''' 'Set port to write RGB settings with:
:'''{{text|OUT &amp;H3C9, color_intensity|green}}''' 'writes new intensity setting
* After every 3 reads or writes, changes to next higher color attribute. Loops can be used to set more than one attribute's intensities.
* Color port setting of red, green and blue intensities can be done in ascending order.
* Color port attribute intensity values range from 0 to 63 (1/4 of the 32-bit values) in QBasic's legacy 4 and 8 bit screen modes.
&lt;p style="text-align: center">([[#toc|Return to Table of Contents]])&lt;/p>
{{PageExamples}}
''Example 1:'' Reading the default RGB color settings of color attribute 15.
{{CodeStart}} '' ''
{{Cl|OUT}} &amp;H3C7, 15
red% = {{Cl|INP}}(&amp;H3C9)
green% = {{Cl|INP}}(&amp;H3C9)
blue% = {{Cl|INP}}(&amp;H3C9)
{{Cl|PRINT}} red%, green%, blue% '' ''
{{CodeEnd}}
{{OutputStart}}
63 63 63
{{OutputEnd}}
''Example 2:'' Changing the color settings of attribute 0 (the background) to dark blue in [[SCREEN]]s 12 or 13.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 12
{{Cl|OUT}} {{Cl|&amp;H}}3C8, 0 'set color port attribute to write
{{Cl|OUT}} {{Cl|&amp;H}}3C9, 0 'red intensity
{{Cl|OUT}} {{Cl|&amp;H}}3C9, 0 'green intensity
{{Cl|OUT}} {{Cl|&amp;H}}3C9, 30 'blue intensity
{{Cl|OUT}} {{Cl|&amp;H}}3C7, 0
{{Cl|PRINT}} {{Cl|INP}}({{Cl|&amp;H}}3C9); {{Cl|INP}}({{Cl|&amp;H}}3C9); {{Cl|INP}}({{Cl|&amp;H}}3C9)
{{Cl|END}}'' ''
{{CodeEnd}}
{{CodeStart}} 0 0 30 {{CodeEnd}}
''Example 3:'' Printing in fullscreen SCREEN 0 mode with a color background under the text only.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}} ' used for fullscreen instead of window
{{Cl|COLOR}} 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]].
''Example 4:'' Using [[CLS]] after setting the background color in SCREEN 0 to make the color cover the entire screen.
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0: {{Cl|_FULLSCREEN}}
{{Cl|COLOR}} , 7: {{Cl|CLS}}
{{Cl|COLOR}} 9: {{Cl|PRINT}} "Hello" '' ''
{{CodeEnd}}
{{TextStart}}{{text|Hello|blue}}{{TextEnd}}
:''Result:'' The blue word Hello is printed to a totally grey background in [[_FULLSCREEN|fullscreen]].
''Example 5:'' Using a different foreground color for each letter:
{{CodeStart}} '' ''
{{Cl|SCREEN}} 0
{{Cl|COLOR}} 1: {{Cl|PRINT}} "H";
{{Cl|COLOR}} 3: {{Cl|PRINT}} "E";
{{Cl|COLOR}} 4: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 5: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 6: {{Cl|PRINT}} "O"
{{Cl|COLOR}} 9: {{Cl|PRINT}} "W";
{{Cl|COLOR}} 11: {{Cl|PRINT}} "O";
{{Cl|COLOR}} 12: {{Cl|PRINT}} "R";
{{Cl|COLOR}} 13: {{Cl|PRINT}} "L";
{{Cl|COLOR}} 14: {{Cl|PRINT}} "D" '' ''
{{CodeEnd}}
{{OutputStart}}
{{text|H|darkblue}}{{text|E|darkcyan}}{{text|L|darkred}}{{text|L|darkmagenta}}{{text|O|goldenrod}}
{{text|W|blue}}{{text|O|cyan}}{{text|R|red}}{{text|L|magenta}}{{text|D|yellow}}
{{OutputEnd}}
''Example 6:'' Doing the same as Example 5 but in only a few lines:
{{CodeStart}} '' ''
{{Cl|SCREEN (statement)|SCREEN}} 0
text$ = "HelloWorld"
{{Cl|FOR...NEXT|FOR}} textpos = 1 {{Cl|TO}} {{Cl|LEN}}(text$)
{{Cl|COLOR}} textpos
{{Cl|IF...THEN|IF}} textpos &lt;> 5 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|MID$}}(text$, textpos, 1);
{{Cl|IF...THEN|IF}} textpos = 5 {{Cl|THEN}} {{Cl|PRINT}} {{Cl|MID$}}(text$, textpos, 1) 'start print on next row
{{Cl|NEXT}}
{{CodeEnd}}
{{OutputStart}}
{{text|H|darkblue}}{{text|e|darkgreen}}{{text|l|darkcyan}}{{text|l|darkred}}{{text|o|darkmagenta}}
{{text|W|goldenrod}}{{text|o|lightgrey}}{{text|r|dimgray}}{{text|l|blue}}{{text|d|lime}} '' ''
{{OutputEnd}}
: ''Explanation:''Semicolon(;) means that the next PRINT happens on the same line, we don't want that when it comes to position 5 so when it is at position 5 the next PRINT will move to the next line (when it isn't at position 5 we want it to continue printing the letter side-by-side on the same line though).
''Example 7:'' Since SCREEN 0 only uses background colors 0 to 7 by default, use [[_PALETTECOLOR]] to change color intensities of color 0.
{{CodeStart}} '' ''
{{Cl|_PALETTECOLOR}} 0, _RGB32(255, 255, 255) 'change color 0 intensity
{{Cl|_PALETTECOLOR}} 8, _RGB32(0, 0, 0) 'change color 8 intensity
{{Cl|COLOR}} 8: {{Cl|PRINT}} "Black on bright white!" '' ''
{{CodeEnd}}
{{WhiteStart}}'''{{text|Black on bright white!|#000000}}'''
{{WhiteEnd}}
----
: ''Explanation:'' Since QB64 does not have [[DAC]] [[SCREEN]] 0 limitations, changing color intensities for custom background colors is possible.
''Example 8:'' Changing light gray text in [[SCREEN]] 0 to a 32 bit custom color using a [[LONG]] HTML hexadecimal value:
{{CodeStart}} '' ''
{{Cl|COLOR}} 7
{{Cl|PRINT}} "Color 7 is gray"
K$ = {{Cl|INPUT$}}(1)
{{Cl|_PALETTECOLOR}} 7, {{Cl|&amp;H}}FFDAA520 ' FF alpha makes the color translucent
{{Cl|PRINT}} "Color 7 is now Goldenrod in {{Cl|SCREEN}} 0! '' ''
{{CodeEnd}}
{{OutputStart}}
{{text|Color 7 is gray|#A8A8A8}}
{{text|Color 7 is now Goldenrod in SCREEN 0!|#DAA520}}
{{OutputEnd}}
: ''Explanation:'' [[_RGB32]] could be used to make custom 32 bit colors or HTML values could be used after &amp;HFF for solid colors.
&lt;p style="text-align: center">([[#toc|Return to Table of Contents]])&lt;/p>
{{PageSeeAlso}}
* [[$COLOR]] (metacommand)
* [[_RGB]], [[_RGBA]], [[_RGB32]], [[RGBA32]].
* [[_RED]], [[_GREEN]], [[_BLUE]]
* [[_RED32]], [[_GREEN32]], [[_BLUE32]]
* [[_ALPHA]], [[_ALPHA32]], [[_CLEARCOLOR]]
* [[PRINT]], [[LOCATE]], [[SCREEN]]
* [[POINT]], [[SCREEN (function)]]
* [[OUT]], [[INP]], [[PALETTE]]
* [[_BLINK]]
* [[_DEFAULTCOLOR]]
* [[_BACKGROUNDCOLOR]]
* [[_PALETTECOLOR]]
* [[Windows_Libraries#Color_Dialog_Box|Color Dialog Box]]
* [http://www.w3schools.com/html/html_colornames.asp Hexadecimal Color Values]
{{PageNavigation}}
<

View file

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

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:22}}
The '''COMMAND$''' function returns the command line argument(s) passed when a program is run.
@ -24,13 +26,13 @@ K$ = {{Cl|INPUT$}}(1)
{{Cl|SYSTEM}}
{{CodeEnd}}
: ''ProgramB'' checks for fullscreen parameter pass in QB64 and goes full screen.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|LOCATE}} 17, 36: {{Cl|PRINT}} "ProgramB"
parameter$ = {{Cl|UCASE$}}({{Cl|COMMAND$}}) 'UCASE$ is needed in QB64 only, as QB4.5 will always return upper case
{{Cl|LOCATE}} 20, 33: {{Cl|PRINT}} "Parameter = " + parameter$
{{Cl|IF...THEN|IF}} {{Cl|LEFT$}}(parameter$, 2) = "FS" {{Cl|THEN}} {{Cl|_FULLSCREEN}} 'parameter changes to full screen
{{Cl|END}} '' ''
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
ProgramB
@ -59,7 +61,7 @@ a data file
cmd$ = {{Cl|COMMAND$}}(count)
{{Cl|IF...THEN|IF}} cmd$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} 'read until an empty return
{{Cl|PRINT}} cmd$ 'or process commands sent
{{Cl|LOOP}} '' ''
{{Cl|LOOP}}
count = count - 1 'save the number of parameters sent to this program when run
{{CodeEnd}}
@ -71,4 +73,4 @@ count = count - 1 'save the number of parameters sent to this program when run
{{PageNavigation}}
<

View file

@ -1,13 +1,15 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:23}}
[[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules.
==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.'''
{{PageSyntax}}
: [[COMMON]] [SHARED] variableList
{{PageLegacySupport}}
* The multi-modular technique goes back to when '''QBasic''' and '''QuickBASIC''' had module size constraints. In '''QB64''' the [[COMMON]] statement has been implemented so that that older code can still be compiled, though it is advisable to use single modules for a single project (not counting [[$INCLUDE]] libraries), for ease of sharing and also because the module size constraints no longer exist.
{{PageDescription}}
* COMMON must be called before any executable statements.
* [[SHARED]] makes the variables shared within [[SUB]] and [[FUNCTION]] procedures within that module.
@ -23,4 +25,4 @@
* [[DEFSTR]], [[DEFLNG]], [[DEFINT]], [[DEFSNG]], [[DEFDBL]]
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:24}}
The [[CONST]] statement globally defines one or more named numeric or string values which will not change while the program is running.
@ -54,7 +56,7 @@ Enter the radius of a circle or zero to quit? ''0''
''Example 2'': Using _RGB32 to set a constant's value.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|CONST}} Red = _RGB32(255,0,0)
{{Cl|COLOR}} Red
@ -69,4 +71,4 @@ Enter the radius of a circle or zero to quit? ''0''
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:25}}
The [[COS]] function returns the horizontal component or the cosine of an angle measured in radians.
@ -10,15 +12,15 @@ The [[COS]] function returns the horizontal component or the cosine of an angle
{{PageDescription}}
* To convert from degrees to radians, multiply degrees * &amp;pi; / 180.
* [[COS]]INE is the horizontal component of a unit vector in the direction theta (&amp;theta;).
* To convert from degrees to radians, multiply degrees * ã / 180.
* [[COS]]INE is the horizontal component of a unit vector in the direction theta (é).
* COS(x) can be calculated in either [[SINGLE]] or [[DOUBLE]] precision depending on its argument.
::: COS(4) = -.6536436 ...... COS(4#) = -.6536436208636119
{{PageExamples}}
''Example 1:'' Converting degree angles to radians for QBasic's trig functions and drawing the line at the angle.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} 12
PI = 4 * {{Cl|ATN}}(1)
{{Cl|PRINT}} "PI = 4 * {{Cl|ATN}}(1) ="; PI
@ -35,7 +37,7 @@ PI = 4 * {{Cl|ATN}}(1)
{{Cl|LINE}} (400, 240)-(400 + (50 * {{Cl|SIN}}(RADIANS)), 240 + (50 * {{Cl|COS}}(RADIANS))), 11
DEGREES% = RADIANS * 180 / PI
{{Cl|PRINT}} "DEGREES% = RADIANS * 180 / PI ="; DEGREES%
{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0 '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} DEGREES% = 0
{{CodeEnd}}
{{OutputStart}}
PI = 4 * ATN(1) = 3.141593
@ -52,7 +54,7 @@ DEGREES% = RADIANS * 180 / PI = 45
''Example 2:'' Creating 12 analog clock hour points using [[CIRCLE]]s and [[PAINT]]
{{CodeStart}} '' ''
{{CodeStart}}
PI2 = 8 * {{Cl|ATN}}(1) '2 * π
arc! = PI2 / 12 'arc interval between hour circles
{{Cl|SCREEN (statement)|SCREEN}} 12
@ -61,14 +63,14 @@ DEGREES% = RADIANS * 180 / PI = 45
cy% = {{Cl|CINT}}({{Cl|SIN}}(t!) * 70) ' pixel rows
{{Cl|CIRCLE}} (cx% + 320, cy% + 240), 3, 12
{{Cl|PAINT}} {{Cl|STEP}}(0, 0), 9, 12
NEXT '' ''
NEXT
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
''Explanation:'' The 12 circles are placed at radian angles that are 1/12 of 6.28318 or .523598 radians apart.
''Example 3:'' Creating a rotating spiral with COS and [[SIN]].
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
{{Cl|DO...LOOP|DO}}
@ -89,7 +91,7 @@ DEGREES% = RADIANS * 180 / PI = 45
{{Cl|_DISPLAY}}
{{Cl|_LIMIT}} 30
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INP}}({{Cl|&amp;H}}60) = 1 'escape exit '' ''
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INP}}({{Cl|&H}}60) = 1 'escape exit
{{CodeEnd}}
{{small|Code by Ben}}
@ -104,4 +106,4 @@ DEGREES% = RADIANS * 180 / PI = 45
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:27}}
[[CSNG]] converts a numerical value to the closest [[SINGLE]]-precision number.
@ -30,4 +32,4 @@
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:28}}
The [[CSRLIN]] function returns the current text row position of the [[PRINT]] cursor.
@ -16,13 +18,13 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
{{PageExamples}}
''Example:'' A semicolon stops the print cursor immediately after the print.
{{CodeStart}} '' ''
{{CodeStart}}
LOCATE 5, 5: PRINT "HELLO ";
Y = {{Cl|CSRLIN}} 'save the row
X = {{Cl|POS}}(0) 'save the column
LOCATE 10, 10: PRINT "WORLD"
LOCATE Y, X 'restore saved position
PRINT "GOODBYE" '' ''
PRINT "GOODBYE"
{{CodeEnd}}
{{OutputStart}}
@ -48,4 +50,4 @@ The [[CSRLIN]] function returns the current text row position of the [[PRINT]] c
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:31}}
The [[CVDMBF]] function decodes an 8-byte [[STRING]] generated by [[MKDMBF$]] (or read from a file) to [[DOUBLE]] numeric values.
@ -37,4 +39,4 @@ The string above, decoded using CVDMBF: 77000.24523213
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:29}}
The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read from a file) to [[DOUBLE]] numeric values.
@ -14,10 +16,10 @@ The [[CVD]] function decodes an 8-byte [[STRING]] generated by [[MKD$]] (or read
{{PageExamples}}
''Example 1:'' Reading an 8-byte encoded string n$ from a file and obtaining the decoded [[DOUBLE]] value:
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|FIELD}} #1, 8 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y# = {{Cl|CVD}}(N$) '' ''
Y# = {{Cl|CVD}}(N$)
{{CodeEnd}}
: ''Explanation:'' Reads a field from file #1, and converts the first eight bytes (N$) into an double-precision number assigned to the variable Y#.
@ -48,4 +50,4 @@ The string above, decoded using CVD: 77000.24523213
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:32}}
The [[CVI]] function decodes a 2-byte [[STRING]] generated by [[MKI$]] (or read from a file) to [[INTEGER]] numeric values.
@ -14,10 +16,10 @@ The [[CVI]] function decodes a 2-byte [[STRING]] generated by [[MKI$]] (or read
{{PageExamples}}
''Example 1:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|FIELD}} #1, 2 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1 'GET does not need a position or variable with successive FIELD buffer reads
Y = {{Cl|CVI}}(N$) '' ''
Y = {{Cl|CVI}}(N$)
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first two bytes (N$) into an integer number assigned to the variable Y.
:Since the representation of an integer number can use up to 5 ASCII characters (five bytes), writing to a file using [[MKI$]] conversion, and then reading back with the [[CVI]] conversion can save up to 3 bytes of storage space.
@ -31,12 +33,12 @@ Q = {{Cl|CHR$}}(34)
' create Print using templates to align the values returned
tmp1$ = "1st character code = ### * 1 = ### "
tmp2$ = "2nd character code = ### * 256 = ##### "
tmp3$ = " &amp; "
tmp3$ = " & "
tmp4$ = " CVI Total = ##### "
{{Cl|DO...LOOP|DO}}
{{Cl|COLOR}} 14: {{Cl|LOCATE}} 13, 20: {{Cl|INPUT}} "Enter an Integer from 1 to 32767(0 quits): ", number%
{{Cl|IF...THEN|IF}} number% &lt; 1 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|IF...THEN|IF}} number% < 1 {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|CLS}}
ASCII$ = {{Cl|MKI$}}(number%) ' create the 2 byte character string
{{Cl|COLOR}} 11
@ -50,7 +52,7 @@ tmp4$ = " CVI Total = ##### "
{{Cl|LOCATE}} 20, 20: {{Cl|PRINT USING}} tmp3$; "-----"
{{Cl|LOCATE}} 21, 20: {{Cl|PRINT USING}} tmp4$; asc1% + (256 * asc2%)
{{Cl|LOOP}}
{{Cl|SYSTEM}} '' ''
{{Cl|SYSTEM}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' All [[ASCII]] characters can be displayed using [[_PRINTSTRING]] . The routine gets the [[ASCII]] code, which is the actual value needed by [[CVI]]. The first byte code is always between 0 and 255. The second byte can return 0 thru 127 and CVI multiplies that value by 256. This proves that you cannot just feed a string number value to [[CVI]] and get the result desired. ("90" gets decoded to 12345).
@ -63,4 +65,4 @@ tmp4$ = " CVI Total = ##### "
{{PageNavigation}}
<

View file

@ -1,8 +1,10 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:33}}
The [[CVL]] function decodes a 4-byte [[STRING]] generated by [[MKL$]] (or read from a file) to [[LONG]] numeric values.
{{PageSyntax}}
: {{Parameter|result&amp;}} = [[CVL]]({{Parameter|stringData$}})
: {{Parameter|result&}} = [[CVL]]({{Parameter|stringData$}})
{{PageDescription}}
@ -14,21 +16,21 @@ The [[CVL]] function decodes a 4-byte [[STRING]] generated by [[MKL$]] (or read
{{PageExamples}}
''Example 1: 4 byte [[ASCII]] character strings show how CVL multipliers convert [[MKL$]] values into a 4 byte [[LONG]] value.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(1) + {{Cl|STRING$}}(3, 0)) '{{Cl|ASC}}(CHR$(1)) * 1 = 1
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|CHR$}}(0) + {{Cl|CHR$}}(1) + {{Cl|STRING$}}(2, 0)) '{{Cl|ASC}}(CHR$(1)) * 256 = 256
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(2, 0) + {{Cl|CHR$}}(1) + {{Cl|CHR$}}(0)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 = 65536
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(3, 0) + {{Cl|CHR$}}(1)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 * 256 = 16777216 '' ''
{{Cl|PRINT}} {{Cl|CVL}}({{Cl|STRING$}}(3, 0) + {{Cl|CHR$}}(1)) '{{Cl|ASC}}(CHR$(1)) * 256 * 256 * 256 = 16777216
{{CodeEnd}}
''Example 2:''
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|FIELD}} #1, 4 {{Cl|AS}} N$, 12 {{Cl|AS}} B$...
{{Cl|GET}} #1
Y&amp; = {{Cl|CVL}}(N$) '' ''
Y& = {{Cl|CVL}}(N$)
{{CodeEnd}}
:''Explanation:'' Reads a field from file #1, and converts the first four bytes (N$) into a long integer value assigned to the variable Y&amp;.
:''Explanation:'' Reads a field from file #1, and converts the first four bytes (N$) into a long integer value assigned to the variable Y&.
:Since the representation of a long number can use up to 10 ASCII characters (ten bytes), writing to a file using [[MKL$]] conversion, and then reading back with the [[CVL]] conversion can save up to 6 bytes of storage space.
@ -40,4 +42,4 @@ Y&amp; = {{Cl|CVL}}(N$) '' ''
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:36}}
The [[CVDMBF]] function decodes a 4-byte [[STRING]] generated by [[MKSMBF$]] (or read from a file) to [[SINGLE]] numeric values.
@ -35,4 +37,4 @@ The string above, decoded using CVSMBF: 700.2213
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:34}}
The [[CVS]] function decodes a 4-byte [[STRING]] generated by [[MKS$]] (or read from a file) to [[SINGLE]] numeric values.
@ -35,4 +37,4 @@ The string above, decoded using CVS: 700.2213
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:24:41}}
A '''colon''' can be used to separate two unrelated procedure statements on the same line.
@ -20,4 +22,4 @@ A '''colon''' can be used to separate two unrelated procedure statements on the
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:37}}
The [[DATA]] statement creates a line of fixed program information separated by commas. The DATA can be later READ by the program at runtime.
@ -23,7 +25,7 @@ The [[DATA]] statement creates a line of fixed program information separated by
{{PageExamples}}
''Example 1:'' Creating two DATA fields that can be [[READ]] repeatedly using [[RESTORE]] with the appropriate line label.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|RESTORE}} Database2
{{Cl|READ}} A$, B$, C$, D$ 'read 4 string values from second DATA field
PRINT A$ + B$ + C$ + D$ 'note that quoted strings values are spaced
@ -41,7 +43,7 @@ Database1:
{{Cl|DATA}} 2, 0, 0, 2, 2, 0, 2, 2, 2 : ' DATA line comments require a colon
Database2:
{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work! '' ''
{{Cl|DATA}} "Hello, ", "world! ", Goodbye, work!
{{CodeEnd}}
{{OutputStart}}Hello world! Goodbyework!
1 0 0 1 1 0 1 1 1 2 0 0 2 2 0 2 2 2
@ -49,9 +51,9 @@ Database2:
''Example 2:'' How to [[RESTORE]] and [[READ]] DATA in a [[SUB]] procedure in QB64. Line labels can be used for multiple DATA fields.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DIM}} {{Cl|SHARED}} num(10) 'shared array or must be passed as a parameter
ReadData 2 '&lt;&lt;&lt;&lt;&lt;&lt;&lt; change value to 1 to read other data
ReadData 2 '<<<<<<< change value to 1 to read other data
{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 10
{{Cl|PRINT}} num(i);
{{Cl|NEXT}}
@ -67,7 +69,7 @@ mydata1:
{{Cl|DATA}} 1,2,3,4,5,6,7,8,9,10
mydata2:
{{Cl|DATA}} 10,9,8,7,6,5,4,3,2,1
{{Cl|END SUB}} '' ''
{{Cl|END SUB}}
{{CodeEnd}}
{{OutputStart}} 10 9 8 7 6 5 4 3 2 1 {{OutputEnd}}
@ -79,4 +81,4 @@ mydata2:
{{PageNavigation}}
<

View file

@ -1 +0,0 @@
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:38}}
The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
@ -11,7 +13,7 @@ The [[DATE$]] function returns the current computer date as a string in the form
{{PageExamples}}
''Example:'' Displaying the weekday and current date.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|PRINT}} {{Cl|DATE$}}
month$ = {{Cl|LEFT$}}({{Cl|DATE$}}, 2): M = {{Cl|VAL}}(month$)
day$ = {{Cl|MID$}}({{Cl|DATE$}}, 4, 2): D = {{Cl|VAL}}(day$)
@ -35,13 +37,13 @@ year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$)
{{Cl|DEFINT}} A-Z
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
{{Cl|IF}} M &lt; 3 {{Cl|THEN}} M = M + 12: Y = Y - 1 'add 12 to Jan - Feb month, -1 year
{{Cl|IF}} M < 3 {{Cl|THEN}} M = M + 12: Y = Y - 1 'add 12 to Jan - Feb month, -1 year
C = Y \ 100: Y = Y {{Cl|MOD}} 100 'split century and year number
S1 = (C \ 4) - (2 * C) - 1 'century leap
S2 = (5 * Y) \ 4 '4 year leap
S3 = 26 * (M + 1) \ 10 'days in months
WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder
{{Cl|IF}} WkDay &lt; 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6
{{Cl|IF}} WkDay < 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6
{{Cl|SELECT CASE}} WkDay
{{Cl|CASE}} 0: day$ = "Sunday"
{{Cl|CASE}} 1: day$ = "Monday"
@ -52,7 +54,7 @@ WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder
{{Cl|CASE}} 6: day$ = "Saturday"
{{Cl|END SELECT}}
WeekDay$ = day$
{{Cl|END FUNCTION}} '' ''
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
{{OutputStart}}
@ -68,4 +70,4 @@ Today is Wednesday, June 2, 2010
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:07:31}}
'''DECLARE DYNAMIC LIBRARY''' allows you to dynamically link your program to functions in dynamically linkable libraries. At present, only ''.DLL'' files are supported (support for ''.so'' will be added soon). These libraries are loaded when your program begins.
@ -34,9 +36,9 @@
{{PageExamples}}
''Example 1:'' This example plays Midi files using the ''playmidi32.dll'' documented here: [http://libertybasicuniversity.com/lbnews/nl110/midi3.htm Liberty Basic University]. Download the following DLL file to your main QB64 folder: [https://www.qb64.org/resources/Playmidi32.dll PlayMidi32.dll]
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DECLARE DYNAMIC LIBRARY}} "playmidi32"
{{Cl|FUNCTION}} PlayMIDI&amp; (filename {{Cl|AS}} {{Cl|STRING}})
{{Cl|FUNCTION}} PlayMIDI& (filename {{Cl|AS}} {{Cl|STRING}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0))
{{Cl|PRINT}} result
@ -45,12 +47,12 @@ result = PlayMIDI(".\samples\qb64\original\ps2battl.mid" + {{Cl|CHR$}}(0))
''Example 2:'' Using a CUSTOMTYPE LIBRARY to return the [[Unicode]] version of the current running program's name.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE DYNAMIC LIBRARY|DECLARE CUSTOMTYPE LIBRARY}} 'Directory Information using KERNEL32 provided by Dav
{{Cl|FUNCTION}} GetModuleFileNameA&amp; ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|FUNCTION}} GetModuleFileNameW&amp; ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|FUNCTION}} GetModuleFileNameA& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|FUNCTION}} GetModuleFileNameW& ({{Cl|BYVAL}} hModule {{Cl|AS}} {{Cl|LONG}}, lpFileName {{Cl|AS}} {{Cl|STRING}}, {{Cl|BYVAL}} nSize {{Cl|AS}} {{Cl|LONG}})
{{Cl|DECLARE LIBRARY|END DECLARE}}
'=== SHOW CURRENT PROGRAM
@ -82,14 +84,14 @@ b$ = {{Cl|STRING$}}({{Cl|LEN}}(a$) * 2, 0)
{{Cl|ASC}}(b$, i * 4 - 2) = {{Cl|ASC}}(a$, i * 2)
{{Cl|NEXT}}
QuickUTF16toUTF32$ = b$
{{Cl|END FUNCTION}} '' ''
{{Cl|END FUNCTION}}
{{CodeEnd}}
{{small|Code by Galleon}}
: '''Note:''' SUB procedures using CUSTOMTYPE LIBRARY API procedures inside may error. Try DYNAMIC with "KERNEL32".
&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>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
@ -102,4 +104,4 @@ QuickUTF16toUTF32$ = b$
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:07:30}}
The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]] and [[FUNCTION]] procedures supported by QB64.
@ -38,7 +40,7 @@ The '''DECLARE LIBRARY''' declaration allows the use of external library [[SUB]]
{{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}} '' ''
{{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}}
@ -55,39 +57,39 @@ DO
{{Cl|SUB}} MouseMove (x {{Cl|AS}} {{Cl|LONG}}, y {{Cl|AS}} {{Cl|LONG}})
SDL_WarpMouse x, y 'call SDL library procedure
{{Cl|END SUB}} '' ''
{{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}} '' ''
<center>'''Using [[ALIAS]] to create a program SUB or FUNCTION''' using '''QB64 SDL ONLY'''</center>
{{CodeStart}}
{{Cl|SCREEN}} 12
{{Cl|DECLARE LIBRARY}}
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&amp;, {{Cl|BYVAL}} row&amp;)
{{Cl|SUB}} MouseMove {{Cl|ALIAS}} SDL_WarpMouse ({{Cl|BYVAL}} column&, {{Cl|BYVAL}} row&)
{{Cl|DECLARE LIBRARY|END DECLARE}}
{{Cl|_DELAY}} 2
MouseMove 100, 100
{{Cl|_DELAY}} 2
MouseMove 200, 200 '' ''
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}} '' ''
{{CodeStart}}
{{Cl|DECLARE LIBRARY}} ""
{{Cl|FUNCTION}} addone&amp; ({{Cl|BYVAL}} value&amp;)
{{Cl|END}} DECLARE '' ''
{{Cl|FUNCTION}} addone& ({{Cl|BYVAL}} value&)
{{Cl|END}} DECLARE
{{CodeEnd}}
:''Explanation:'' The C function 'addone' exists in a library QB64 already links to, but it hasn't been defined as a C function or a QB64 function. By using "" we are telling QB64 the function exists in a library which is already linked to and that it must define the C function before calling it, as well as allowing QB64 code to call it. Trying the above code without the "" will fail.
: '''Note: What libraries are or aren't automatically used in the linking process is not formally defined, nor is it guaranteed to stay that way in future versions of QB64.'''
&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>
<center>'''QB64 version 1.000 and up produce standalone executables. External DLL files must be distributed with your program.'''</center>
<center>'''Note: QB64 versions prior to 1.000 require all default DLL files to either be with the program or in the C:\WINDOWS\SYSTEM32 folder.'''</center>
''See also:''
@ -100,4 +102,4 @@ MouseMove 200, 200 '' ''
{{PageNavigation}}
<

View file

@ -1,15 +1,17 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:45}}
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.
==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'''.
{{PageSyntax}}
: [[DEFDBL]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
{{PageLegacySupport}}
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS DOUBLE, a2 AS DOUBLE, a3 AS DOUBLE{{InlineCodeEnd}}, simply having {{InlineCode}}DEFDBL A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
@ -38,4 +40,4 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,15 +1,17 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:46}}
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.
==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'''.
{{PageSyntax}}
: [[DEFINT]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
{{PageLegacySupport}}
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS INTEGER, a2 AS INTEGER, a3 AS INTEGER{{InlineCodeEnd}}, simply having {{InlineCode}}DEFINT A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
@ -39,4 +41,4 @@ The [[DEFINT]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,15 +1,17 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:47}}
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.
==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'''.
{{PageSyntax}}
: [[DEFLNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
{{PageLegacySupport}}
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS LONG, a2 AS LONG, a3 AS LONG{{InlineCodeEnd}}, simply having {{InlineCode}}DEFLNG A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
@ -39,4 +41,4 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,15 +1,17 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:48}}
The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables.
==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'''.
{{PageSyntax}}
: [[DEFSNG]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
{{PageLegacySupport}}
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS SINGLE, a2 AS SINGLE, a3 AS SINGLE{{InlineCodeEnd}}, simply having {{InlineCode}}DEFSNG A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* Undeclared variables with no type suffix are of type [[SINGLE]] by default.
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
@ -39,4 +41,4 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,15 +1,17 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:49}}
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.
==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'''.
{{PageSyntax}}
: [[DEFSTR]] {{Parameter|letter}}[-{{Parameter|range}}], {{Parameter|letter2}}[-{{Parameter|range2}}], [...]
{{PageLegacySupport}}
* '''DEF''' statements ([[DEFDBL]], [[DEFSNG]], [[DEFLNG]], [[DEFINT]], [[DEFSTR]]) were used when storage space was a concern in older computers, as their usage could save up typing. Instead of {{InlineCode}}DIM a AS STRING, a2 AS STRING, a3 AS STRING{{InlineCodeEnd}}, simply having {{InlineCode}}DEFSTR A{{InlineCodeEnd}} in the code before using variables starting with letter '''A''' would do the same job.
* For clarity, it is recommended to declare variables with meaningful names.
{{PageDescription}}
* {{Parameter|letter}} (or {{Parameter|range}}) can be from A-Z or any other range, like '''G-M'''.
* You can also use commas for specific undefined variable first letters.
@ -38,4 +40,4 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec
{{PageNavigation}}
<

View file

@ -1,7 +1,9 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:44}}
[[DEF SEG]] is used to define the area in memory to access QB64's emulated conventional memory.
==Legacy support==
{{PageLegacySupport}}
* '''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.'''
@ -12,15 +14,15 @@
{{PageDescription}}
* Used to set the pointer to a memory area of a variable/array or register.
* [[PEEK]] and [[POKE]] require a segment memory address (often just 0) without using VARSEG.
* Important segments using [[PEEK]] and [[POKE]] include &amp;HB800 (text segment) and &amp;HA000 (graphics segment).
* Important segments using [[PEEK]] and [[POKE]] include &HB800 (text segment) and &HA000 (graphics segment).
* [[BSAVE]] and [[BLOAD]] require a VARSEG reference to the grahic array(0 index) used.
* Always use DEF SEG when the procedure is completed, in order to reset the segment to QBasic's default value.
* [[DEF SEG]], [[VARSEG]], [[VARPTR]], [[PEEK]] and [[POKE]] access QB64's emulated 16 bit conventional memory block. '''It is highly recommended to use QB64's [[_MEM]] memory system to avoid running out of memory.'''
&lt;!--
<!--
{{PageExamples}}
''Example:'' In a Qbasic(ONLY) file delete, '''SEG''' forces the parameter to be passed as a far pointer.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|CONST}} file = "trashme.tmp" 'example temporary file name to delete
{{Cl|DEFINT}} A-Z
{{Cl|DIM}} filename {{Cl|AS}} {{Cl|STRING}}
@ -36,7 +38,7 @@ t = "5589E51E8B560C8EDA8B5E0A8B5702B441CD218B56088EDA8B5E06720B6631C0"
t = t + "6689071F5DCA0800660D0000FFFFEBF0"
{{Cl|FOR...NEXT|FOR}} i = 0 {{Cl|TO}} codelen - 1
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&amp;h" + {{Cl|MID$}}(t, i + i + 1, 2)))
{{Cl|MID$}}(code, i + 1, 1) = {{Cl|CHR$}}({{Cl|VAL}}("&h" + {{Cl|MID$}}(t, i + i + 1, 2)))
{{Cl|NEXT}}
{{Cl|OPEN}} file {{Cl|FOR...NEXT|FOR}} {{Cl|APPEND}} {{Cl|AS}} 1 'create temporary file
@ -52,12 +54,12 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{Cl|CALL}} absolute('''SEG''' filename, '''SEG''' result, {{Cl|VARPTR}}(code))
{{Cl|IF...THEN|IF}} result {{Cl|THEN}} 'check results
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&amp;H}}FFFF&amp;)
{{Cl|PRINT}} "oops. error: 0x"; {{Cl|HEX$}}(result {{Cl|AND (boolean)|AND}} {{Cl|&H}}FFFF&)
{{Cl|ELSE}}
{{Cl|PRINT}} "now you don't:"
{{Cl|END IF}}
{{Cl|SHELL}} "dir " + file
{{Cl|END}} '' ''
{{Cl|END}}
{{CodeEnd}}
{{small|Code by Michael Calkins as Public Domain(2011)}}
-->
@ -70,4 +72,4 @@ filename = file + {{Cl|CHR$}}(0) 'create zero string name for DOS
{{PageNavigation}}
<

View file

@ -1,12 +1,18 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:51}}
The [[DIM]] statement is used to declare a variable or a list of variables as a specified data type or to dimension [[$STATIC]] or [[$DYNAMIC]] [[Arrays|arrays]].
{{PageSyntax}}
::''Syntax 1:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]]
::''To declare variables:''
:::[[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]]
::''Syntax 2:'' [[DIM]] [{{KW|SHARED}}] ''array(lowest% [{{KW|TO}}) highest%])''[{suffix| {{KW|AS}} ''type''}] [, ''variable2''...]
::''To declare arrays:''
:::[[DIM]] [{{KW|SHARED}}] ''array([lowest% {{KW|TO}}] highest%])''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
:'' '''QB64''' Syntax:'' [[DIM]] [{{KW|SHARED}}] ''variable''[{suffix| {{KW|AS}} [{{KW|_UNSIGNED}}] ''type''}] [, ''variable2''...]
::'' '''QB64''' Alternative Syntax:''
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''variable'' [, ''variable2''...]
:::[[DIM]] [{{KW|SHARED}}] {{KW|AS}} [{{KW|_UNSIGNED}}] ''type'' ''array([lowest% {{KW|TO}}] highest%])'' [, ''array2(elements)''...]
{{PageDescription}}
@ -15,18 +21,19 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
* DIM [[SHARED]] shares variable values with sub-procedures without passing the value in a parameter.
* Use the [[AS]] keyword to define a variable or array ''type'' [[AS]]...
** [[INTEGER]] (or use variable suffix '''%''')
** [[LONG]] (or use variable suffix '''&amp;''')
** [[LONG]] (or use variable suffix '''&''')
** [[SINGLE]] (or use variable suffix '''!''' or no suffix by default)
** [[DOUBLE]] (or use variable suffix '''#''')
** [[STRING]] (or use variable suffix '''$'''). An AS multiplier can set the string [[LEN|length]]. Ex: {{InlineCode}}DIM ''variable'' AS STRING * 8{{InlineCodeEnd}}
* '''QB64''' variable types:
** [[_BIT]] (or use variable suffix '''`'''). An AS multiplier can be used for multiple bits. Ex: {{InlineCode}}DIM ''variable'' AS _BIT * 8{{InlineCodeEnd}}
** [[_BYTE]] (or use variable suffix '''%%''')
** [[_INTEGER64]] (or use variable suffix '''&amp;&amp;''')
** [[_INTEGER64]] (or use variable suffix '''&&''')
** [[_FLOAT]] (or use variable suffix '''##''')
** [[_OFFSET]] (or use variable suffix '''%&amp;''')
** [[_OFFSET]] (or use variable suffix '''%&''')
** DIM AS [[_MEM]] (the _MEM type has no type suffix).
* '''Note: When a variable has not been defined or has no type suffix, the value defaults to [[SINGLE]].'''
* '''Note: When a variable has not been defined or has no type suffix, the type defaults to [[SINGLE]].'''
* When using the '''AS type variable-list''' syntax, type symbols cannot be used.
* When the [[$DYNAMIC]] metacommand or [[REDIM]] is used, array element sizes are changeable (not [[$STATIC]]).
* Use [[REDIM]] instead of DIM to dimension arrays as dynamic without the {{KW|$DYNAMIC}} metacommand.
* Use [[REDIM]] [[_PRESERVE]] in '''QB64''' to retain previous array values when changing the size of an array.
@ -65,25 +72,32 @@ The [[DIM]] statement is used to declare a variable or a list of variables as a
''Example 6:'' QB64 is more flexible than QBasic when it comes to "Duplicate Definition" errors. The following code does not error:
{{CodeStart}} '' ''
{{CodeStart}}
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
{{Cl|DIM}} x {{Cl|AS}} {{Cl|LONG}}
{{Cl|PRINT}} x '' ''
{{Cl|PRINT}} x
{{CodeEnd}}
: ''Explanation:'' The [[SINGLE]] variable can be differentiated from the [[LONG]] x variable by using suffixes like x! or x&amp; in later code.
: ''Explanation:'' The [[SINGLE]] variable can be differentiated from the [[LONG]] x variable by using suffixes like x! or x& in later code.
''Example 7:'' The following code will create a "Name already in use" '''status error''' in QB64 when the variable types are the same.
{{CodeStart}} '' ''
{{CodeStart}}
x = 1 'x is a {{Cl|SINGLE}} variable
{{Cl|PRINT}} x
{{Cl|DIM}} x {{Cl|AS}} {{Cl|SINGLE}}
{{Cl|PRINT}} x '' ''
{{Cl|PRINT}} x
{{CodeEnd}}
: ''Explanation:'' QB64 gives an error because the creation of the new variable would make referring to the existing one impossible.
''Example 8:'' Using QB64's alternative syntax to declare multiple variables/arrays of the same type.
{{CodeStart}}
{{Cl|DIM}} {{Cl|AS}} {{Cl|LONG}} w, h, id, weight, index 'all of these variables are created as type LONG
{{Cl|DIM}} {{Cl|AS}} {{Cl|SINGLE}} x, y, z 'all of these variables are created as type SINGLE
{{CodeEnd}}
{{PageSeeAlso}}
* [[_DEFINE]], [[_PRESERVE]]
* [[REDIM]], [[TYPE]]
@ -95,4 +109,4 @@ x = 1 'x is a {{Cl|SINGLE}} variable
{{PageNavigation}}
<

View file

@ -1,3 +1,5 @@
{{QBDLDATE:05-20-2022}}
{{QBDLTIME:23:12:52}}
'''DO...LOOP''' statements are used in programs to repeat code or return to the start of a procedure.
@ -36,9 +38,9 @@
''Example 1:'' Using WHILE to clear the keyboard buffer.
{{CodeStart}}
DO WHILE {{Cl|INKEY$}} &lt;> "": LOOP ' checks evaluation before running loop code
DO WHILE {{Cl|INKEY$}} <> "": LOOP ' checks evaluation before running loop code
DO: LOOP WHILE INKEY$ &lt;> "" ' checks evaluation after one run of loop code
DO: LOOP WHILE INKEY$ <> "" ' checks evaluation after one run of loop code
{{CodeEnd}}
@ -55,7 +57,7 @@ DO: LOOP UNTIL {{Cl|INKEY$}} = "" ' checks evaluation after one run of loop code
''Example 3:'' Using a one time DO loop to exit ANY of several FOR LOOPs, without using [[GOTO]].
:SUB reads header contents of a [[BSAVE]] file that may include embedded RGB color settings before the image.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DEFINT}} A-Z
{{Cl|INPUT}} "Enter a BSAVE file name to read the file for screen mode:"', filenm$
CheckScreen filenm$
@ -73,7 +75,7 @@ CheckScreen filenm$
{{Cl|GET}} #1, , Bsv '1 check for small 2 character
GET #1, , Header '2 - 7 rest of file header
IF Bsv &lt;> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file
IF Bsv <> {{Cl|CHR$}}(253) THEN ' small 2 character denotes a {{Cl|BSAVE}} file
COLOR 12: LOCATE 15, 33: PRINT "Not a BSAVE file!": SLEEP 3: {{Cl|EXIT}} SUB
END IF
@ -85,10 +87,10 @@ DO
FOR i = 10 TO 55 'check for Screen 12 embedded colors
GET #1, , RGB
tot12&amp; = tot12&amp; + RGB
tot12& = tot12& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test sound slows loop in QB
IF RGB > 63 OR RGB &lt; 0 THEN {{Cl|EXIT DO}}
IF i = 55 AND tot12&amp; = 0 THEN {{Cl|EXIT DO}}
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 55 AND tot12& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid12 '56
@ -97,10 +99,10 @@ DO
FOR i = 58 TO 775 'check for Screen 13 embedded colors
GET #1, , RGB
tot13&amp; = tot13&amp; + RGB
tot13& = tot13& + RGB
'PRINT i; RGB; : SOUND 300, 1 'test
IF RGB > 63 OR RGB &lt; 0 THEN {{Cl|EXIT DO}}
IF i = 775 AND tot13&amp; = 0 THEN {{Cl|EXIT DO}}
IF RGB > 63 OR RGB < 0 THEN {{Cl|EXIT DO}}
IF i = 775 AND tot13& = 0 THEN {{Cl|EXIT DO}}
NEXT
GET #1, , wid13 '776
GET #1, , dep13 '777
@ -109,7 +111,7 @@ CLOSE #1
COLOR 14: LOCATE 10, 25
{{Cl|SELECT CASE}} i
{{Cl|CASE IS}} &lt; 56:
{{Cl|CASE IS}} < 56:
IF widN > 640 THEN
Scr = 13: MaxColors = 0
PRINT "Default Screen 13:"; widN \ 8; "X"; depN
@ -131,7 +133,7 @@ COLOR 14: LOCATE 10, 25
Scr = 13: MaxColors = 256: PWidth = wid13 \ 8: PDepth = dep13
{{Cl|END SELECT}}
{{Cl|END SUB}} '' ''
{{Cl|END SUB}}
{{CodeEnd}}
{{small|Code by Ted Weissgerber}}
:''Explanation:'' The SUB procedure reads a file that was [[BSAVE]]d previously. If the RGB colors are stored before the image, the values can only be between 0 and 63. Higher values indicate that the image width and height are located there and that there are no stored color values to be read. SUB later displays the dimensions of the file image that [[GET (graphics statement)|GET]] placed in the file array. The loop is set to only run once by creating '''a TRUE [[UNTIL]] statement''' such as 1 = 1. When a screen mode cannot be determined, the user must select one.
@ -148,4 +150,4 @@ COLOR 14: LOCATE 10, 25
{{PageNavigation}}
<

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