Re: How to convert integers to characters?
- From: Terry Duell <tduell@xxxxxxxxxxxx>
- Date: Sat, 29 Sep 2007 10:57:56 +1000
In message 29 Sep
hermitian <iamwuxin@xxxxxxxxx> wrote:
Is there any functions to convert integers to characters?[snip]
[snip]
Moreover, is there any other functions can reverse the conversion?
Have a look at these two functions. You should be able to do the reverse.
* atodbl: converts string to real*8 using internal file
function atodbl(str)
implicit none
c paramater declarations
include "misc.h"
c global declarations
character str*(*)
real*8 atodbl
c external declarations
integer*2 strlen
c local declarations
character cnvstr*(MAXSTRLEN),tmpstr*(MAXSTRLEN)
logical*1 nodp
integer*2 i,l
real*8 tmp
c begin
tmpstr = str
c.....check for decimal points
l = strlen(str)
i = 1
nodp = .true.
do while (i.le.l)
nodp = nodp.and.(str(i:i).ne.'.')
i = i + 1
enddo
if (nodp) then
write(cnvstr,CHRFMT) tmpstr(1:l)//'.'
else
write(cnvstr,CHRFMT) tmpstr
endif
read(cnvstr,DBLFMT) tmp
atodbl = tmp
return
end
* atoint: converts string to integer*2 using internal file
function atoint(str)
implicit none
c parameter declarations
include "misc.h"
c global declarations
character str*(*)
integer*2 atoint
c local declarations
character cnvstr*(MAXSTRLEN)
integer*2 tmp
c begin
write(cnvstr,CHRFMT) str
read(cnvstr,INTFMT) tmp
atoint = tmp
return
end
Hope this helps.
Cheers,
--
Regards,
Terry Duell
.
- Follow-Ups:
- Re: How to convert integers to characters?
- From: hermitian
- Re: How to convert integers to characters?
- References:
- How to convert integers to characters?
- From: hermitian
- How to convert integers to characters?
- Prev by Date: How to convert integers to characters?
- Next by Date: Re: Printing of Program Name ??
- Previous by thread: How to convert integers to characters?
- Next by thread: Re: How to convert integers to characters?
- Index(es):
Relevant Pages
|