From 443cbb39a3aca2767b3c579a72017da6f3b6b96e Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Wed, 27 Jan 2021 20:43:12 -0300 Subject: [PATCH 1/3] Updates help files. --- internal/help/$IF.txt | 23 +++++++++++-- .../help/Keyword_Reference_-_Alphabetical.txt | 1 + .../help/Keyword_Reference_-_By_usage.txt | 1 + internal/help/Metacommand.txt | 3 ++ internal/help/_MEM.txt | 33 ++++++++++--------- internal/help/links.bin | 1 + 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/internal/help/$IF.txt b/internal/help/$IF.txt index 11d52dd9d..96d97fca8 100644 --- a/internal/help/$IF.txt +++ b/internal/help/$IF.txt @@ -14,9 +14,15 @@ * $IF is the start of a precompiler code block which includes or excludes sections of code from being compiled. * There is no single line $IF statement. $IF must be in a valid $IF THEN...$END IF block to work properly. * Like all other metacommands, you can not use more than one metacommand per line. '''Use of : to separate statements in a single line is not allowed.''' -* Variable names can contain numbers, letters, and periods -- in any order. -* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters, and periods, in any order. -* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are: '''WIN''' or '''WINDOWS''' if the user is running QB64 in a Windows environment. '''LINUX''' if the user is running QB64 in a Linux environment. '''MAC''' or '''MACOSX''' if the user is running QB64 in a macOS environment. '''32BIT''' if the user is running a 32-bit version of QB64. '''64BIT''' if the user is running a 64-bit version of QB64. +* Variable names can contain numbers, letters and periods, in any order. +* Expressions can contain one set of leading and/or trailing quotes; and any number of numbers, letters and periods, in any order. +* The precompiler comes with some preset values which can be used to help determine which code blocks to include/exclude. These are: +** '''WIN''' or '''WINDOWS''' if the user is running QB64 in a Windows environment. +** '''LINUX''' if the user is running QB64 in a Linux environment. +** '''MAC''' or '''MACOSX''' if the user is running QB64 in a macOS environment. +** '''32BIT''' if the user is running a 32-bit version of QB64. +** '''64BIT''' if the user is running a 64-bit version of QB64. +** '''VERSION''', which is set to the version of the QB64 compiler. This is a number and can be ordered, see example below. * [[$END IF]] denotes the end of a valid precompiler $IF block. * [[$ELSEIF]] must follow a valid $IF or $ELSEIF statement. * If [[$ELSE]] is used, it must be used as the last conditional check before $END IF. $ELSEIF cannot come after $ELSE. @@ -58,8 +64,19 @@ The [[$LET]] and $IF statements let the programmer control the code that actuall ''Explanation:'' For the above, the CONST slash is defined by the automatic internal flags which returns what operating system is being used at compile time. On a Windows PC, the Slash will be the backslash; for any other OS it will be the forward slash. +''Example 3:'' +{{CodeStart}} '' '' +{{Cl|$IF}} VERSION < 1.5 THEN + {{Cl|$ERROR}} Requires QB64 version 1.5 or greater +{{Cl|$END IF}} +{{CodeEnd}} + +''Explanation:'' VERSION is a predefined variable that holds the QB64 compiler version. If we know our program needs features only available above a certain version, we can check for that and give the user a helpful error message instead of a confusing error elsewhere in the program. + + {{PageSeeAlso}} * [[$LET]] +* [[$ERROR]] * [[Metacommand]]s diff --git a/internal/help/Keyword_Reference_-_Alphabetical.txt b/internal/help/Keyword_Reference_-_Alphabetical.txt index 5f7c22434..da012ff44 100644 --- a/internal/help/Keyword_Reference_-_Alphabetical.txt +++ b/internal/help/Keyword_Reference_-_Alphabetical.txt @@ -142,6 +142,7 @@ __NOTOC__ * [[$ELSE]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler.}} * [[$ELSEIF]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler.}} * [[$END IF]] (Pre-Compiler [[Metacommand]]) {{text|used in conjunction with $IF for the precompiler.}} +* [[$ERROR]] (Pre-Compiler [[Metacommand]]) {{text|used to trigger compiler errors.}} * [[_ERRORLINE]] (function) {{text|returns the source code line number that caused the most recent runtime error.}} * [[_ERRORMESSAGE$]] (function) {{text|returns a human-readable message describing the most recent runtime error.}} * [[$EXEICON]] (Pre-Compiler [[Metacommand]]) {{text|used with a .ICO icon file name to embed the image into the QB64 executable.}} diff --git a/internal/help/Keyword_Reference_-_By_usage.txt b/internal/help/Keyword_Reference_-_By_usage.txt index c2a3e859b..8f58c19bc 100644 --- a/internal/help/Keyword_Reference_-_By_usage.txt +++ b/internal/help/Keyword_Reference_-_By_usage.txt @@ -657,6 +657,7 @@ The following table describes the error codes that are reported by the '''QB64'' * [[$CHECKING]]:OFF/ON {{text|(QB64 only) turns event and error checking ON and OFF. ON (default) can only be used after it is OFF.}} * [[$CONSOLE]] {{text|creates a console window throughout the program.}} +* [[$ERROR]] (Pre-Compiler [[Metacommand]]) {{text|used to trigger compiler errors.}} * [[$SCREENHIDE]] {{text|hides the program window throughout the program until [[$SCREENSHOW]] is used.}} * [[$SCREENSHOW]] {{text|displays the main program window throughout the program only after [[$SCREENHIDE]] or [[_SCREENHIDE]] has been used.}} diff --git a/internal/help/Metacommand.txt b/internal/help/Metacommand.txt index 27a04ae03..ea85aab58 100644 --- a/internal/help/Metacommand.txt +++ b/internal/help/Metacommand.txt @@ -36,6 +36,8 @@ :[[$IF]]...[[$END IF]] 'precompiler directive +: [[$ERROR]] MESSAGE 'trigger a compilation error, useful inside $IF blocks + ===Description=== * [[$INCLUDE]] can be used at the beginning or at the end of program SUB procedures. @@ -44,6 +46,7 @@ * [[$RESIZE]]:ON allows a user to resize the program window. OFF is default. * [[$SCREENHIDE]] hides the QB64 program window throughout the program until [[$SCREENSHOW]] is used. * [[$IF]]...[[$END IF]] allows selective inclusion of code in the final program. +* [[$ERROR]] MESSAGE causes a compilation error whenever QB64 attempts to compile it, displaying MESSAGE to the user. This is useful if inside a $IF block, as the error can be conditional. * '''Do not comment out with ' or [[REM]] QB64-specific metacommands.''' diff --git a/internal/help/_MEM.txt b/internal/help/_MEM.txt index 48f0c540c..28d2cf2e4 100644 --- a/internal/help/_MEM.txt +++ b/internal/help/_MEM.txt @@ -28,22 +28,23 @@ END TYPE :: ''name'''''.TYPE''' is the type (represented as bits combined to form a value) AS [[_OFFSET]]: ==.TYPE values == -:::* 0 = UDT ([[TYPE|user defined type]]) or memory created by [[_MEMNEW]] -:::* 1 = 1 bit ELEMENT.SIZE=1 *Only used along with specific types (currently integers or floats) -:::* 2 = 2 bit. ELEMENT.SIZE=2 * -:::* 4 = 4 bit. ELEMENT.SIZE=4 * -:::* 8 = 8 bit. ELEMENT.SIZE=8 * -:::* 16 = 16 bit. ELEMENT.SIZE=16 * -:::* 32 = 32 bit. ELEMENT.SIZE=32 * -:::* 64 = 64 bit. ELEMENT.SIZE=64 * -:::* 128 = 128 bit. ELEMENT.SIZE=128 * -:::* 256 = 256 bit. ELEMENT.SIZE=256 * -:::* 512(+ bit*) = integer types only(ie. whole numbers) -:::* 1024(+ bit*) = floating point types only(ie. numbers that can have a decimal point) -:::* 2048 = [[STRING]] type only -:::* 4096(+ 512 + bit*) = [[_UNSIGNED]] integer type only -:::* 8192 = [[_MEM]] type only -:::* 16384(+ 512 + bit*)= [[_OFFSET]] type only +:::* [bit 0] 1* byte types (_BYTE) +:::* [bit 1] 2* byte types (INTEGER) +:::* [bit 2] 4* byte types (LONG or SINGLE) +:::* [bit 3] 8* byte types (DOUBLE or _INTEGER64) +:::* [bit 4] 16* byte types (reserved for future use) +:::* [bit 5] 32* byte types (_FLOAT) +:::* [bit 6] 64* byte types (reserved for future use) +:::* [bit 7] 128 = integer types (_BYTE, INTEGER, LONG, _INTEGER64) (added to *) +:::* [bit 8] 256 = floating point types (SINGLE, DOUBLE, _FLOAT) (added to *) +:::* [bit 9] 512 = STRING types (fixed length or variable length) +:::* [bit 10] 1024 = _UNSIGNED types (added to *+128) +:::* [bit 11] 2048 = pixel data usually from _MEMIMAGE (added to 1+128+1024 for 256 color screens, or 2+128+1024 for text screens, or 4+128+1024 for 32-bit color screens) +:::* [bit 12] 4096 = _MEM TYPE structure (NOT added to 32768) +:::* [bit 13] 8192 = _OFFSET type (added to 4+128+[1024] or 8+128+[1024] or future_size+128+[1024]) +:::* [bit 14] 16384 = data created/defined by _MEMNEW(size) or _MEMNEW(offset,size) +:::* [bit 15] 32768 = a custom, user defined type (ie. created with TYPE name ... END TYPE) +:::* [bit 16] 65536 = an array of data (added to other type values defining the array's data type) ''Note: If a future integer, float or other type doesn't have a size that is 1,2,4,8,16,32,64,128 or 256 it won't have a size-bit set.'' * '''Note: [[_OFFSET]] values cannot be cast to other variable [[Variable Types|type]]s reliably. _MEM is a reserved custom variable [[Variable Types|type]].''' diff --git a/internal/help/links.bin b/internal/help/links.bin index e40949da6..bb81f2681 100644 --- a/internal/help/links.bin +++ b/internal/help/links.bin @@ -87,6 +87,7 @@ _ECHO,_ECHO $ELSE,$ELSE $ELSEIF,$ELSEIF $END,$END IF +$ERROR,$ERROR _ERRORLINE,_ERRORLINE _ERRORMESSAGE$,_ERRORMESSAGE$ $EXEICON,$EXEICON From e273baa0ddccd277e72a592cad6232cdd0e447e9 Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Wed, 27 Jan 2021 22:17:26 -0300 Subject: [PATCH 2/3] Reset EOF when SEEK is used. --- internal/c/libqb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 6e536f839..7a49f9ec8 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -23337,6 +23337,10 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ f->file_handle->seekp(position); } f->pos=position; + if (f->pos<=gfs_lof(i)){ + f->eof_passed=0; + f->eof_reached=0; + } return 0; #endif From 4824f9c67b2d7491d916fea5c96c8e10ee4b0abd Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Wed, 27 Jan 2021 22:19:32 -0300 Subject: [PATCH 3/3] Should be the same for Windows. --- internal/c/libqb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 7a49f9ec8..f37ec5d4d 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -23355,6 +23355,10 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ } } f->pos=position; + if (f->pos<=gfs_lof(i)){ + f->eof_passed=0; + f->eof_reached=0; + } return 0; #endif