join_csv Function

public pure function join_csv(a, empty) result(s)

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.

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in), allocatable :: a(:)
character(len=*), intent(in) :: empty

Return Value character(len=:), allocatable


Called by

proc~~join_csv~~CalledByGraph proc~join_csv join_csv proc~active_features active_features proc~active_features->proc~join_csv proc~print_banner print_banner proc~print_banner->proc~active_features proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~print_banner proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~rebuild_watch_list proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~rebuild_watch_list proc~watcher_run watcher_t%watcher_run proc~watcher_run->proc~rebuild_watch_list proc~watcher_run->proc~handle_manifest_change

Source Code

   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