tokens Subroutine

subroutine tokens(s, t0, t1, t2, t3)

Split line into up to four whitespace-separated tokens.

Missing tokens blank, tokens past fourth dropped.

Arguments

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

Input line.

character(len=*), intent(out) :: t0

First token (command).

character(len=*), intent(out) :: t1

Second token.

character(len=*), intent(out) :: t2

Third token.

character(len=*), intent(out) :: t3

Fourth token.


Source Code

   subroutine tokens(s, t0, t1, t2, t3)
      !! Split line into up to four whitespace-separated tokens.
      !!
      !! Missing tokens blank, tokens past fourth dropped.
      ! Arguments
      character(len=*), intent(in)  :: s
         !! Input line.
      character(len=*), intent(out) :: t0
         !! First token (command).
      character(len=*), intent(out) :: t1
         !! Second token.
      character(len=*), intent(out) :: t2
         !! Third token.
      character(len=*), intent(out) :: t3
         !! Fourth token.
      character(len=len(s)) :: buf
      t0 = ''; t1 = ''; t2 = ''; t3 = ''
      buf = adjustl(s)
      call pop(buf, t0)
      call pop(buf, t1)
      call pop(buf, t2)
      call pop(buf, t3)
   end subroutine tokens