12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- $PBExportHeader$f_stringtofile.srf
- global type f_stringtofile from function_object
- end type
- forward prototypes
- global function integer f_stringtofile (string arg_filepathname, string arg_stringdata, ref string arg_msg)
- end prototypes
- global function integer f_stringtofile (string arg_filepathname, string arg_stringdata, ref string arg_msg);long rslt=1,fend,fend_t
- string ls_dtdata, ls_dtdata_p
- long li_FileNum,ls_i,ls_jh
- string tmpfilepathname
- tmpfilepathname=arg_filepathname
- ls_dtdata=arg_stringdata
- fend=len(ls_dtdata)
- if fend<=32765 then
- fend_t=1
- else
- fend_t=fend/32765
- if mod(fend,32765)<>0 then
- fend_t=fend_t+1
- end if
- end if
- li_FileNum = FileOpen( tmpfilepathname,TextMode!, Write!, LockWrite!, Append!,EncodingUTF16LE!)
- if li_FileNum<=0 then
- arg_msg="打开文件"+tmpfilepathname+"失败"
- rslt=0
- fileclose(li_FileNum)
- goto ext
- end if
- for ls_i = 1 to fend_t
- ls_dtdata_p=mid(ls_dtdata,1+(ls_i - 1 )*32765,32765)
- ls_jh=FileWriteEx(li_FileNum, ls_dtdata_p)
- if ls_jh<=0 then
- arg_msg="写文件"+tmpfilepathname+"失败"
- rslt=0
- fileclose(li_FileNum)
- goto ext
- end if
- next
- fileclose(li_FileNum)
- ext:
- return rslt
- end function
|