Silverfrost Forums

Welcome to our forums

string handling functions

7 Jul 2020 8:10 #25927

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?

7 Jul 2020 8:50 #25928

The format for printing out 2-byte integers as decimal strings is I6, not A2.

7 Jul 2020 9:58 #25929

Which string handling functions don't exist?

8 Jul 2020 1:33 #25936

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.

8 Jul 2020 2:00 #25937

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

8 Jul 2020 2:31 #25938

Quoted from BK .. 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.

8 Jul 2020 3:57 #25940

There are a few: https://www.silverfrost.com/ftn95-help/char/idh_character_handling_routines.aspx

Please login to reply.