|
of_filewrite
|
|
Full name
|
pfc_n_cst_filesrv.of_filewrite
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_filewrite(string,string,boolean)
|
Name
|
Datatype
|
li_cnt
|
integer
|
li_FileNo
|
integer
|
li_writes
|
integer
|
ll_currentpos
|
long
|
ll_StrLen
|
long
|
ls_Text
|
string
|
lwm_Mode
|
writemode
|
public function integer of_filewrite (string as_filename, string as_text, boolean ab_append);//////////////////////////////////////////////////////////////////////////////
// Public Function: of_FileWrite
// Arguments: as_FileName The name of the file to write to.
// as_Text The text to be written to the file.
// ab_Append True - append to the end of the file,
// False - overwrite the existing file.
// Returns: Integer
// 1 if successful, -1 if an error occurrs.
// Description: Open, write to, and close a file. Handles strings > 32,765 bytes.
//////////////////////////////////////////////////////////////////////////////
// Rev. History: Version
// 5.0 Initial version
// 6.0.01 Rewrite to handle strings > 60k making more than 2 passes (for 32 bit platforms)
//////////////////////////////////////////////////////////////////////////////
// Copyright © 1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved. Any distribution of the
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
integer li_FileNo, li_writes, li_cnt
long ll_StrLen, ll_currentpos
string ls_Text
writemode lwm_Mode
If ab_Append Then
lwm_Mode = Append!
Else
lwm_Mode = Replace!
End if
li_FileNo = FileOpen(as_FileName, StreamMode!, Write!, LockReadWrite!, lwm_Mode)
If li_FileNo < 0 Then Return -1
ll_StrLen = Len(as_Text)
// If the string is longer than 32765 bytes then it will require multiple writes to write it
If ll_StrLen > 32765 Then
If Mod(ll_StrLen, 32765) = 0 Then
li_Writes = ll_StrLen / 32765
Else
li_Writes = (ll_StrLen / 32765) + 1
End if
Else
li_Writes = 1
End if
ll_CurrentPos = 1
For li_Cnt = 1 To li_Writes
ls_Text = Mid(as_Text, ll_CurrentPos, 32765)
ll_CurrentPos += 32765
If FileWrite(li_FileNo, ls_Text) = -1 Then
Return -1
End if
Next
FileClose(li_FileNo)
Return 1
end function
Name
|
Owner
|
systemfunctions.fileclose |
systemfunctions
|
systemfunctions.fileopen |
systemfunctions
|
systemfunctions.filewrite |
systemfunctions
|
systemfunctions.len |
systemfunctions
|
systemfunctions.mid |
systemfunctions
|
systemfunctions.mod |
systemfunctions
|