欢迎光临
我们一直在努力

CAPL —— file

 fileGetString

        用于按行读取文件中的字符串(读取到缓冲区中),会把行结束符/回车读取到缓冲区中;

long fileGetString (char buff[], long buffsize, dword fileHandle);

Parameter:

        buff,缓冲区; buffsize,字符串长度; fileHandle,句柄;

Return Values:

        错误返回0;否则返回1;

fileGetStringSZ

        用于按行读取文件中的字符串(读取到缓冲区中),不会把行结束符/回车读取到缓冲区中;

long fileGetStringSZ(char buff[], long buffsize, dword fileHandle);

Parameter:

        buff,缓冲区; buffsize,字符串长度; fileHandle,句柄;

Return Values:

        错误返回0;否则返回1;

openFileRead

        通过文件名读取文件;

dword openFileRead (char filename[], dword mode); // form 1
dword openFileRead (char filename[], dword mode, dword fileEncoding); // form 2

Parameter:

filename

filename

mode

0,open in text mode;1,open in binary mode;

fileEncoding

Identifier of the Microsoft code page that is used to encode the file.

Return Values:

         The return value is the file handle that must be used for read operations. If an error occurs, the return value is 0.

Example:

dword glbHandle;
char buffer[64];
long glbValue;

setFilePath("C:\\\\Users\\\\Desktop", 2);
glbHandle = OpenFileRead ("index.Txt",0);
if ( glbHandle!=0 )
{
// fileGetStringSZ, 不会把行结束符(10),回车(13)也输入到接收buffer内
while ( fileGetStringSZ(buffer,elcount(buffer), glbHandle)!=0 )
{write ("%s",buffer);};
glbValue = atol (buffer);
write ("Last value %d.",glbValue);
ileClose (glbHandle);
}
else
{
write ("File '.Txt' was not opened for read access.");
}

openFileWrite

Parameter:

Return values:

Example:

dword glbHandle;
char write_text[1000]="Btn;\\nValue:0;\\n;
long ret;
int i,j=0;

setFilePath("C:\\\\Users\\\\Desktop", 2); // 不可以直接设置C根目录,2,可读可写

glbHandle = openFileWrite ("index.txt",1); // 以ASCII打开,并且覆盖文件原有内容
if ( glbHandle!=0 )
{
ret = filePutString(write_text, strlen(write_text), glbHandle);
if(ret)
{
writeLineEx (mNewPage,1,"write ok.");
fileClose (glbHandle);
}
else
{writeLineEx (mNewPage,1,"write error.");}
}

赞(0)
未经允许不得转载:171主机测评 » CAPL —— file
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址