帮我解释下面这段PB代码,越详细越好,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/04 21:53:38
string str_docname,str_name,str_text
integer i,i_value,i_filenum,i_loops
long l_flength,l_bytes_read
i_value=getfileopenname("选择要打开的文件",str_docname,str_name,"txt","文本文件(*.txt),*.txt,所有文件(*.*),*.*")
//返回值为1是正确获取文件及路径!str_docname存放路径,str_name存放文件名
if i_value=1 then
l_flength=filelength(str_docname)//取文件长度字节数
i_filenum=fileopen(str_docname,streammode!)
if l_flength>32765 then
if mod(l_flength,32765)=0 then
i_loops=l_flength/32765
else
i_loops=(l_flength/32765)+1
end if
else
i_loops=1
end if
//读取文件内容到多行编辑框中
w_sdi.mle_1.text=""
for i=1 to i_loops
l_bytes_read=fileread(i_filenum,str_text)
w_sdi.mle_1.text=w_sdi.mle_1.text+str_text
next
fileclose(i_filenum)
str_current_filename=str_docname
w_sdi.title="编辑文件-"+str_current_filename
end if

代码大致是这样情况:
先声明变量
读取文件
把文件内容按32765字节一行判断文件需要占几行(就是为了得到i_loops的值)

后半部分:
清空文本框
把文件逐行写入文本框(个人觉得这里有点问题)
最后修改title等属性