h6. [[MessageTrans]] h6(. » [[MessageTrans SWI Calls|SWI Calls]] h6((. » MessageTrans_OpenFile h2. MessageTrans_OpenFile h5. (SWI &41501) |_<^{width:4em}. Entry | | |<^. R0 |<^. Pointer to file descriptor (held in the RMA if R2 = 0 on entry) | |<^. R1 |<^. Pointer to filename (held in the RMA if R2 = 0 on entry) | |<^. R2 |<^. Pointer to buffer to hold the file data, or value of 0 (allocate some space in RMA, or use file directly if possible) | |_<^{width:4em}. Exit | | |<^. - |<^. - | h4. Use This SWI is used to open a message-file. If R2 = 0, then the data-structure in R0 and the filename in R1 both must be in the RMA. h4. Notes An application may decide that it would like to buffer the file in its own workspace (rather than the RMA) if it needs to be loaded, or use the file directly if it is already in memory. To do this: <pre> SYS "MessageTrans_FileInfo",,filename$ TO flags%,,size% IF flags% AND 1 THEN buffer%=0 ELSE buffer%=FNalloc(size%) SYS "OS_Module",6,,,17+LENfilename$ TO ,,filedesc% $(filedesc%+16)=filename$ SYS "MessageTrans_OpenFile",filedesc%,filedesc%+16,buffer% </pre> where FNalloc() allocates a buffer of a given size, by using the [[Wimp_SlotSize]] or "END=" command. In fact the filename and file descriptor only need to be in the RMA if R2=0 on entry to MessageTrans_OpenFile. h4. See also * [[MessageTrans_CloseFile]] * [[MessageTrans_FileInfo]] * [[OS_Module]] * [[Wimp_SlotSize]]