Revision history for KeyPgGetfileio


Revision [22308]

Last edited on 2018-05-11 13:05:40 by fxm [Updated first example]
Additions:
Dim Shared f As Integer
Sub get_long()
Dim buffer As Long ' Long variable
' Read a Long (4 bytes) from the file into buffer, using file number "f".
Get #f, , buffer
Print buffer
Print
End Sub
Sub get_array()
Dim an_array(0 To 10-1) As Long ' array of Longs
' Read 10 Longs (10 * 4 = 40 bytes) from the file into an_array, using file number "f".
Get #f, , an_array()
For i As Integer = 0 To 10-1
Print an_array(i)
Next
Print
End Sub
Sub get_mem
Dim pmem As Long Ptr
' allocate memory for 5 Longs
pmem = Allocate(5 * SizeOf(Long))
' Read 5 Longs (5 * 4 = 20 bytes) from the file into allocated memory
Get #f, , *pmem, 5 ' Note pmem must be dereferenced (*pmem, or pmem[0])
For i As Integer = 0 To 5-1
Print pmem[i]
Next
Print
Deallocate pmem
End Sub
f = FreeFile
Open "file.ext" For Binary As #f
get_long()
Close #f
Deletions:
dim shared f as integer
sub get_integer()
dim buffer as integer ' Integer variable
' Read an Integer (4 bytes) from the file into buffer, using file number "f".
get #f, , buffer
print buffer
print
end sub
sub get_array()
dim an_array(0 to 10-1) as integer ' array of Integers
' Read 10 Integers (10 * 4 = 40 bytes) from the file into an_array, using file number "f".
get #f, , an_array()
for i as integer = 0 to 10-1
print an_array(i)
next
print
end sub
sub get_mem
dim pmem as integer ptr
' allocate memory for 5 Integers
pmem = allocate(5 * sizeof(integer))
' Read 5 integers (5 * 4 = 20 bytes) from the file into allocated memory
get #f, , *pmem, 5 ' Note pmem must be dereferenced (*pmem, or pmem[0])
for i as integer = 0 to 5-1
print pmem[i]
next
print
deallocate pmem
end sub
f = freefile
open "file.ext" for binary as #f
get_integer()
close #f


Revision [22307]

Edited on 2018-05-11 01:08:46 by fxm [Added a note if passing a dereferenced [w/z]string pointer to Get]
Additions:
//Note: If a dereferenced [w/z]string pointer is passed to ##**Get**##, the ##//amount//## parameter is not taken into account as it is by passing a dereferenced numeric pointer. But instead, the pointed buffer must begin with at least as many non-zero elements as the number of elements to read.//
Deletions:
//Note: If a [w/z]string dereferenced pointer is passed to ##**Get**##, the ##//amount//## parameter is not taken into account as it is by passing a dereferenced numeric pointer. But instead, the pointed buffer must begin with at least as many non-zero elements as the number of elements to read.//


Revision [22306]

Edited on 2018-05-11 01:04:06 by fxm [Added a note if passing a [w/z]string dereferenced pointer to Get]
Additions:
//Note: If a [w/z]string dereferenced pointer is passed to ##**Get**##, the ##//amount//## parameter is not taken into account as it is by passing a dereferenced numeric pointer. But instead, the pointed buffer must begin with at least as many non-zero elements as the number of elements to read.//
Deletions:
//Note: If a [w/z]string dereferenced pointer is passed to ##**Get**##, the ##//amount//## parameter is not taken into account as it is by passing a dereferenced numeric pointer. But instead the pointed buffer must begin with at least as many non-zero elements as elements to read.//


Revision [22305]

Edited on 2018-05-11 00:58:36 by fxm [Added a note if passing a [w/z]string dereferenced pointer Get]
Additions:
//Note: If a [w/z]string dereferenced pointer is passed to ##**Get**##, the ##//amount//## parameter is not taken into account as it is by passing a dereferenced numeric pointer. But instead the pointed buffer must begin with at least as many non-zero elements as elements to read.//


Revision [21306]

Edited on 2016-04-03 16:16:37 by fxm [Get() returns a 32 bit Long]
Additions:
##**Get()**## returns a 32 bit ##[[KeyPgLong|Long]]##: a zero (##0##) on success; non-zero on error.
Note: if ##[[KeyPgEof|EOF]]## (end of file) is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.
Deletions:
Zero (##0##) on success; non-zero on error. Note: if ##[[KeyPgEof|EOF]]## (end of file) is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.


Revision [20934]

Edited on 2016-03-13 01:52:23 by fxm [Formatting]

No Differences

Revision [20252]

Edited on 2016-02-10 16:00:50 by DkLwikki [Update link format]
Additions:
**Get** #//filenum// [[KeyPgAs|As]] [[KeyPgLong|Long]], [//position// [[KeyPgAs|As]] [[KeyPgLongint|longint]]], [[KeyPgByref|ByRef]] //data// [[KeyPgAs|As]] [[KeyPgAny|Any]] [, [//amount// [[KeyPgAs|As]] [[KeyPgUinteger|Uinteger]]] [, [[KeyPgByref|ByRef]] //bytesread// [[KeyPgAs|As]] [[KeyPgUinteger|Uinteger]]] ]
**Get** #//filenum// [[KeyPgAs|As]] [[KeyPgLong|Long]], [//position// [[KeyPgAs|As]] [[KeyPgLongint|longint]]], //data// [[KeyPgAs|As]] [[KeyPgString|String]] [, , [[KeyPgByref|ByRef]] //bytesread// [[KeyPgAs|As]] [[KeyPgUinteger|Uinteger]] ]
**Get** #//filenum// [[KeyPgAs|As]] [[KeyPgLong|Long]], [//position// [[KeyPgAs|As]] [[KeyPgLongint|longint]]], //data()// [[KeyPgAs|As]] [[KeyPgAny|Any]] [, , [[KeyPgByref|ByRef]] //bytesread// [[KeyPgAs|As]] [[KeyPgUinteger|Uinteger]] ]
The value passed to ##[[KeyPgOpen|Open]]## when the file was opened.
The position where the read must start. If the file was opened ##[[KeyPgRandom|For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, reading starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position ##1##.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless the ##[[KeyPgEof|EOF]]## is reached.
When getting ##[[KeyPgString|String]]##s, the number of bytes read is the same as the number of bytes in the string data. ##//amount//## is not allowed.
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf|Operator * (Value of)]]##.) If you pass a pointer directly, then ##**Get**## will overwrite the pointer variable, not the memory it points to.
Makes ##**Get**## read ##//amount//## consecutive variables from file to memory, i.e. it reads ##(//amount// * [[KeyPgSizeof|Sizeof]](//data//) )## bytes of data from file into the memory starting at ##//data//##'s memory location. If ##//amount//## is omitted it defaults to ##1##, meaning that ##**Get**## just reads a single variable.
Zero (##0##) on success; non-zero on error. Note: if ##[[KeyPgEof|EOF]]## (end of file) is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.
For files opened in ##[[KeyPgRandom|Random]]## mode, the size in bytes of the data to read must match the specified record size.
print an_array(i)
print pmem[i]

txt = String(Lof(h), 0)
if Get( #h, ,txt ) <> 0 then txt = ""

- ##[[KeyPgGetgraphics|Get (Graphics)]]## different usage of same keyword
- ##[[KeyPgPutfileio|Put (File I/O)]]##
- ##[[KeyPgOpen|Open]]##
- ##[[KeyPgClose|Close]]##
- ##[[KeyPgBinary|Binary]]##
- ##[[KeyPgRandom|Random]]##
- ##[[KeyPgFreefile|Freefile]]##
- ##[[ProPgFileIO|File I/O methods comparison]]##
Deletions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], [[KeyPgByref ByRef]] //data// [[KeyPgAs As]] [[KeyPgAny Any]] [, [//amount// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] [, [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data// [[KeyPgAs As]] [[KeyPgString String]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data()// [[KeyPgAs As]] [[KeyPgAny Any]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
The value passed to ##[[KeyPgOpen Open]]## when the file was opened.
The position where the read must start. If the file was opened ##[[KeyPgRandom For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, reading starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position ##1##.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless the ##[[KeyPgEof EOF]]## is reached.
When getting ##[[KeyPgString String]]##s, the number of bytes read is the same as the number of bytes in the string data. ##//amount//## is not allowed.
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf Operator * (Value of)]]##.) If you pass a pointer directly, then ##**Get**## will overwrite the pointer variable, not the memory it points to.
Makes ##**Get**## read ##//amount//## consecutive variables from file to memory, i.e. it reads ##(//amount// * [[KeyPgSizeof Sizeof]](//data//) )## bytes of data from file into the memory starting at ##//data//##'s memory location. If ##//amount//## is omitted it defaults to ##1##, meaning that ##**Get**## just reads a single variable.
Zero (##0##) on success; non-zero on error. Note: if ##[[KeyPgEof EOF]]## (end of file) is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.
For files opened in ##[[KeyPgRandom Random]]## mode, the size in bytes of the data to read must match the specified record size.
print an_array(i)
print pmem[i]

txt = String(Lof(h), 0)
if Get( #h, ,txt ) <> 0 then txt = ""

- ##[[KeyPgGetgraphics Get (Graphics)]]## different usage of same keyword
- ##[[KeyPgPutfileio Put (File I/O)]]##
- ##[[KeyPgOpen Open]]##
- ##[[KeyPgClose Close]]##
- ##[[KeyPgBinary Binary]]##
- ##[[KeyPgRandom Random]]##
- ##[[KeyPgFreefile Freefile]]##
- ##[[ProPgFileIO File I/O methods comparison]]##


Revision [17499]

Edited on 2015-04-01 11:52:06 by DkLwikki [integer => long/uinteger]
Additions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], [[KeyPgByref ByRef]] //data// [[KeyPgAs As]] [[KeyPgAny Any]] [, [//amount// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] [, [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data// [[KeyPgAs As]] [[KeyPgString String]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgLong Long]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data()// [[KeyPgAs As]] [[KeyPgAny Any]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
Deletions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], [[KeyPgByref ByRef]] //data// [[KeyPgAs As]] [[KeyPgAny Any]] [, [//amount// [[KeyPgAs As]] [[KeyPgInteger Integer]]] [, [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data// [[KeyPgAs As]] [[KeyPgString String]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data()// [[KeyPgAs As]] [[KeyPgAny Any]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]


Revision [14838]

Edited on 2010-09-25 13:38:59 by AgAmemnus [this sentence doesn't have any meaning / is incorrect]
Additions:
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf Operator * (Value of)]]##.) If you pass a pointer directly, then ##**Get**## will overwrite the pointer variable, not the memory it points to.
Deletions:
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf Operator * (Value of)]]##.) Get will automatically infer that the rest of the buffer continues after the first variable. If you pass a pointer directly, then ##**Get**## will overwrite the pointer variable, not the memory it points to.


Revision [14239]

Edited on 2009-08-20 03:03:52 by CountingPine [updated]

No Differences

Revision [14097]

Edited on 2009-01-17 20:42:10 by CountingPine [Further clarification]
Additions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], //data// [[KeyPgAs As]] [[KeyPgString String]] [, , [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]] ]
The value passed to ##[[KeyPgOpen Open]]## when the file was opened.
The position where the read must start. If the file was opened ##[[KeyPgRandom For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, reading starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position ##1##.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless the ##[[KeyPgEof EOF]]## is reached.
When getting arrays, ##//data//## should be followed by an empty pair of brackets: "##()##". ##**Get**## will read data for all of the values in the array. ##//amount//## is not allowed.
When getting ##[[KeyPgString String]]##s, the number of bytes read is the same as the number of bytes in the string data. ##//amount//## is not allowed.
Makes ##**Get**## read ##//amount//## consecutive variables from file to memory, i.e. it reads ##(//amount// * [[KeyPgSizeof Sizeof]](//data//) )## bytes of data from file into the memory starting at ##//data//##'s memory location. If ##//amount//## is omitted it defaults to ##1##, meaning that ##**Get**## just reads a single variable.
Deletions:
The value passed to ##[[KeyPgOpen Open]]## when the file was opened
The position where the read must start. If the file was opened ##[[KeyPgRandom For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, read starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position ##1##.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless the ##[[KeyPgEof EOF]]## is reached. When getting arrays, ##//data//## should be followed by an empty pair of brackets: "##()##". ##**Get**## will write all of the data in the array. ##//amount//## is not allowed.
Limits ##**Get**## to read read ##//amount// * [[KeyPgSizeof Sizeof]](//datatype//)## bytes of data. If ##//amount//## is omitted it defaults to ##1##, and ##**Get**## just reads a single variable of the buffer's data type.


Revision [14067]

Edited on 2008-12-28 18:14:36 by CountingPine [When position = 0...]
Additions:
If ##//position//## is omitted or zero (##0##), file reading will start from the current file position.


Revision [14000]

Edited on 2008-12-01 04:55:56 by DoS386 [+link]
Additions:
- ##[[KeyPgGetgraphics Get (Graphics)]]## different usage of same keyword


Revision [13844]

Edited on 2008-10-30 19:19:21 by CountingPine [+link]
Additions:
- ##[[KeyPgBinary Binary]]##
- ##[[KeyPgRandom Random]]##


Revision [13833]

Edited on 2008-10-30 18:53:49 by CountingPine [+link]
Additions:
The position where the read must start. If the file was opened ##[[KeyPgRandom For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, read starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position ##1##.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless the ##[[KeyPgEof EOF]]## is reached. When getting arrays, ##//data//## should be followed by an empty pair of brackets: "##()##". ##**Get**## will write all of the data in the array. ##//amount//## is not allowed.
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf Operator * (Value of)]]##.) Get will automatically infer that the rest of the buffer continues after the first variable. If you pass a pointer directly, then ##**Get**## will overwrite the pointer variable, not the memory it points to.
Limits ##**Get**## to read read ##//amount// * [[KeyPgSizeof Sizeof]](//datatype//)## bytes of data. If ##//amount//## is omitted it defaults to ##1##, and ##**Get**## just reads a single variable of the buffer's data type.
Zero (##0##) on success; non-zero on error. Note: if ##[[KeyPgEof EOF]]## (end of file) is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.
##**Get**## can be used as a function, and will return ##0## on success or an error code on failure.
- ##**Get**## can be used as a function in FB, to find the success/error code returned without having to use error handling procedures.
Deletions:
The position where the read must start. If the file was opened ##[[KeyPgRandom For Random]]##, the position is in records; otherwise, it is in bytes. If omitted, read starts at the present file pointer position. The position is 1-based: i.e. first record or byte of a file is at position 1.
The buffer where data is written. It can be a numeric variable, a string, an array, a user defined type or a dereferenced pointer. The read operation will try to fill completely the variable, unless //amount// is given or the ##[[KeyPgEof EOF]]## is reached.
Note: If you want to read values into a buffer, you should NOT pass a pointer to the buffer; instead you should pass the first variable in the buffer. (This can be done by dereferencing the pointer with ##[[KeyPgOpValueOf Operator * (Value of)]]##.) Get will automatically infer that the rest of the buffer continues after the first variable. If you pass a pointer directly, then ##**Get**## will overwrite the pointer, not the memory it points to.
Limits ##**Get**## to read read ##//amount// * [[KeyPgSizeof Sizeof]](//datatype//)## bytes of data. If ##//amount//## is omitted it defaults to 1, and ##**Get**## reads one variable of the buffer's data type.
Zero (##0##) on success; non-zero on error. Note: if EOF is reached while reading, ##**Get**## will return success. The amount of bytes actually read can be checked by passing a ##//bytesread//## variable.
##**Get**## can be used as a function, and will return 0 on success or an error code on failure.
- ##**Get**## can be used as a function in FB.


Revision [13777]

Edited on 2008-10-12 05:33:24 by DoS386 [+ link]
Additions:
- ##[[ProPgFileIO File I/O methods comparison]]##


Revision [13602]

Edited on 2008-07-21 18:48:17 by JeffMarshall [missing comma]
Additions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], [[KeyPgByref ByRef]] //data// [[KeyPgAs As]] [[KeyPgAny Any]] [, [//amount// [[KeyPgAs As]] [[KeyPgInteger Integer]]] [, [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] ]
Deletions:
**Get** #//filenum// [[KeyPgAs As]] [[KeyPgInteger Integer]], [//position// [[KeyPgAs As]] [[KeyPgLongint longint]]], [[KeyPgByref ByRef]] //data// [[KeyPgAs As]] [[KeyPgAny Any]] [, [//amount// [[KeyPgAs As]] [[KeyPgInteger Integer]]] [ [[KeyPgByref ByRef]] //bytesread// [[KeyPgAs As]] [[KeyPgUinteger Uinteger]]] ]


Revision [13507]

The oldest known version of this page was created on 2008-07-13 18:41:07 by CountingPine [missing comma]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode