Skip to content

Commit

Permalink
clip(3f) and msg(3f)
Browse files Browse the repository at this point in the history
+ clip can now use a specified set of characters to clip
+ msg has CSV option
  • Loading branch information
urbanjost committed Jul 14, 2024
1 parent 242e2eb commit 86a439d
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 17,466 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12,769 changes: 0 additions & 12,769 deletions bug.gfortran.f90

This file was deleted.

3 changes: 3 additions & 0 deletions example/demo_clip.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ program demo_clip
write(*,*) 'clipped string=[',clip(untrimmed),']'
! which is equivalent to
write(*,*) 'clipped string=[',trim(adjustl(untrimmed)),']'
write(*,*)'non-space:'
write(*,*) '['//clip('----single-character----',set='-')//']'
write(*,*) '['//clip(' ... . .multi-character . ...',set='. ')//']'
end program demo_clip
21 changes: 19 additions & 2 deletions example/demo_msg.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program demo_msg
use M_strings, only : msg
use M_strings, only : msg, quote
implicit none
character(len=:),allocatable :: pr
character(len=:),allocatable :: frmt
Expand All @@ -24,8 +24,25 @@ program demo_msg
frmt=msg('(*(i',int(log10(real(biggest)))+0,':,1x))',sep='')
write(*,*)'format=',frmt

! compound output
pr=msg(10,100.0,"string",(11.0,22.0),.false.)
write(*,'(a)')pr
! a separator and also use of quote(3f)
pr=msg(10,100.0,quote("string"),(11.0,22.0),.false.,sep=';')
write(*,'(a)')pr
! CSV mode
pr=msg(10,100.0,"string",(11.0,22.0),.false.,csv=.true.)
write(*,'(a)')pr
! everything a vector instead of a scalar
pr=msg([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.])
write(*,'(a)')pr
pr=msg([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.],sep='|')
write(*,'(a)')pr
pr=msg([10,20,30],["string"],[(11.0,22.0)],[.false.,.true.],csv=.true.)
write(*,'(a)')pr

! although it will often work, using msg(3f) in an I/O statement
! is not recommended
write(*,*)msg('program will now stop')
write(*,*)msg('program will now attempt to stop')

end program demo_msg
Loading

0 comments on commit 86a439d

Please sign in to comment.