Join a list of strings into a comma-separated value string.
Empty entries are skipped. If all entries are empty (or the array is not
allocated), returns the provided empty placeholder string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(string_t), | intent(in), | allocatable | :: | a(:) | ||
| character(len=*), | intent(in) | :: | empty |
pure function join_csv(a, empty) result(s) type(string_t), allocatable, intent(in) :: a(:) character(len=*), intent(in) :: empty character(len=:), allocatable :: s character(len=:), allocatable :: tmp integer :: i tmp = "" if (allocated(a)) then do i = 1, size(a) if (len_trim(a(i)%s) == 0) cycle if (len(tmp) > 0) tmp = tmp // "," tmp = tmp // trim(a(i)%s) end do end if if (len(tmp) == 0) then s = empty else s = tmp end if end function join_csv