Name
ReadMem -- read raw data from a file (V2.0)
Synopsis
ReadMem(file_id, blk_id, len[, offset])
Function
This function allows you to read len bytes raw data from an open file (specified by file_id, use OpenFile() to open files) to a memory block (specified by blk_id). Additionally you can specify the optional offset argument to define where in the memory block the raw data shall be stored. The data from the source file is read from the current cursor position in the file which you can modify using the Seek() command.

Inputs
file_id
identifier of an open file
blk_id
identifier of a memory block
len
bytes to read from the file
offset
optional: where to store the data in the block (defaults to 0 = beginning of the block)
Example
len = FileSize("C:SetPatch")
OpenFile(1, "C:SetPatch", #MODE_READ)
AllocMem(1, len)
ReadMem(1, 1, len)
CloseFile(1)
OpenFile(1, "Ram:Copy_of_SetPatch", #MODE_WRITE)
WriteMem(1, 1, len)
CloseFile(1)
FreeMem(1)
Makes a copy of the SetPatch program in RAM: by using the two raw data i/o functions ReadMem() and WriteMem().

Show TOC