FC_ReadFromFile - General Information

Overview

Type:

Function

Available as of:

SystemInterface_1.32.6.0

Versions:

Current version

Task

Read the number of bytes from a file.

Description

The function reads the number (i_diCount) of bytes from a file identified with i_diFileId to a variable (i_pbyVarAdr).

NOTE: The processing time of this function is a few hundred milliseconds. This is why the times for the cycle check of the task in which this function is performed should be increased one-time. For example FC_CycleCheckTimeSet(500, 2).

Interface

Input

Data type

Description

i_diFileId

DINT

Name of the file from which you want to read from

i_pbyVarAdr

POINTER TO BYTE

Variable in which bytes shall be written

i_diCount

DINT

Number of bytes that shall be read/written

Return Value

Data type

Description

DINT

0: OK

-3: Incorrect FileId (< 0 or >9)

-5: Read error detected or file is not open or the end of the file is reached

Examples

 FileNr:= FC_Open_WriteFile(i_sFilename:= 'CSpline');  
 lResult:= FC_WriteToFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(Header), i_diCount:=SIZEOF(Header));  
 lResult:= FC_WriteToFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(B0), i_diCount:=SIZEOF(B0));  
 lResult:= FC_WriteToFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(B1), i_diCount:=SIZEOF(B1));  
 lResult:= FC_CloseFile(i_diFileId:=FileNr); .... ....  
 FileNr:= FC_AppendToWriteFile(i_sFilename:='CSpline');  
 lResult:= FC_WriteToFile(i_diFileId:= FileNr, i_pbyVarAdr:= ADR(SP), i_diCount:=SIZEOF(SP));  
 lResult:= FC_CloseFile(i_diFileId:=FileNr); .... ....  
 FileNr:= FC_Open_ReadFile(i_sFilename:='CSpline');  
 lResult:= FC_ReadFromFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(Header), i_diCount:=SIZEOF(Header));  
 lResult:= FC_ReadFromFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(B0), i_diCount:=SIZEOF(B0));  
 lResult:= FC_ReadFromFile(i_diFileId:=FileNr, i_pbyVarAdr:=ADR(B1),i_diCount:=SIZEOF(B1));  
 lResult:= FC_ReadFromFile(i_diFileId:= FileNr, i_pbyVarAdr:= ADR(SP),i_diCount:=SIZEOF(SP));  
 lResult:= FC_CloseFile(i_diFileId:=FileNr);