CompileEntryImport怎样导入大于32k的对象

zysea 2011-11-09 03:24:03
int PBORCA_CompileEntryImport ( PBORCA hORCASession, LPSTR lpszLibraryName, LPSTR lpszEntryName, PBORCA_TYPE otEntryType, LPSTR lpszComments, LPSTR lpszEntrySyntax, LONG lEntrySyntaxBuffSize, PBORCA_ERRPROC pCompErrorProc, LPVOID pUserData ) ;
CompileEntryImport无法导入大于32k的对象,将lpszEntrySyntax声明为blob型也不行,函数返回值为0,但pbl中找不到对象,小于32k的对象就没有问题,请问高手该怎样处理?
...全文
230 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zysea 2011-11-10
  • 打赏
  • 举报
回复
读肯定没有文题,这是PB的help里的example里的代码,并且我还测试过将读出的lb_syntax再写入另一文件,结果是和源文件一致的,这个语句:messagebox('',string(len(lb_syntax)))执行也是显示的大于32765的数字
yyoinge 2011-11-09
  • 打赏
  • 举报
回复
读文件内容的方法参照这个试试:
PB9读写大容量文件的方法
http://blog.csdn.net/yyoinge/article/details/6935768

可能是你读文件时有问题,没有完全读入文件,只读了32765 byte
zysea 2011-11-09
  • 打赏
  • 举报
回复
pb自带的import可成功导入。我的代码如下:
声明:
public function long sessionopen () library "PBORC90.DLL" alias for "PBORCA_SessionOpen"
public subroutine sessionclose (long horcasession) library "PBORC90.DLL" alias for "PBORCA_SessionClose"
public function integer sessionsetlibrarylist (long horcasession,ref string plibnames[],integer inumberoflibs) library "PBORC90.DLL" alias for "PBORCA_SessionSetLibraryList"
public function integer sessionsetcurrentappl (long horcasession,string lpszappllibname,string lpszapplname) library "PBORC90.DLL" alias for "PBORCA_SessionSetCurrentAppl"
public function integer libraryentryexport (long horcasession,string lpszlibraryname,string lpszentryname,long otentrytype,ref string lpszexportbuffer,long lexportbuffersize) library "PBORC90.DLL" alias for "PBORCA_LibraryEntryExport"
public function integer compileentryimport (long horcasession,string lpszlibraryname,string lpszentryname,long otentrytype,string lpszcomments,blob lpszentrysyntax,long lentrysyntaxbuffsize,long pcomperrorproc,long puserdata) library "PBORC90.DLL" alias for "PBORCA_CompileEntryImport"

导入函数of_importfile:
long li_handle
long ll_sid
long ll_index
integer li_result


ll_sid=sessionopen()
li_result = sessionsetlibrarylist(ll_sid,as_library,upperbound(as_library))

if li_result = 0 then
li_result = sessionsetcurrentappl(ll_sid,as_library[1],as_appl)

if li_result = 0 then
li_result = compileentryimport(ll_sid,as_pbl,as_object,al_type,"Messagebox->gf_msgbox",ab_syntax,len(ab_syntax),0,0)

if li_result <> 0 then
li_handle = fileopen("status.txt",linemode!,write!,lockwrite!,append!)
filewrite(li_handle,string(li_result) + " - " + as_pbl + " - " + as_object+'(compileentryimport)')
fileclose(li_handle)
else
li_handle = fileopen("status.txt",linemode!,write!,lockwrite!,append!)
filewrite(li_handle,string(li_result) + " - " + as_pbl + " - " + as_object+'(compileentryimport)')
fileclose(li_handle)
end if

else
li_handle = fileopen("status.txt",linemode!,write!,lockwrite!,append!)
filewrite(li_handle,string(li_result) + " - " + as_pbl + " - " + as_object+'(sessionsetcurrentappl)')
fileclose(li_handle)
end if

else
li_handle = fileopen("status.txt",linemode!,write!,lockwrite!,append!)
filewrite(li_handle,string(li_result) + " - " + as_pbl + " - " + as_object+'(sessionsetlibrarylist)')
fileclose(li_handle)
end if

sessionclose(ll_sid)
return li_result

调用倒入函数的代码:
integer li_handle,li_ret,li_i,li_j,li_EntryType,li_loops
string ls_dir,ls_filename,ls_fileext,ls_targetpbl
string ls_library[]
long ll_filelen
blob lb_1,lb_syntax
ls_dir=sle_sourcedir.text
ls_library[1]=sle_targetpbl.text
SetPointer(HourGlass!)
for li_i=1 to lb_sourcefilelist.totalitems()
ls_filename=lower(left(lb_sourcefilelist.text(li_i),len(lb_sourcefilelist.text(li_i))-4))
ls_fileext=lower(right(lb_sourcefilelist.text(li_i),3))
choose case ls_fileext
case 'sra'
li_EntryType=0
case 'srd'
li_EntryType=1
case 'srf'
li_EntryType=2
case 'srm'
li_EntryType=3
case 'srq'
li_EntryType=4
case 'srs'
li_EntryType=5
case 'sru'
li_EntryType=6
case 'srw'
li_EntryType=7
case else
continue
end choose
ls_targetpbl=sle_targetpbl.text
if lower(right(ls_targetpbl,4))<>'.pbl' then
ls_targetpbl=ls_targetpbl+'.pbl'
end if



// Get the file length, and open the file
ll_filelen = FileLength(ls_filename+"."+ls_fileext)
li_handle = fileopen(ls_filename+"."+ls_fileext,StreamMode!,Read!,LockRead!)
// Determine how many times to call FileRead
if ll_filelen > 32765 then
if Mod(ll_filelen, 32765) = 0 then
li_loops = ll_filelen/32765
else
li_loops = (ll_filelen/32765) + 1
end if
else
li_loops = 1
end if
// Read the file
for li_j = 1 to li_loops
FileRead(li_handle,lb_1)
lb_syntax = lb_syntax+lb_1
next
li_ret=fileclose(li_handle)

//messagebox('',string(len(lb_syntax)))
in_cst_pborc.of_importfile(lb_syntax,ls_filename,li_EntryType,ls_targetpbl,ls_library[],'aa')
next
messagebox('确定','对象导入成功!',information!)
yyoinge 2011-11-09
  • 打赏
  • 举报
回复
测试过,可以导入超过32K的,你先试试该对象通过pb自带的import功能可否导入

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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