<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > File > FILE: functions working on files > FILE_GETR |
Description
Read a data record from a file open AS RANDOM
Syntax
s = FILE_GETR(FileID, nRec, UDTStructure)
Returns
Return a string containing the same data that will be filled into UDTStructure.
Parameters
Name |
Type |
Optional |
Meaning |
FileID |
Number |
No |
A previously open random access file handle |
nRec |
Number |
No |
Record number to be retrieved |
UDTStructre |
UDT |
No |
Any UDT data structure. Use the same UDT to GET data from and PUT into a random access file. This UDT structure will receive retrieved data |
Remarks
Restrictions
See also
Examples
Thanks to Psch for the following script example
USES "File", "Console"
Type tRecord
LName As String * 12
FName As String * 8
Age As Byte
End Type
Dim Item As tRecord
Dim OutFileName As String = app_sourcepath & "Test.DAT"
Dim f As DWORD
file_KILL(OutFileName)
f = file_Open(OutFileName, "random", SIZEOF(tRecord))
PRINTL "Vader in the file"
Item.LName = "Vader"
Item.FName = "Darth"
Item.Age = 40
file_putr(f, 1, Item)
PRINTL "Yoda in the file"
Item.LName = "Yoda"
Item.FName = "Mister"
Item.Age = 45
file_putr(f, 2, Item)
PRINTL "---------------------------"
PRINTL "Seeking first: "
file_getr(f, 1, Item)
PRINTL item.LName, item.FName, item.Age
PRINTL "Seeking second: "
file_getr(f, 2, Item)
PRINTL item.LName, item.FName, item.Age
file_Close(f)
WAITKEY