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的物件就沒有問題,請問高手該怎樣處理?
uj5u.com熱心網友回復:
測驗過,可以匯入超過32K的,你先試試該物件通過pb自帶的import功能可否匯入uj5u.com熱心網友回復:
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!)
uj5u.com熱心網友回復:
讀檔案內容的方法參照這個試試:PB9讀寫大容量檔案的方法
http://blog.csdn.net/yyoinge/article/details/6935768
可能是你讀檔案時有問題,沒有完全讀入檔案,只讀了32765 byte
uj5u.com熱心網友回復:
讀肯定沒有文題,這是PB的help里的example里的代碼,并且我還測驗過將讀出的lb_syntax再寫入另一檔案,結果是和源檔案一致的,這個陳述句:messagebox('',string(len(lb_syntax)))執行也是顯示的大于32765的數字轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/73486.html
標籤:API 調用
上一篇:PB 測驗UDP埠是否被占用
