12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- $PBExportHeader$f_getblobfromfile_rpt.srf
- global type f_getblobfromfile_rpt from function_object
- end type
- forward prototypes
- global function integer f_getblobfromfile_rpt (ref blob arg_bdata, string arg_filename, ref string arg_msg)
- end prototypes
- global function integer f_getblobfromfile_rpt (ref blob arg_bdata, string arg_filename, ref string arg_msg);//f_getblobfromfile
- long rslt=1
- long flen,li_FileNum,loops,ls_i,bytes_read,new_pos
- blob b_dtdata_p,tot_b
- SetPointer(HourGlass!)
- // Get the file length, and open the file
- flen = FileLength(arg_filename)
- li_FileNum = FileOpen(arg_filename, StreamMode!, Read!, LockRead!)
- if li_FileNum=-1 then
- rslt=0
- arg_msg='打开文件'+arg_filename+'操作失败!'
- fileclose(li_FileNum)
- goto ext
- end if
- // Determine how many times to call FileRead
- IF flen > 32765 THEN
- IF Mod(flen, 32765) = 0 THEN
- loops = flen/32765
- ELSE
- loops = (flen/32765) + 1
- END IF
- ELSE
- loops = 1
- END IF
- // Read the file
- new_pos = 1
- FOR ls_i = 1 to loops
- bytes_read = FileRead(li_FileNum, b_dtdata_p)
- if bytes_read=0 then
- rslt=0
- arg_msg='读取文件'+arg_filename+'操作失败!'
- fileclose(li_FileNum)
- goto ext
- end if
- tot_b = tot_b + b_dtdata_p
- NEXT
- arg_bdata=tot_b
- fileclose(li_FileNum)
- ext:
- return rslt
- end function
|