f_saveblobtofile.srf 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $PBExportHeader$f_saveblobtofile.srf
  2. global type f_saveblobtofile from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_saveblobtofile (blob arg_bdata, string arg_filename, ref string arg_msg)
  6. end prototypes
  7. global function integer f_saveblobtofile (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 = lena(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