View previous topic :: View next topic |
Author |
Message |
BK
Joined: 07 May 2020 Posts: 14
|
Posted: Tue Jul 07, 2020 9:10 pm Post subject: string handling functions |
|
|
I've been trying to convert integer data to strings without success. Silverfrost apparently doesn't have string handling functions, so I've been trying to use writing to an internal file as shown in the FORTRAN 95 manual. As an example, my write is as follows
write(unit=str1,fmt='(A2)') Idat
Is there another way to do this conversion? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1892
|
Posted: Tue Jul 07, 2020 9:50 pm Post subject: |
|
|
The format for printing out 2-byte integers as decimal strings is I6, not A2. |
|
Back to top |
|
|
Robert
Joined: 29 Nov 2006 Posts: 448 Location: Manchester
|
Posted: Tue Jul 07, 2020 10:58 pm Post subject: |
|
|
Which string handling functions don't exist? |
|
Back to top |
|
|
BK
Joined: 07 May 2020 Posts: 14
|
Posted: Wed Jul 08, 2020 2:33 pm Post subject: |
|
|
Thanks mecej4. The "I" format worked.
Robert, string handling functions that directly do conversions between numeric and string (e.g., int to str and str to int) aren't available. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1892
|
Posted: Wed Jul 08, 2020 3:31 pm Post subject: Re: |
|
|
BK wrote: | .. string handling functions that directly do conversions between numeric and string (e.g., int to str and str to int) aren't available. |
In Fortran strings processing is done differently than in C and its relatives.
In fact, Fortran has character variables of various fixed lengths (and, in very few compilers, kinds), and a small set of features for processing strings is built into the language. Such processing does not need to use functions such as atoi and itoa, as in C. |
|
Back to top |
|
|
Robert
Joined: 29 Nov 2006 Posts: 448 Location: Manchester
|
|
Back to top |
|
|
|