Search the Community
Showing results for tags 'direct access file'.
-
This UDf ( _FileDirectAccess.au3 ) implements direct access file method. It allows to create files with fixed-legth records with many fields, so you can write or read these records giving their record number. version 2 in sept 10 2017. I dis some importante changes. Records can have up to 180 fields. Each field can be: type 1= int32 (occupies 4 bytes in record) type 2= int64 (occupies 8 bytes in record) type 3= string (size defined by user) type 4= real - double (occupies 8 bytes) (not working yet, but for now you can use string with m chars -> ex: m=10, 16 or 20), where the most sgnificant digits are preserved (left digits) If there is any interest on them, I can put the formal UDF comments describing better the functions. How they work: open/create a DA file: _fileDA_Open (ByRef $file, $filename, $mode, $flush=10 ) Param1= variable previously created by user, ex: $file=0. It will be converted in an array, where all fle information is saved, including record fields. Param2= open mode = read (1) , read+write file (2), read+write+create (3) mode=1 => file must exists and can only be read, mode=2 => file + path will be created if does not exists. Record pointer will be after last record (so a write will be at file´s end), mode 3 => a previous file will be erased. File + path will be created. Param3= flush at each "n" writes. If 0, there are no flushes. default = 10 = a flush at each 10 writes define record fields and size: _FileDA_defineRecord(ByRef $file, $fields) Param1= array describing file, created by _fileDA_Open Param2= array [n][2]: n= # fields, [n][0]=field type, [n][1]= field lenght (used just if string, otherwise ignored) writes a record: _fileDA_Write (ByRef $file, ByRef $record) Param1= array describing file, created by _fileDA_Open Param2= array[n], n= number of record´s fields. [0]= field1, [1]= field2... each field must have same definition´s datatypes ** strings smaller than field´s size => will be filled with " ", bigger will be right trimmed (left n chars will remain) reads a record: _fileDA_Read (ByRef $file, ByRef $record) Param1= array describing file, created by _fileDA_Open Param2= array with # columns >= # fields. Each array´s column receives a record field Positions file pointer at next record to be read or write: _fileDA_Pos (ByRef $file, $pos, $origin=0) Param1= array describing file, created by _fileDA_Open Param2= pointer position. Param3= type of positioning: 0= absolute form start (default), 1= relative to the current position Closes file: _fileDA_Close (ByRef $file, $free=1) Param1= array describing file, created by _fileDA_Open Param2= type of close: 1 (defaut), clears $file array, so another file can be created on this variable. 0= another open is necessary, but defineRecord is not (ex: read) Besides attached UDF, there is na example that covers it´s usage. version 2 : _FileDirectAccess.au3