forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

string handling functions

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
BK



Joined: 07 May 2020
Posts: 14

PostPosted: Tue Jul 07, 2020 9:10 pm    Post subject: string handling functions Reply with quote

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
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1420

PostPosted: Tue Jul 07, 2020 9:50 pm    Post subject: Reply with quote

The format for printing out 2-byte integers as decimal strings is I6, not A2.
Back to top
View user's profile Send private message
Robert



Joined: 29 Nov 2006
Posts: 346
Location: Manchester

PostPosted: Tue Jul 07, 2020 10:58 pm    Post subject: Reply with quote

Which string handling functions don't exist?
Back to top
View user's profile Send private message Visit poster's website
BK



Joined: 07 May 2020
Posts: 14

PostPosted: Wed Jul 08, 2020 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2178
Location: Yateley, Hants, UK

PostPosted: Wed Jul 08, 2020 3:00 pm    Post subject: Reply with quote

BK, that's a Whopper.

Where are such things available in Standard Fortran? What are the routine names where you used them before? You might be referring to MATLAB functions, and you can find a discussion here on how to get the equivalent in Fortran:

https://coderwall.com/p/dqwzea/str2num-and-num2str-functions-in-fortran

Or the routine SAYINT (see the manual https://www.silverfrost.com/manuals/77library.pdf )

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1420

PostPosted: Wed Jul 08, 2020 3:31 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
Robert



Joined: 29 Nov 2006
Posts: 346
Location: Manchester

PostPosted: Wed Jul 08, 2020 4:57 pm    Post subject: Reply with quote

There are a few: https://www.silverfrost.com/ftn95-help/char/idh_character_handling_routines.aspx
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group