f_saveblobtofile_rpt.srf 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $PBExportHeader$f_saveblobtofile_rpt.srf
  2. global type f_saveblobtofile_rpt from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_saveblobtofile_rpt (blob arg_bdata, string arg_filename, ref string arg_msg)
  6. end prototypes
  7. global function integer f_saveblobtofile_rpt (blob arg_bdata, string arg_filename, ref string arg_msg);//f_saveblobtofile
  8. long rslt=1
  9. long fend,li_FileNum,fend_t,ls_i,ls_jh
  10. blob b_dtdata_p
  11. //if len(b_dtdata)32765
  12. fend=len(arg_bdata)
  13. if fend<=32765 then
  14. fend_t=1
  15. else
  16. fend_t=fend/32765
  17. if mod(fend,32765)<>0 then
  18. fend_t=fend_t+1
  19. end if
  20. end if
  21. li_FileNum = FileOpen( arg_filename,StreamMode!, Write!, LockWrite!)
  22. if li_FileNum<=0 then
  23. arg_msg="打开文件"+arg_filename+"失败"
  24. rslt=0
  25. fileclose(li_FileNum)
  26. goto ext
  27. end if
  28. for ls_i = 1 to fend_t
  29. b_dtdata_p=blobmid(arg_bdata,1+(ls_i - 1 )*32765,32765)
  30. ls_jh=FileWrite(li_FileNum, b_dtdata_p)
  31. if ls_jh<=0 then
  32. arg_msg="写文件"+arg_filename+"失败"
  33. rslt=0
  34. fileclose(li_FileNum)
  35. goto ext
  36. end if
  37. next
  38. fileclose(li_FileNum)
  39. ext:
  40. return rslt
  41. end function