WSJT-X/msgtrim.f90
Joe Taylor dd11b4ab98 Trim leading blanks and multiple blanks from Tx messages.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/map65@2452 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2011-09-29 16:18:26 +00:00

38 lines
664 B
Fortran

subroutine msgtrim(msg,msglen)
character*28 msg
! Remove leading blanks
do i=1,28
if(msg(1:1).ne.' ') go to 2
msg=msg(2:)
enddo
2 do i=28,1,-1
if(msg(i:i).ne.' ') go to 3
enddo
i=1
3 iz=i
! Collapse multiple blanks to one
ib2=index(msg,' ')
if(ib2.eq.0 .or. ib2.eq.iz+1) go to 10
msg=msg(:ib2-1)//msg(ib2+1:)
iz=iz-1
go to 2
! Convert letters to upper case
10 do i=1,22
if(msg(i:i).ge.'a' .and. msg(i:i).le.'z') &
msg(i:i)= char(ichar(msg(i:i))+ichar('A')-ichar('a'))
enddo
do i=28,1,-1
if(msg(i:i).ne.' ') go to 20
enddo
i=28
20 msglen=i
return
end subroutine msgtrim