of_fileread


pfcapsrv.pbl   >   pfc_n_cst_filesrv   >   of_fileread   

Full name pfc_n_cst_filesrv.of_fileread
Access public
Extend of long
Return value long
Prototype public function long of_fileread(string,ref string[])

Name Datatype
No Data

Name Datatype
li_Cnt integer
li_FileNo integer
ll_FileLen long
ll_Reads long

public function long of_fileread (string as_filename, ref string as_text[]);//////////////////////////////////////////////////////////////////////////////
//	Public Function:  of_FileRead
//	Arguments:		as_FileName				The name of the file to read.
//						as_Text[]				An array of strings to hold the text from the file,
//													passed by reference.
//	Returns:			Long - The number of elements in as_Text, returns -1 if an error occurrs.
//	Description:	Open, read, and close a file.  Handles files > 32,765 bytes by reading
//						it into an array of strings.
//////////////////////////////////////////////////////////////////////////////
//	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_Cnt
long			ll_FileLen, ll_Reads

ll_FileLen = FileLength(as_FileName)

li_FileNo = FileOpen(as_FileName, StreamMode!, Read!)
If li_FileNo < 0 Then Return -1

// Determine the number of reads required to read the entire file
If ll_FileLen > 32765 Then
	If Mod(ll_FileLen, 32765) = 0 Then
		ll_Reads = ll_FileLen / 32765
	Else
		ll_Reads = (ll_FileLen / 32765) + 1
	End if
Else
	ll_Reads = 1
End if

For li_Cnt = 1 to ll_Reads
	If FileRead(li_FileNo, as_Text[li_Cnt]) = -1 Then
		Return -1
	End if
Next

FileClose(li_FileNo)

Return ll_Reads
end function

     
Name Owner
No Data

     
Name Owner
systemfunctions.fileclose systemfunctions
systemfunctions.filelength systemfunctions
systemfunctions.fileopen systemfunctions
systemfunctions.fileread systemfunctions
systemfunctions.mod systemfunctions

     
Full name
No Data

     
Name Scope
No Data