Return the index of the option (inside a section) matching the name(s) passed.
The matching index returned is the first found if back is not passed or if back=.false.. On the contrary the last found is returned if back=.true..
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(file_ini), | intent(in) | :: | self | File data. |
||
logical, | intent(in), | optional | :: | back | If back appears with the value true, the last matching index is returned. |
|
character, | intent(in) | :: | section_name | Section name. |
||
character, | intent(in) | :: | option_name | Option name. |
Index of searched section.
elemental function index_option(self, back, section_name, option_name) result(ind)
!< Return the index of the option (inside a section) matching the name(s) passed.
!<
!< @note The matching index returned is the first found if *back* is not passed or if *back=.false.*. On the contrary the last
!< found is returned if *back=.true.*.
class(file_ini), intent(in) :: self !< File data.
logical, optional, intent(in) :: back !< If back appears with the value true, the last matching index is returned.
character(*), intent(in) :: option_name !< Option name.
character(*), intent(in) :: section_name !< Section name.
integer(I4P) :: ind !< Index of searched section.
logical :: backd !< Dummy back flag.
integer(I4P) :: s !< Counter.
ind = 0
if (allocated(self%sections)) then
backd = .false. ; if (present(back)) backd = back
s = self%index(section_name=section_name, back=backd)
if (s>0) then
ind = self%sections(s)%index(option_name=option_name, back=backd)
endif
endif
endfunction index_option