diff --git a/internal/help/$ERROR.txt b/internal/help/$ERROR.txt new file mode 100644 index 000000000..b0b3187d5 --- /dev/null +++ b/internal/help/$ERROR.txt @@ -0,0 +1,30 @@ +The [[$ERROR]] metacommand triggers a compilation error. + + +{{PageSyntax}} +: [[$ERROR]] MESSAGE + +{{PageDescription}} +* The Metacommand does '''not''' require a comment or REM before it. +* MESSAGE is any text. Quotation marks are not required. +* When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and MESSAGE is shown to the user. This is useful in [[$IF]] blocks. + +===Details=== +* If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with [[$IF]]. +* An [[$ERROR]] directive not inside an [[$IF]] (or [[$ELSEIF]]) block is useless because the program will never compile. + +{{PageExamples}} +{{CodeStart}} '' '' +{{Cl|$IF}} VERSION < 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}} diff --git a/internal/help/BEEP.txt b/internal/help/BEEP.txt index 049cc7ec1..9e10c44a1 100644 --- a/internal/help/BEEP.txt +++ b/internal/help/BEEP.txt @@ -10,7 +10,7 @@ The [[BEEP]] statement produces a beep sound through the sound card. * '''QB64''' produces the actual "beep" sound through the PC's sound card, to emulate QBasic's beeping through the [https://en.wikipedia.org/wiki/PC_speaker PC speaker]. -==QBasic/QuickBASIC== +{{PageQBasic}} * Older programs may attempt to produce a BEEP by printing [[CHR$]](7) to the screen. This is no longer supported in QB64 after '''version 1.000'''. ** You may have to replace instances of PRINT CHR$(7) in older programs to the [[BEEP]] statement to maintain the legacy functionality. diff --git a/internal/help/BLOAD.txt b/internal/help/BLOAD.txt index 85808829a..2d95484a0 100644 --- a/internal/help/BLOAD.txt +++ b/internal/help/BLOAD.txt @@ -1,6 +1,6 @@ [[BLOAD]] loads a binary graphics file created by [[BSAVE]] to an array. -==Legacy support== +{{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.''' diff --git a/internal/help/BSAVE.txt b/internal/help/BSAVE.txt index 74a7a925a..41288e2f8 100644 --- a/internal/help/BSAVE.txt +++ b/internal/help/BSAVE.txt @@ -1,8 +1,8 @@ [[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. +{{PageLegacySupport}} +* QB64 can save larger arrays directly to binary files using [[PUT]] # and [[GET]] # without [[BSAVE]]. For that reason, use of [[BSAVE]] is no longer recommended practice but is supported to maintain compatibility with legacy code. {{PageSyntax}} @@ -65,16 +65,16 @@ {{Cl|GET (graphics statement)|GET}}(0, 0)-{{Cl|STEP}}(10, 10), Graphic%() 'get image to array {{Cl|FOR...NEXT|FOR}} i% = 1000 {{Cl|TO}} 0 {{Cl|STEP}} -1 'reverse read array for size needed - {{Cl|IF...THEN|IF}} Graphic%(i%) <> 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 FOR}} 'find image color not black {{Cl|NEXT}} size% = i% + 4 'size plus 2 integers(4 bytes) for dimensions {{Cl|REDIM}} {{Cl|_PRESERVE}} Graphic%(size%) 'resize existing array in QB64 only! -{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file +{{Cl|OPEN}} "example2.BIN" {{Cl|FOR (file statement)|FOR}} {{Cl|BINARY}} {{Cl|AS}} #1 ' {{Cl|PUT}} to a file {{Cl|PUT}} #1, , Graphic%() {{Cl|CLOSE}} -{{Cl|OPEN}} "example2.BIN" {{Cl|FOR...NEXT|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen +{{Cl|OPEN}} "example2.BIN" {{Cl|FOR (file statement)|FOR}} {{Cl|BINARY}} {{Cl|AS}} #2 'GET array and {{Cl|PUT}} to screen {{Cl|DIM}} CopyBin%({{Cl|LOF}}(2) \ 2) 'create new array sized by half of file size {{Cl|GET}} #2, , CopyBin%() {{Cl|PUT (graphics statement)|PUT}}(100, 100), CopyBin%(), {{Cl|PSET}} diff --git a/internal/help/CALL_ABSOLUTE.txt b/internal/help/CALL_ABSOLUTE.txt index b4bcbb596..45df91671 100644 --- a/internal/help/CALL_ABSOLUTE.txt +++ b/internal/help/CALL_ABSOLUTE.txt @@ -5,7 +5,7 @@ : [[CALL ABSOLUTE]]([{{Parameter|argumentList}},] {{Parameter|integerOffset}}) -==Legacy support== +{{PageLegacySupport}} * [[CALL ABSOLUTE]] is implemented to support older code and is not recommended practice. To handle mouse input, the '''use [[_MOUSEINPUT]] and related functions'''. diff --git a/internal/help/CHAIN.txt b/internal/help/CHAIN.txt index a2b93ce2c..a605e1dbc 100644 --- a/internal/help/CHAIN.txt +++ b/internal/help/CHAIN.txt @@ -1,7 +1,7 @@ [[CHAIN]] is used to change seamlessly from one module to another one in a program. -==Legacy support== +{{PageLegacySupport}} * 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.''' diff --git a/internal/help/COMMON.txt b/internal/help/COMMON.txt index e0868ce66..f3a7a0c31 100644 --- a/internal/help/COMMON.txt +++ b/internal/help/COMMON.txt @@ -1,6 +1,6 @@ [[COMMON]] shares common variable values with other linked or [[CHAIN]]ed modules. -==Legacy support== +{{PageLegacySupport}} * 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.''' diff --git a/internal/help/DEFDBL.txt b/internal/help/DEFDBL.txt index c0cf2143d..e96f5d05c 100644 --- a/internal/help/DEFDBL.txt +++ b/internal/help/DEFDBL.txt @@ -1,7 +1,7 @@ The [[DEFDBL]] statement defines all variables with names starting with the specified letter (or letter range) AS [[DOUBLE]] variables instead of the [[SINGLE]] type default. -==Legacy support== +{{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'''. @@ -18,7 +18,7 @@ The [[DEFDBL]] statement defines all variables with names starting with the spec * '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures. diff --git a/internal/help/DEFINT.txt b/internal/help/DEFINT.txt index 3a5ed61d8..4fe9262a9 100644 --- a/internal/help/DEFINT.txt +++ b/internal/help/DEFINT.txt @@ -1,7 +1,7 @@ The [[DEFINT]] statement defines all variables with names starting with the specified letter (or letter range) AS [[INTEGER]] variables instead of the [[SINGLE]] type default. -==Legacy support== +{{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'''. @@ -19,7 +19,7 @@ The [[DEFINT]] statement defines all variables with names starting with the spec * '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures. diff --git a/internal/help/DEFLNG.txt b/internal/help/DEFLNG.txt index 59178d239..803ae5e29 100644 --- a/internal/help/DEFLNG.txt +++ b/internal/help/DEFLNG.txt @@ -1,7 +1,7 @@ The [[DEFLNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[LONG]] variables instead of the [[SINGLE]] type default. -==Legacy support== +{{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'''. @@ -19,7 +19,7 @@ The [[DEFLNG]] statement defines all variables with names starting with the spec * '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures. diff --git a/internal/help/DEFSNG.txt b/internal/help/DEFSNG.txt index 6a7a51248..aef84bfc5 100644 --- a/internal/help/DEFSNG.txt +++ b/internal/help/DEFSNG.txt @@ -1,7 +1,7 @@ The [[DEFSNG]] statement defines all variables with names starting with the specified letter (or letter range) AS [[SINGLE]] variables. -==Legacy support== +{{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'''. @@ -19,7 +19,7 @@ The [[DEFSNG]] statement defines all variables with names starting with the spec * '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures. diff --git a/internal/help/DEFSTR.txt b/internal/help/DEFSTR.txt index 03f157aed..fb01898a8 100644 --- a/internal/help/DEFSTR.txt +++ b/internal/help/DEFSTR.txt @@ -1,7 +1,7 @@ The [[DEFSTR]] statement defines all variables with names starting with the specified letter (or letter range) AS [[STRING]] variables instead of the [[SINGLE]] type default. -==Legacy support== +{{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'''. @@ -18,7 +18,7 @@ The [[DEFSTR]] statement defines all variables with names starting with the spec * '''Warning: QBasic keyword names can only be used as string variable names when they are followed by the string type suffix ($).''' -==QBasic/QuickBASIC== +{{PageQBasic}} * QBasic's IDE would add DEF statements before any [[SUB]] or [[FUNCTION]]. QB64 (like QBasic) will change all variable types in subsequent sub-procedures to that default variable type without giving a [[ERROR Codes|"Parameter Type Mismatch"]] warning or adding DEF statement to subsequent procedures. If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect [[$INCLUDE]] procedures. diff --git a/internal/help/DEF_SEG.txt b/internal/help/DEF_SEG.txt index 0d60b9c33..7717f2caf 100644 --- a/internal/help/DEF_SEG.txt +++ b/internal/help/DEF_SEG.txt @@ -1,7 +1,7 @@ [[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.''' diff --git a/internal/help/DOUBLE.txt b/internal/help/DOUBLE.txt index 66012f3c8..da87db111 100644 --- a/internal/help/DOUBLE.txt +++ b/internal/help/DOUBLE.txt @@ -16,7 +16,7 @@ * '''Warning: QBasic keyword names cannot be used as numerical variable names with or without the type suffix.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * Results of mathematical calculations may be approximate or slow in QuickBASIC 4.5. diff --git a/internal/help/FILES.txt b/internal/help/FILES.txt index d03dc6681..5c59b6aba 100644 --- a/internal/help/FILES.txt +++ b/internal/help/FILES.txt @@ -15,7 +15,7 @@ The [[FILES]] statement is used to print a list of files in the current director * FILES lists can make the screen roll up. Try using SHELL "DIR" with the /P option. [http://www.computerhope.com/dirhlp.htm DIR command]. -==QBasic/QuickBASIC== +{{PageQBasic}} * Illegal filename characters in QBasic included '''* ? , > < ; : " | \ / + [ ]''' and more than one dot extension in [http://www.computerhope.com/issues/ch000209.htm DOS]. diff --git a/internal/help/FUNCTION.txt b/internal/help/FUNCTION.txt index d10afd287..b2093e654 100644 --- a/internal/help/FUNCTION.txt +++ b/internal/help/FUNCTION.txt @@ -24,7 +24,7 @@ A [[FUNCTION]] block statement is used to create a function procedure to return * The IDE can create the FUNCTION and END FUNCTION lines for you. Use the ''New FUNCTION...'' option in the Edit Menu. A box will come up for you to enter a name for the FUNCTION. Enter all code between the FUNCTION and [[END FUNCTION]] lines. -==QBasic/QuickBASIC== +{{PageQBasic}} * Once a FUNCTION was created and used, the QBasic IDE would DECLARE it when the file was saved. '''QB64 doesn't need these declarations.''' * QBasic's IDE could place a [[DEFINT]], [[DEFSNG]], [[DEFLNG]], [[DEFDBL]] or [[DEFSTR]] statement before the FUNCTION line if it is used in the main module. It may even be the wrong variable type needed. * QBasic allowed programmers to add DATA fields anywhere because the IDE separated the main code from other procedures. diff --git a/internal/help/GET_(graphics_statement).txt b/internal/help/GET_(graphics_statement).txt index 08c1ada0d..d76ad1d4a 100644 --- a/internal/help/GET_(graphics_statement).txt +++ b/internal/help/GET_(graphics_statement).txt @@ -1,6 +1,6 @@ The [[GET (graphics statement)|GET]] statement is used in graphics to store a box area image of the screen into an [[INTEGER]] array. -==Legacy support== +{{PageLegacySupport}} * '''QB64 can manipulate parts of an image using [[_PUTIMAGE]]. For that reason, GET isn't recommended practice anymore and is supported to maintain compatibility with legacy code.''' @@ -30,7 +30,7 @@ The [[GET (graphics statement)|GET]] statement is used in graphics to store a bo * '''[[PUT]] and [[GET]] file statements can also write and read image array data using [[BINARY]] files instead of using [[BSAVE]] or [[BLOAD]].''' -==QBasic/QuickBASIC== +{{PageQBasic}} * SCREEN 12 could only GET 1/3 of a full SCREEN 12 image. Rows would increment 160 each GET. '''QB64''' can save entire screen at once. diff --git a/internal/help/GOSUB.txt b/internal/help/GOSUB.txt index 2645a8724..6ce672c65 100644 --- a/internal/help/GOSUB.txt +++ b/internal/help/GOSUB.txt @@ -11,7 +11,7 @@ * GOSUB and GOTO can be used '''within''' [[SUB]] or [[FUNCTION]] procedures, but cannot refer to a label located outside the procedure. -==QBasic/QuickBASIC== +{{PageQBasic}} * Too many GOSUBs without a [[RETURN]] can eventually cause "Out of Stack Errors" in QBasic as each GOSUB uses memory to store the location to return to. Each [[RETURN]] frees the memory of the GOSUB it returns to. diff --git a/internal/help/HEX$_32_Bit_Values.txt b/internal/help/HEX$_32_Bit_Values.txt new file mode 100644 index 000000000..0e5d419e1 --- /dev/null +++ b/internal/help/HEX$_32_Bit_Values.txt @@ -0,0 +1,66 @@ +[[LONG]] [[HEX$|Hexadecimal]] values can be used to set a [[_PALETTECOLOR]] instead of using [[_RGB32]] or [[_RGBA32]] values. + + +* Hexadecimal digits can be represented as any number or letter up to F: '''0 1 2 3 4 5 6 7 8 9 A B C D E F''' + +* [[_BYTE|Byte]] values up to 255 can represented by two hexadecimal digits such as 1C, 23, FA, etc. + +* The [[HEX$|hex]] value for bright white(attribute 15) is &HFFFFFFFF or: + +::: [[_ALPHA|Alpha]] = FF (255), Red = FF (255), Green = FF (255), Blue = FF (255) + +* [[_RGB]] will return an alpha value of 255 for fully opaque 32 bit colors only. Values range from &HFF000000 to &HFFFFFFFF. + +* [[_RGB32]] will return an alpha value of 255 for fully opaque colors only. Values range from &HFF000000 to &HFFFFFFFF. + +* [[_RGBA]] can set the transparency so hexadecimal values range from &H000000 (zero alpha) to &HFFFFFFFF (full alpha). + +* [[_RGBA32]] can set the transparency so hexadecimal values range from &H000000 (zero alpha) to &HFFFFFFFF (full alpha). + + +* So expanding on the principle above allows us to easily make up our own hex color values: + +:: _PALETTECOLOR 1, '''&HFFFF0000''' 'COLOR 1 is full red +:: _PALETTECOLOR 2, '''&HFFFF00FF''' 'COLOR 2 is purple +:: _PALETTECOLOR 3, '''&HFFFFFF00''' 'COLOR 3 is brown + +:Where '''FF''' is the fully opaque [[_ALPHA]] and the 3 hex color values can range from '''00''' to '''FF''' (0 to 255) each. + + +''Example:'' Converting the color port RGB intensity palette values 0 to 63 to 32 bit hexadecimal [[STRING|string]] values. +{{CodeStart}} +{{Cl|SCREEN}} 12 +{{Cl|DIM}} hex32$(15) +alpha$ = "FF" 'solid alpha colors only +{{Cl|OUT}} {{Cl|&H}}3C8, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 0: {{Cl|OUT}} {{Cl|&H}}3C9, 20 'set black background to dark blue + +{{Cl|FOR...NEXT|FOR}} attribute = 0 {{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$ 'necessary for low or zero color intensities + {{Cl|IF...THEN|IF}} {{Cl|LEN}}(grn$) = 1 {{Cl|THEN}} grn$ = "0" + grn$ + {{Cl|IF...THEN|IF}} {{Cl|LEN}}(blu$) = 1 {{Cl|THEN}} blu$ = "0" + blu$ + hex32$(attribute) = "{{Cl|&H}}" + alpha$ + red$ + grn$ + blu$ +{{Cl|NEXT}} +{{Cl|PRINT}} "COLOR 0 = " + hex32$(0) +{{Cl|FOR...NEXT|FOR}} i = 1 {{Cl|TO}} 15 + {{Cl|_PALETTECOLOR}} i, {{Cl|VAL}}(hex32$(i)) + {{Cl|COLOR}} i + {{Cl|PRINT}} "COLOR" + {{Cl|STR$}}(i) + " = " + hex32$(i) 'returns closest attribute +{{Cl|NEXT}} '' '' +{{CodeEnd}}{{small|Code by Ted Weissgerber}} +:''Explanation:'' [[VAL]] is used to convert the [[HEX$|hexadecimal]] [[STRING|string]] values to valid 32 bit color values for [[_PALETTECOLOR]]. +:: No VAL conversion is necessary if the [[LONG]] [[&H]] hexadecimal values are entered into the program directly by the programmer. + + +''See also:'' +* [[_PALETTECOLOR]] +* [[_RGB32]], [[_RGBA32]] +* [[_RGB]], [[_RGBA]] {{text|(when used in 32 bit only)}} +* [[COLOR]], [[SCREEN]], [[POINT]] +* [http://www.w3schools.com/html/html_colornames.asp HTML Color Table HEX Values and Names] + + +{{PageNavigation}} diff --git a/internal/help/INPUT$.txt b/internal/help/INPUT$.txt index 80aea89fc..5dcab5284 100644 --- a/internal/help/INPUT$.txt +++ b/internal/help/INPUT$.txt @@ -16,7 +16,7 @@ The [[INPUT$]] function is used to receive data from the user's keyboard, an ope * Use [[_DEST]] [[_CONSOLE]] before INPUT$ is used to receive input from a [[$CONSOLE|console]] window. -==QBasic/QuickBASIC== +{{PageQBasic}} * {{Parameter|numberOfBytes%}} could not exceed 32767 in [[BINARY]] files or a QBasic error would occur. * Ctrl + Break would not interrupt the QBasic program until there was a full INPUT$ key entry. In '''QB64''' Ctrl + Break will immediately exit a running program. diff --git a/internal/help/INSTR.txt b/internal/help/INSTR.txt index dcd4d9e27..9bd3c8e6e 100644 --- a/internal/help/INSTR.txt +++ b/internal/help/INSTR.txt @@ -21,7 +21,7 @@ The [[INSTR]] function searches for the first occurence of a search [[STRING]] w * In a loop, INSTR can search an entire file for occurences of certain words. See the [[MID$ (statement)|MID$]] statement example. -==QBasic/QuickBASIC== +{{PageQBasic}} * The {{Parameter|start%}} position had to be at least 1 or greater when used or there will be an [[ERROR Codes|Illegal function call]] error. In '''QB64''', a {{Parameter|start%}} value of 0 or negative is interpreted as 1 and doesn't generate an error. diff --git a/internal/help/INTERRUPT.txt b/internal/help/INTERRUPT.txt index 1d991b42a..a5397a349 100644 --- a/internal/help/INTERRUPT.txt +++ b/internal/help/INTERRUPT.txt @@ -1,7 +1,7 @@ The [[INTERRUPT]] statement is an assembly routine for accessing computer information registers. -==Legacy support== +{{PageLegacySupport}} * Registers are emulated in '''QB64''' to allow older programs to be compiled. To enable mouse input in your programs, the recommended practice is to use [[_MOUSEINPUT]] and related functions. @@ -14,7 +14,7 @@ The [[INTERRUPT]] statement is an assembly routine for accessing computer inform * {{Parameter|inRegs}} are the values placed into the call and {{Parameter|outRegs}} are the register return values. -==QBasic/QuickBASIC== +{{PageQBasic}} * Available in QuickBASIC versions 4 and up and required an external library to be loaded. <!-- Command line: QB.EXE /L in QB4.5 --> '''QB64''' emulates the statement without an external library. * {{Parameter|intNum}} is the interrupt reference vector table address. For historic reference, see: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List] * The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls diff --git a/internal/help/INTERRUPTX.txt b/internal/help/INTERRUPTX.txt index 428d06a6d..81b0cdb24 100644 --- a/internal/help/INTERRUPTX.txt +++ b/internal/help/INTERRUPTX.txt @@ -1,7 +1,7 @@ The [[INTERRUPTX]] statement is an assembly routine for accessing computer information registers. -==Legacy support== +{{PageLegacySupport}} * Registers are emulated in '''QB64''' to allow older programs to be compiled. To enable mouse input in your programs, the recommended practice is to use [[_MOUSEINPUT]] and related functions. @@ -14,7 +14,7 @@ The [[INTERRUPTX]] statement is an assembly routine for accessing computer infor * {{Parameter|inRegs}} are the values placed into the call and {{Parameter|outRegs}} are the register return values. -==QBasic/QuickBASIC== +{{PageQBasic}} * Available in QuickBASIC versions 4 and up and required an external library to be loaded. <!-- Command line: QB.EXE /L in QB4.5 --> '''QB64''' emulates the statement without an external library. * {{Parameter|intNum}} is the interrupt reference vector table address. For historic reference, see: [http://www.ctyme.com/intr/cat.htm Ralf Brown's Interrupt List] * The [[TYPE]] definition below will work for both [[INTERRUPT]] and INTERRUPTX statement calls diff --git a/internal/help/Keyword_Reference_-_Alphabetical.txt b/internal/help/Keyword_Reference_-_Alphabetical.txt index c325b5e98..b77f0ce8a 100644 --- a/internal/help/Keyword_Reference_-_Alphabetical.txt +++ b/internal/help/Keyword_Reference_-_Alphabetical.txt @@ -193,7 +193,7 @@ __NOTOC__ <div id = "uI">_I</div> * [[$IF]] (precompiler [[metacommand]]) {{text|used to set an IF condition for the precompiler.}} * [[_ICON]] (statement) {{text|designates a [[_LOADIMAGE]] image file handle to be used as the program's icon or loads the embedded icon (see [[$EXEICON]]).}} -* [[_INCLERRORFILE$]] {function) {{text|returns the name of the original source code $INCLUDE module that caused the most recent error.}} +* [[_INCLERRORFILE$]] (function) {{text|returns the name of the original source code $INCLUDE module that caused the most recent error.}} * [[_INCLERRORLINE]] (function) {{text|returns the line number in an included file that caused the most recent error.}} * [[_INFLATE$]] (function) {{text|decompresses a string}} * [[_INSTRREV]] (function) {{text|allows searching for a substring inside another string, but unlike [[INSTR]] it returns the last occurrence instead of the first one.}} diff --git a/internal/help/Keywords_currently_not_supported_by_QB64.txt b/internal/help/Keywords_currently_not_supported_by_QB64.txt index a934d9b23..6a95d2c4f 100644 --- a/internal/help/Keywords_currently_not_supported_by_QB64.txt +++ b/internal/help/Keywords_currently_not_supported_by_QB64.txt @@ -25,7 +25,7 @@ The keywords listed here are not supported in QB64. QB64 is meant to be compatib * SIGNAL * TIME$ (statement) (reading the current [[TIME$]] is supported) * TRON, TROFF -* '''[[WIDTH]] [[LPRINT]]''' combined statement is not supported. +* [[WIDTH]] [[LPRINT]] combined statement is not supported. ==Keywords Not Supported in Linux or MAC OSX versions== diff --git a/internal/help/LOCK.txt b/internal/help/LOCK.txt index 1f284b112..d2b112c1b 100644 --- a/internal/help/LOCK.txt +++ b/internal/help/LOCK.txt @@ -18,7 +18,7 @@ The [[LOCK]] statement restricts access to parts of a file by other programs or * [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not supported in Linux or macOS versions]] -==QBasic/QuickBASIC== +{{PageQBasic}} * Required DOS '''SHARED.EXE''' to be run for QBasic to use networking access modes. No longer required. diff --git a/internal/help/MID$.txt b/internal/help/MID$.txt index ce666cdcd..5fbda61b5 100644 --- a/internal/help/MID$.txt +++ b/internal/help/MID$.txt @@ -18,7 +18,7 @@ The [[MID$]] function returns a portion of a [[STRING|string]]. * In '''QB64''', [[ASC]] string byte position reads are about '''5 times faster''' than MID$ when parsing strings. See ''Example 2'' below. -==QBasic/QuickBASIC== +{{PageQBasic}} * In QBasic the {{Parameter|startPosition%}} could not be zero (0) or an [[ERROR Codes|Illegal function call error]] would occur. diff --git a/internal/help/ON...GOSUB.txt b/internal/help/ON...GOSUB.txt index 31d0fd5da..435a87eb6 100644 --- a/internal/help/ON...GOSUB.txt +++ b/internal/help/ON...GOSUB.txt @@ -12,7 +12,7 @@ * '''Note:''' [[SELECT CASE]] provides a much more convenient way of doing this task. -==QBasic/QuickBASIC== +{{PageQBasic}} * In QuickBASIC 4.5 the list could contain a maximum of 60 line numbers or labels, while '''QB64''' has no limit. diff --git a/internal/help/ON...GOTO.txt b/internal/help/ON...GOTO.txt index 1b66d3347..3bc2476a0 100644 --- a/internal/help/ON...GOTO.txt +++ b/internal/help/ON...GOTO.txt @@ -11,7 +11,7 @@ * '''Note:''' [[SELECT CASE]] provides a much more convenient way of doing this task. -==QBasic/QuickBASIC== +{{PageQBasic}} * In QuickBASIC 4.5 the list could contain a maximum of 60 line numbers or labels, while '''QB64''' has no limit. diff --git a/internal/help/ON_STRIG(n).txt b/internal/help/ON_STRIG(n).txt index 8f4978ffd..710e41b6d 100644 --- a/internal/help/ON_STRIG(n).txt +++ b/internal/help/ON_STRIG(n).txt @@ -12,7 +12,7 @@ The [[ON STRIG(n)]] statement is an event procedure that directs program flow up * The statement sends the procedure to a line number, line label or [[SUB]] procedure when a button event occurs. -==QBasic/QuickBASIC== +{{PageQBasic}} * In QBasic, value of ''n'' could only be a number from 0 to 3 only as it could only monitor 2 joystick buttons and 2 joysticks. diff --git a/internal/help/OUT.txt b/internal/help/OUT.txt index 1b2960f59..bb322e180 100644 --- a/internal/help/OUT.txt +++ b/internal/help/OUT.txt @@ -34,7 +34,7 @@ ::::* Some [[DAC]] color attribute intensities cannot be changed using OUT. -==QBasic/QuickBASIC== +{{PageQBasic}} * In DOS, OUT accesses memory and hardware directly, unlike [[POKE]], and could cause PC damage. diff --git a/internal/help/PALETTE.txt b/internal/help/PALETTE.txt index c7e543fee..a71842fef 100644 --- a/internal/help/PALETTE.txt +++ b/internal/help/PALETTE.txt @@ -16,7 +16,7 @@ The [[PALETTE]] statement can swap color settings, set colors to default or set * QB64 implements the [[_PALETTECOLOR]] statement to provide extended palette functionality. -==QBasic/QuickBASIC== +{{PageQBasic}} * Screens 0, 7 and 9 ([[DAC]]) colors could not be changed using the first syntax, but the program could use [[OUT]] to change intensity settings of attributes 1 thru 5. diff --git a/internal/help/PCOPY.txt b/internal/help/PCOPY.txt index dbd83593f..3d2c977ba 100644 --- a/internal/help/PCOPY.txt +++ b/internal/help/PCOPY.txt @@ -14,7 +14,7 @@ The [[PCOPY]] statement copies one source screen page to a destination page in m * The '''QB64''' [[_DISPLAY]] statement can also be used to stop screen flicker without page flipping or [[CLS]] and '''is the recommended practice'''. -==QBasic/QuickBASIC== +{{PageQBasic}} * {{Parameter|sourcePage%}} and {{Parameter|destinationPage%}} numbers are limited by the SCREEN mode used. In '''QB64''', the same limits don't apply. diff --git a/internal/help/SHELL.txt b/internal/help/SHELL.txt index 62fba490f..096bee847 100644 --- a/internal/help/SHELL.txt +++ b/internal/help/SHELL.txt @@ -22,7 +22,7 @@ The [[SHELL]] statement allows a program to run external programs or command lin *'''NOTE: Use [[CHDIR]] instead of CD as SHELL commands cannot affect the current program path.''' -==QBasic/QuickBASIC== +{{PageQBasic}} * '''QBasic BAS files could be run like compiled programs without returning to the IDE when [[SYSTEM]] was used to [[END|end]] them.''' * A user would invoke it with {{InlineCode}}SHELL "QB.EXE /L /RUN program.BAS"{{InlineCodeEnd}} diff --git a/internal/help/SYSTEM.txt b/internal/help/SYSTEM.txt index c5baae736..c30819a2b 100644 --- a/internal/help/SYSTEM.txt +++ b/internal/help/SYSTEM.txt @@ -1,4 +1,4 @@ -The {{KW|SYSTEM}} statement immediately closes a program and returns control to the operating system. +The [[SYSTEM]] statement immediately closes a program and returns control to the operating system. {{PageSyntax}} @@ -16,7 +16,7 @@ The {{KW|SYSTEM}} statement immediately closes a program and returns control to -==QBasic or QuickBASIC== +{{PageQBasic}} * '''QBasic BAS files can be run like compiled programs without returning to the IDE when [[SYSTEM]] is used to [[END|end]] them!''' * If a program BAS module is run from the IDE, stopped by Ctrl-Break or an error occurs the QB program will exit to the IDE. * To run a QuickBASIC program without the IDE use the following DOS command line: {{text|QB.EXE /L /RUN filename.BAS|green}} diff --git a/internal/help/TIMER_(statement).txt b/internal/help/TIMER_(statement).txt index 53892e27c..05a7543dc 100644 --- a/internal/help/TIMER_(statement).txt +++ b/internal/help/TIMER_(statement).txt @@ -1,12 +1,11 @@ -A '''TIMER''' statement enables, turns off or stops timer event trapping. QBasic only uses the base timer, but '''QB64''' can run many. +A [[TIMER]] statement enables, turns off or stops timer event trapping. QBasic only uses the base timer, but '''QB64''' can run many. -QB {{PageSyntax}} - +{{PageSyntax}} +QB :::TIMER {ON|STOP|OFF} -QB64 {{PageSyntax}} - +QB64 :::TIMER(''number%'') {ON|STOP|OFF|FREE} @@ -15,12 +14,14 @@ QB64 {{PageSyntax}} * TIMER ON enables event trapping of an [[ON TIMER (n)]] statement. While enabled, a check is made after every code statement to see if the specified time has elapsed and the ON TIMER [[GOSUB]] (or [[SUB]] in QB64) procedure is executed. * TIMER STOP disables timer event trapping. When an event occurs while stopped, it is remembered. If timer events are turned back on later, any remembered events are immediately executed. * TIMER OFF turns timer event trapping completely off and no subsequent events are remembered. +* TIMER(n) '''FREE''' clears a specific timer event when it is no longer needed. '''The base TIMER or TIMER(0) cannot be freed!''' + +{{PageDescription}} <center>'''QB64 only'''</center> * Get a TIMER number from [[_FREETIMER]] ONLY except when the base timer(no number or 0) is used. Use specific variables or an array to hold each event number value for later reference. * If the TIMER number is omitted or 0, the TIMER used is the base timer. * Specific TIMER events can be enabled, suspended, turned off or freed using [[TIMER (statement)|TIMER(n)]] ON, STOP, OFF or FREE. -* TIMER(n) '''FREE''' clears a specific timer event when it is no longer needed. '''The base TIMER or TIMER(0) cannot be freed!''' <center>'''QB64 Timing Alternatives'''</center> @@ -29,31 +30,29 @@ QB64 {{PageSyntax}} * [[_LIMIT]] can slow down loops to a specified number of frames per second. This can also alleviate a program's CPU usage. +{{PageExamples}} ''Example:'' How to update the time while [[PRINT|printing]] at the same time in a program. {{CodeStart}} '' '' - TIMER ON ' enable timer event trapping - LOCATE 4, 2 ' set the starting PRINT position - {{Cl|ON TIMER(n)|ON TIMER}}(10) GOSUB Clock ' set procedure execution repeat time - DO WHILE INKEY$ = "": PRINT "A"; : SLEEP 6: LOOP - TIMER OFF - {{Cl|SYSTEM}} +{{Cl|TIMER}} ON ' enable timer event trapping +{{Cl|LOCATE}} 4, 2 ' set the starting PRINT position +{{Cl|ON TIMER(n)|ON TIMER}}(10) {{Cl|GOSUB}} Clock ' set procedure execution repeat time +{{Cl|DO}} {{Cl|WHILE}} {{Cl|INKEY$}} = "": {{Cl|PRINT}} "A"; : {{Cl|SLEEP}} 6: {{Cl|LOOP}} +{{Cl|TIMER}} OFF +{{Cl|SYSTEM}} - Clock: - row = {{Cl|CSRLIN}} ' Save current print cursor row. - col = {{Cl|POS|POS(0)}} ' Save current print cursor column. - LOCATE 2, 37: PRINT {{Cl|TIME$}}; ' print current time at top of screen. - LOCATE row, col ' return to last print cursor position - {{Cl|RETURN}} '' '' +Clock: + row = {{Cl|CSRLIN}} ' Save current print cursor row. + col = {{Cl|POS|POS(0)}} ' Save current print cursor column. + {{Cl|LOCATE}} 2, 37: {{Cl|PRINT}} {{Cl|TIME$}}; ' print current time at top of screen. + {{Cl|LOCATE}} row, col ' return to last print cursor position +{{Cl|RETURN}} '' '' {{CodeEnd}} : NOTE: SLEEP will be interrupted in QBasic. -''See also:'' - +{{PageSeeAlso}} * [[ON TIMER(n)]], [[TIMER]](function) - * [[_DELAY]], [[_LIMIT]] - {{PageNavigation}} diff --git a/internal/help/_CLIPBOARD$.txt b/internal/help/_CLIPBOARD$.txt index 71b54eef5..6f486969e 100644 --- a/internal/help/_CLIPBOARD$.txt +++ b/internal/help/_CLIPBOARD$.txt @@ -1,5 +1,5 @@ {{DISPLAYTITLE:_CLIPBOARD$}} -The [[_CLIPBOARD$]] function returns the current Operating System's clipboard contents as a [[STRING]]. +The [[_CLIPBOARD$]] function returns the current operating system's clipboard contents as a [[STRING]]. {{PageSyntax}} @@ -19,7 +19,7 @@ The [[_CLIPBOARD$]] function returns the current Operating System's clipboard co {{Cl|PRINT}} "Start Program2 to read your text entries! Empty entry quits!" {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "Entry program started!" 'set clipboard initially -DO +{{Cl|DO}} {{Cl|LINE INPUT}} "Enter some text to send to other program: ", text$ {{Cl|IF...THEN|IF}} text$ = "" {{Cl|THEN}} {{Cl|EXIT DO}} {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = text$ @@ -31,11 +31,11 @@ DO {{CodeStart}} {{Cl|PRINT}} "Enter text in Program1 and this program will read it. Esc key quits!" -DO: {{Cl|_LIMIT}} 100 +{{Cl|DO}}: {{Cl|_LIMIT}} 100 text$ = {{Cl|_CLIPBOARD$}} 'function returns clipboard contents {{Cl|IF...THEN|IF}} {{Cl|LEN}}(text$) {{Cl|THEN}} - {{Cl|PRINT}} text$ - {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "" 'clear clipboard after a read + {{Cl|PRINT}} text$ + {{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "" 'clear clipboard after a read {{Cl|END IF}} {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) diff --git a/internal/help/_CLIPBOARD$_(statement).txt b/internal/help/_CLIPBOARD$_(statement).txt index 7536caef5..0225659d9 100644 --- a/internal/help/_CLIPBOARD$_(statement).txt +++ b/internal/help/_CLIPBOARD$_(statement).txt @@ -1,5 +1,5 @@ {{DISPLAYTITLE:_CLIPBOARD$ (statement)}} -The [[_CLIPBOARD$ (statement)|_CLIPBOARD$]] statement copies the [[STRING]] value into the system clipboard. +The [[_CLIPBOARD$ (statement)|_CLIPBOARD$]] statement copies the specified [[STRING]] value into the operating system's clipboard. {{PageSyntax}} diff --git a/internal/help/_MOUSEX.txt b/internal/help/_MOUSEX.txt index 84854b80d..7a119e6bb 100644 --- a/internal/help/_MOUSEX.txt +++ b/internal/help/_MOUSEX.txt @@ -13,7 +13,7 @@ The [[_MOUSEX]] function returns the current horizontal (column) mouse cursor po * [[_MOUSEINPUT]] must be used to detect any changes in the mouse position and is '''required''' for any coordinate returns. -==QBasic/QuickBASIC== +{{PageQBasic}} * In [[SCREEN]] 0, QBasic's [[ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. diff --git a/internal/help/_MOUSEY.txt b/internal/help/_MOUSEY.txt index 0df48c644..da049cbd7 100644 --- a/internal/help/_MOUSEY.txt +++ b/internal/help/_MOUSEY.txt @@ -13,7 +13,7 @@ The [[_MOUSEY]] function returns the current vertical (row) mouse cursor positio * [[_MOUSEINPUT]] must be used to detect any changes in the mouse position and is '''required''' for any coordinate returns. -==QBasic/QuickBASIC== +{{PageQBasic}} * In [[SCREEN]] 0, QBasic's [[ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. diff --git a/internal/help/_RGBA32.txt b/internal/help/_RGBA32.txt index 55c59df58..c56030b01 100644 --- a/internal/help/_RGBA32.txt +++ b/internal/help/_RGBA32.txt @@ -14,7 +14,7 @@ The [[_RGBA32]] function returns the 32-bit ''RGBA'' color value with the specif * {{Parameter|blue&}} specifies the blue component intensity from 0 to 255. * {{Parameter|alpha&}} specifies the [[_ALPHA|''alpha'']] component transparency value from 0 (fully transparent) to 255 (opaque). * Alpha or intensity values outside of the valid range of 0 to 255 are clipped. -* Returns [[LONG]] 32-bit 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 varying [[_ALPHA]] transparency. +* Returns [[LONG]] 32-bit hexadecimal values from '''&H00000000''' to '''&HFFFFFFFF''' with varying [[_ALPHA]] transparency. * When [[LONG]] values are [[PUT]] to file, the ARGB values become BGRA. Use [[LEFT$]]([[MKL$]]({{Parameter|color32value~&}}), 3) to place 3 colors. * '''NOTE: Default 32-bit backgrounds are clear black or [[_RGBA]](0, 0, 0, 0). Use [[CLS]] to make the black opaque.'''