of_FileWrite


pfcapsrv.pbl   >   pfc_n_cst_filesrv   >   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,blob,boolean)

Name Datatype
No Data

Name Datatype
lblb_Data blob
li_Cnt integer
li_FileNo integer
li_Writes integer
ll_BlobLen long
ll_CurrentPos long
lwm_Mode writemode

public function integer of_FileWrite (string as_FileName, blob ablb_Data, boolean ab_Append);//////////////////////////////////////////////////////////////////////////////
//	Public Function:  of_FileWrite
//	Arguments:		as_FileName				The name of the file to write to.
//						ablb_Data				The data 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 from a blob, and close a file.  Handles blobs > 32,765 bytes.
//////////////////////////////////////////////////////////////////////////////
//	Rev. History:	Version
//						5.0   Initial version
//////////////////////////////////////////////////////////////////////////////
//	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_BlobLen, ll_CurrentPos
blob lblb_Data
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_BlobLen = Len(ablb_Data)

// Determine the number of writes required to write the entire blob
If ll_BlobLen > 32765 Then
	If Mod(ll_BlobLen, 32765) = 0 Then
		li_Writes = ll_BlobLen / 32765
	Else
		li_Writes = (ll_BlobLen / 32765) + 1
	End if
Else
	li_Writes = 1
End if

ll_CurrentPos = 1

For li_Cnt = 1 To li_Writes
	lblb_Data = BlobMid(ablb_Data, ll_CurrentPos, 32765)
	ll_CurrentPos += 32765
	If FileWrite(li_FileNo, lblb_Data) = -1 Then
		Return -1
	End if
Next

FileClose(li_FileNo)

Return 1
end function

     
Name Owner
pfc_n_cst_inifile.of_delete pfc_n_cst_inifile
pfc_n_cst_inifile.of_delete pfc_n_cst_inifile
pfc_n_cst_filesrv.of_FileCopy pfc_n_cst_filesrv
pfc_n_cst_filesrv.of_FileWrite pfc_n_cst_filesrv

     
Name Owner
systemfunctions.blobmid systemfunctions
systemfunctions.fileclose systemfunctions
systemfunctions.fileopen systemfunctions
systemfunctions.filewrite systemfunctions
systemfunctions.len systemfunctions
systemfunctions.mod systemfunctions

     
Full name
No Data

     
Name Scope
No Data