1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-30 05:10:37 +00:00

Merge pull request #119 from QB64Team/fix-seek-eof

Fix EOF not being reset after SEEK is used.
This commit is contained in:
Fellippe Heitor 2021-01-27 22:51:34 -03:00 committed by GitHub
commit f7cd2b2ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 19 deletions

View file

@ -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
@ -23351,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

View file

@ -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 &lt; 1.5 THEN
{{Cl|$ERROR}} Requires QB64 version 1.5 or greater
{{Cl|$END IF}}
{{CodeEnd}}
''Explanation:'' VERSION is a predefined variable that holds the QB64 compiler version. If we know our program needs features only available above a certain version, we can check for that and give the user a helpful error message instead of a confusing error elsewhere in the program.
{{PageSeeAlso}}
* [[$LET]]
* [[$ERROR]]
* [[Metacommand]]s

View file

@ -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.}}

View file

@ -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.}}

View file

@ -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.'''

View file

@ -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]].'''

View file

@ -87,6 +87,7 @@ _ECHO,_ECHO
$ELSE,$ELSE
$ELSEIF,$ELSEIF
$END,$END IF
$ERROR,$ERROR
_ERRORLINE,_ERRORLINE
_ERRORMESSAGE$,_ERRORMESSAGE$
$EXEICON,$EXEICON