FileRead

 

int FileRead(int handle, string buf, int size);

int FileRead(int handle, string buf, int size, int encoding);  - 10.3.6.24 버전 이상에서 지원

 

파일에서 지정한 size만큼을 읽어서 buf에 담는 함수이다.

 

함수인자

handle - FileOpen 함수를 사용하여 얻은 파일 인식 ID

buf - 파일에서 읽어와서 담을 메모리

size - 파일에서 읽어올 크기

encoding - 0 : ANSI(시스템 기본설정), 1 : UTF-8 형식

 

return 값

읽기가 성공적으로 끝나면 return값은 읽은 크기 만큼이 돌아온다.

 

 

예제1)

handle  = @FileOpen("C:\\EX.TXT", "r");

if(handle != 0) {

@FileRead(handle, buf, 14);

@FileClose(handle);

}

 

문장설명 : C:\\EX.TXT 파일을 열어서 buf에 14개의 데이터를 읽어온 뒤 파일을 닫는다.

 

예제2)

filepath = "C:\\AutoBase\\Project\\ApiClientTest\\RESTAPIClient\\태양열_log.txt";
size = @FileGetSize(filepath);
handle = @FileOpen(filepath, "r"); //읽기전용으로 열기
if(handle != 0) {
@FileRead(handle, buf, size, 1); // UTF-8 형식으로 읽기
@FileClose(handle);
}
$ST_buf = buf;


문장설명 : 태양열_log.txt 파일을 열어서 UTF-8 형식으로 읽은 후 buf에 저장하고 $ST_buf 문자열 태그에 저장한다.

 

관련 항목)

@FileClose()

@FileCompare()

@FileCopy()

@FileDelete()

@FileExists()

@FileGetSize()

@FileGetTime()

@FileNameSplit()

@FileMove()

@FileOpen()

@FileOpenLPT()

@FileRead()

@FileWrite()

@FileSeek()