of_getsections


pfcapsrv.pbl   >   pfc_n_cst_inifile   >   of_getsections   

Full name pfc_n_cst_inifile.of_getsections
Access public
Extend of integer
Return value integer
Prototype public function integer of_getsections(string,ref string[])

Name Datatype
No Data

Name Datatype
li_file integer
li_rc integer
li_section integer
ll_first long
ll_last long
ll_length long
ll_pos long
lnv_string n_cst_string
ls_line string
ls_section string
ls_sections string[]

public function integer of_getsections (string as_file, ref string as_sections[]);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  		of_GetSections
//
//	Access:  		public
//
//	Arguments:	
// as_file			The .ini file.
//	as_sections[]	An array of strings passed by reference.  This will store
//						the section names retrieved from the .INI file
//
//	Returns:			Integer
//						 #	the number of sections retrieved
//						-1	error
//						-2 if .INI file does not exist or has not been specified.
//
//	Description:  	Retrieves all sections from an .INI file
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
// 5.0.02 Initialize sections array to blanks at start of function
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1997 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.
//
//////////////////////////////////////////////////////////////////////////////

long			ll_length
integer		li_file
integer		li_rc
long			ll_pos
long			ll_first
long			ll_last
integer		li_section
string		ls_line
string		ls_section
string		ls_sections[]
n_cst_string lnv_string

SetPointer (Hourglass!)

// Determine if file exists
if not FileExists (as_file) then
	return -2
end if

// Open file
ll_length = FileLength (as_file)
li_file = FileOpen (as_file, LineMode!)
if li_file = -1 then	return -1

// reset the array coming in
as_sections = ls_sections
//////////////////////////////////////////////////////////////////////////////
// Retrieve all section names in the file
//////////////////////////////////////////////////////////////////////////////
do while li_rc >= 0
	li_rc = FileRead (li_file, ls_line)
	if li_rc = -1 then
		return li_rc
	elseif li_rc > 0 then
		ll_first = Pos (ls_line, "[")
		ll_last = Pos (ls_line, "]")
		if ll_first > 0 and ll_last > 0 then
			ls_line = lnv_string.of_LeftTrim (ls_line, true, true)
			if Left (ls_line, 1) = "[" then
				ll_pos = Pos (ls_line, "]")
				ls_section = Mid (ls_line, 2, ll_pos - 2)
				li_section++
				as_sections[li_section] = ls_section
			end if
		end if
	end if
loop 

// Close file and return
FileClose (li_file)
return li_section
end function

     
Name Owner
pfc_n_cst_winsrv_preference.of_restore pfc_n_cst_winsrv_preference

     
Name Owner
systemfunctions.fileclose systemfunctions
systemfunctions.fileexists systemfunctions
systemfunctions.filelength systemfunctions
systemfunctions.fileopen systemfunctions
systemfunctions.fileread systemfunctions
systemfunctions.left systemfunctions
systemfunctions.mid systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.setpointer systemfunctions
pfc_n_cst_string.of_lefttrim pfc_n_cst_string

     
Full name
No Data

     
Name Scope
No Data