add_option Subroutine

private pure subroutine add_option(self, error, section_name, option_name, val)

Add an option (with scalar value).

If the option already exists, its value is updated.

Arguments

TypeIntentOptionalAttributesName
class(file_ini), intent(inout) :: self

File data.

integer(kind=I4P), intent(out), optional :: error

Error code.

character, intent(in) :: section_name

Section name.

character, intent(in) :: option_name

Option name.

class(*), intent(in) :: val

Option value.


Contents

Source Code


Source Code

  pure subroutine add_option(self, error, section_name, option_name, val)
  !< Add an option (with scalar value).
  !<
  !< If the option already exists, its value is updated.
  class(file_ini),        intent(inout) :: self         !< File data.
  integer(I4P), optional, intent(out)   :: error        !< Error code.
  character(*),           intent(in)    :: section_name !< Section name.
  character(*),           intent(in)    :: option_name  !< Option name.
  class(*),               intent(in)    :: val          !< Option value.
  integer(I4P)                          :: errd         !< Error code.
  integer(I4P)                          :: s            !< Counter.

  errd = err_section_options
  call self%add(section_name=section_name, error=errd)
  if (errd==0) then
    do s=1, size(self%sections, dim=1)
      if (self%sections(s) == section_name) then
        call self%sections(s)%add(error=errd, option_name=option_name, val=val)
        exit
      endif
    enddo
  endif
  if (present(error)) error = errd
  endsubroutine add_option