- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I quite often use the trim() function when concatenating string together so that spacing can be controlled (used often for creation filenames for example) however I noticed that if the variable being trimmed is blank none of the strings following are added to the string. Is this expected?
eg
character*20 :: var1,var2,var3
character*132 :: string
var1 = '250.0'
var2 = 'millimetres'
var3 = 'tagline'
string = trim(var1)//' '//trim(var2)//' '//trim(var3)
string would be '250.0 millimetres tagline'
however if:
var2 = ' '
string would be just '250.0'
where I would expect '250.0 tagline'
I've only noticed this recently so may have been introduced in one of the later XE compiler updates.
eg
character*20 :: var1,var2,var3
character*132 :: string
var1 = '250.0'
var2 = 'millimetres'
var3 = 'tagline'
string = trim(var1)//' '//trim(var2)//' '//trim(var3)
string would be '250.0 millimetres tagline'
however if:
var2 = ' '
string would be just '250.0'
where I would expect '250.0 tagline'
I've only noticed this recently so may have been introduced in one of the later XE compiler updates.
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
4 Respuestas
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Please report the specific compiler version which exhibits this behavior. Version 12.1.0.233 (32-bit and 64-bit) on Windows prints:
250.0 tagline
250.0 tagline
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
I get:
250.0 tagline
in Update 9 (12.1.330)
Please show a complete program that demonstrates the problem and a command prompt log showing the build and run with the bad results.
250.0 tagline
in Update 9 (12.1.330)
Please show a complete program that demonstrates the problem and a command prompt log showing the build and run with the bad results.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Hi Steve,
I'm running on Update 9 (12.1.330).
After some investigation the problem I flagged up occurs when thevar2 substring has not been initialised at all. This is down to bad programming practice on my part so apologies for that. However I would be interested to know if the behavoir of the function is as expected.
I know that len_trim() function does not like C strings with trailing char(0)/ Should these founctions still work even if they containare NULL characters using the first encountered NULL as the end of the string?
Thanks for your quick response.
I'm running on Update 9 (12.1.330).
After some investigation the problem I flagged up occurs when thevar2 substring has not been initialised at all. This is down to bad programming practice on my part so apologies for that. However I would be interested to know if the behavoir of the function is as expected.
I know that len_trim() function does not like C strings with trailing char(0)/ Should these founctions still work even if they containare NULL characters using the first encountered NULL as the end of the string?
Thanks for your quick response.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
TRIM and LEN_TRIM remove blanks only - not other characters. the NUL character has no special meaning in Fortran.
Responder
Opciones de temas
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla