GetField
This routine returns the field from the string.
Interface
- ܀ Interface
- ️܀ Example 1
- ️܀ Example 2
- ↢
INTERFACE
MODULE PURE SUBROUTINE getField(i, chars, field, ierr)
INTEGER(I4B), INTENT(IN) :: i
CHARACTER(*), INTENT(IN) :: chars
CHARACTER(:), ALLOCATABLE, INTENT(OUT) :: field
INTEGER(I4B), INTENT(OUT), OPTIONAL :: ierr
END SUBROUTINE getField
END INTERFACE
program main
use easifemBase
implicit none
CHARACTER( LEN = 100 ) :: astr
CHARACTER( LEN = : ), allocatable :: afield
INTEGER( I4B ):: ierr, ii
astr = "Hello world, how are you"
DO ii = 1, 5
CALL getField(i=ii, chars=astr, field=afield, ierr=ierr )
CALL Display(afield, "afield(" // tostring(ii) // ") = " )
END DO
end program main
results
afield(1) =Hello
afield(2) =world
afield(3) =how
afield(4) =are
afield(5) =you
program main
use easifemBase
implicit none
CHARACTER( LEN = 100 ) :: astr
CHARACTER( LEN = : ), allocatable :: afield
INTEGER( I4B ):: ierr, ii
astr = "Hello/ world/ how/ are/ you"
DO ii = 1, 5
CALL getField(i=ii, chars=astr, field=afield, ierr=ierr )
CALL Display(afield, "afield(" // tostring(ii) // ") = " )
END DO
end program main
Results
afield(1) =Hello/
afield(2) =world/
afield(3) =how/
afield(4) =are/
afield(5) =you