get_val Function

public function get_val(buffer, fs) result(output)

Extract the section of buffer that occurs after the field separator fs

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: buffer

Input buffer

character(len=1), intent(in), optional :: fs

Field separator

Return Value character(len=:), allocatable

Extracted value


Source Code

  function get_val(buffer, fs) result(output)
    !! Extract the section of buffer that occurs after the field separator fs
    implicit none

    ! Arguments
    character(*), intent(in) :: buffer
    !! Input buffer
    character(1), intent(in), optional :: fs
    !! Field separator

    ! Local variables
    character(:), allocatable :: output
    !! Extracted value
    character(1) :: fs_
    !! Field separator

    fs_ = '='
    if(present(fs)) fs_ = fs

    output = trim(adjustl(buffer((scan(buffer, fs_) + 1):)))
  end function get_val