请教个函数的含义

sunshineos 2010-12-12 09:18:08
不会PB,只知道文件是PB的这个函数生成的,麻烦大家解释下这个函数是如何生成文件的
我想用delphi读取该函数生成的文件可行么
public function long of_writefile (string as_filename, ref blob abl_data);
/*
returns : integer (-1=error, > =0 number of bytes written)
arg1 : string as_FileName (Filename of the file to write)
arg2 : ref blob abl_data (source data)

This function writes the contents of the abl_data blob to disk
with the specified filename.

Revision record
Date Author Modification
*/

SetPointer(HourGlass!)

long ll_file
long ll_written
long ll_tot
long ll_writ

/* Open or create the file in replace mode */

ll_file = fileopen(as_filename,streammode!,write!,lockwrite!,replace!)


if ll_File <= 0 then
messagebox( 'Error writing file ',as_filename)
return -1
end if

/* write the contents to that file */
ll_tot = len(abl_data)
do while true

ll_writ = filewrite(ll_file,blobmid(abl_data,ll_written+1) )
if ll_writ = 0 then exit
ll_written += ll_writ
if ll_Written > = ll_tot then exit

loop

fileclose(ll_file)

return ll_written
end function

...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuam 2010-12-13
  • 打赏
  • 举报
回复
直接用delphi的文件操作函数处理OK了,blob类型delphi有吧
hsfeng75 2010-12-13
  • 打赏
  • 举报
回复
pb里面用ref定义的参数相当于C中的传递地址的参数,也就是说这个参数的值发生改变,调用此函数的对应值参数的值也改变,别的跟值传递一样的。
你给出的PB代码,文件是通过流模式写入的,也就是说你直接用记事本打开可能是乱码的。
sunshineos 2010-12-12
  • 打赏
  • 举报
回复
我用delphi该如何读取这个文件啊
/* write the contents to that file */
ll_tot = len(abl_data)
do while true

ll_writ = filewrite(ll_file,blobmid(abl_data,ll_written+1) )
if ll_writ = 0 then exit
ll_written += ll_writ
if ll_Written > = ll_tot then exit

loop

这边看不懂额
还有 ref blob delphi没这种数据类型的

pb8 2010-12-12
  • 打赏
  • 举报
回复
它只是个封装好的文件操作函数,as_filename为文件名,abl_data为内容,如果是pb10以前的版本,是采用的ANSI字符集,如果是pb10及其以后的,是采用的UNICODE字符集;
具体的内容要看pb调用of_writefile的地方才知道存入的是什么
sunshineos 2010-12-12
  • 打赏
  • 举报
回复
这个文件是PB程序生成的,我找到这个程序的源码,但不会PB看不懂,我想用Delphi去读取这个生成的文件,但不知道这个文件是啥样,该怎么样的方式读取,直接打开是乱码额
pb8 2010-12-12
  • 打赏
  • 举报
回复
直接用delphi中的文件操作函数不是更好么,
如果说调用pb的,只能使用com方式或通过run之类的运行pb的exe,通过发送窗口消息之类的触发~~

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧