Please enable JavaScript to view this site.

This function allows you to open a file on CF for reading or writing and obtain a handle, which is to be used as a parameter for subsequent operations on the same file(f_puts(), f_close(), ..).

Syntax

i32 f_open (string fileName, string mode, i32 maxChar, stru_filehnd stru)

fileName

This is the name (complete with extension) of the file you intend to open.

NOTE: The name must be preceded by the indication of the logical device you intend to work on, which can be FA, FB, etc. It can be a local or global string variable, or a constant string.

mode

This is a parameter that specifies how the file is opened and can take one of the following values:

Value

Meaning

"rb"

Open in read, binary mode

"rt"

Read opening, text mode

"wb"

Writing opening, binary mode

"wt"

Opening in write, text mode

"ab"

Opening in append, binary mode

"at"

Opening in append, text mode

maxChar

WARNING: From RTE >= 33 must be imposed equal to zero.

This is a parameter that specifies the maximum number of characters that made the file.

This value must be given when opening a file for writing, while it must be set to 0 when the file is opened for reading.

This parameter is used by the operating system to reserve in flash a fixed portion of memory in which the file will later be written

stru

Variable of type stru_filehnd where the handle characterizing the opened file will be stored and remain associated with it during all subsequent operations, until the file is closed by the instruction f_close().

This variable is to be used as a parameter in all other file handling functions

Result

Returns:

Value

Description

0

Negative result of the operation

<> 0

Positive result of the operation

Validity

Task

Note

If functions regarding compact flash management are used, it is recommended to impose bit 14 of the sys_cfg variable (0x00004000) to 1, to enable the use of safety routines for flash writing/reading

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC