![Advantech UbiQ User Manual Download Page 81](http://html1.mh-extra.com/html/advantech/ubiq/ubiq_user-manual_2856809081.webp)
75
UbiQ Scenario Manager User Manual
Chapter 5
Functions
Reference
5.2.21
read
Syntax
int read(int hFile,char *buf, int nCount)
Parameters
hFile: Specifies the handle referring to open file
buf: Specifies the storage location for data
nCount: Specifies the maximum number of bytes
Description
This function returns the number of bytes read, which may be less than nCount
if there are fewer than count bytes left in the file. If the function tries to read at
end of file, it returns 0. If the handle is invalid, or the file is not open for reading,
or the file is locked, the function returns -1.
Example
int hFile;
int nLen;
char data[512];
hFile=open(“\\flash storage\\template.txt”, FILE_CREATE_RW);
setdebug(TRUE);
if (hFile==0) {
debug(“Open file failed!”);
}
else {
// process the file
nLen=read(hFile, data, 512);
while (nLen!=512) {
nLen=read(hFile,data,512);
}
close(hFile); // close the file
}
See Also
open, close, write, seek, readln, writeln, filecopy, eof
Summary of Contents for UbiQ
Page 1: ...User Manual UbiQ Scenario Manager User Manual V1 03...
Page 4: ...UbiQ Scenario Manager User Manual iv...
Page 7: ...Chapter 1 1 Introduction...
Page 13: ...Chapter 2 2 Getting Started...
Page 37: ...Chapter 3 3 Tutorials...
Page 47: ...Chapter 4 4 Basic of Smart C Script Language...
Page 62: ...UbiQ Scenario Manager User Manual 56...