Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(string), | intent(in) | :: | self | The string. |
||
integer, | intent(in) | :: | unit | Logical unit. |
||
character(len=*), | intent(in), | optional | :: | form | Format of unit. |
|
integer, | intent(out), | optional | :: | iostat | IO status code. |
|
character(len=*), | intent(inout), | optional | :: | iomsg | IO status message. |
Write lines (records) to a connected unit.
This method checks if self contains more than one line (records) and writes them as lines (records).
new_line()
character is added at the end (if necessary) to mark the end of line.Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(string), | public, | allocatable | :: | lines(:) | Lines. |
||
integer, | public | :: | l | Counter. |
subroutine write_lines(self, unit, form, iostat, iomsg)
!---------------------------------------------------------------------------------------------------------------------------------
!< Write lines (records) to a connected unit.
!<
!< This method checks if self contains more than one line (records) and writes them as lines (records).
!<
!< @note If the connected unit is unformatted a `new_line()` character is added at the end (if necessary) to mark the end of line.
!---------------------------------------------------------------------------------------------------------------------------------
class(string), intent(in) :: self !< The string.
integer, intent(in) :: unit !< Logical unit.
character(len=*), intent(in), optional :: form !< Format of unit.
integer, intent(out), optional :: iostat !< IO status code.
character(len=*), intent(inout), optional :: iomsg !< IO status message.
type(string), allocatable :: lines(:) !< Lines.
integer :: l !< Counter.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(self%raw)) then
call self%split(tokens=lines, sep=new_line('a'))
do l=1, size(lines, dim=1)
call lines(l)%write_line(unit=unit, form=form, iostat=iostat, iomsg=iomsg)
enddo
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine write_lines