Silverfrost Forums

Welcome to our forums

trim(string) does not work

27 Apr 2023 8:57 #30234

trim(string) → the compiler does not recognise the statement. If someone does get it to work, please post an example. I could not find anything on the Internet that might point out why compiling the statement produced an error.

27 Apr 2023 11:32 #30236
program trim_string_works
character(len=30) name
name = 'Casper the Jack Russell       '
write(6,*)      len(name)
write(6,*)      len(trim(name))
write(6,'(A)') '123456789012345678901234567890'
write(6,'(2A)') name,'X'
write(6,'(2A)') trim(name),'X'
end program trim_string_works 
28 Apr 2023 10:53 #30239

A better example:

program trim_string_works
character(len=30) name, breed
name = 'Casper       '
breed = 'Jack Russell terrier'
write(6,'(A,1X,A,1X,A)') name, 'is a', breed
write(6,*)
write(6,'(A,1X,A,1X,A)') trim(name), 'is a', breed
end program trim_string_works


Casper                         is a Jack Russell terrier

Casper is a Jack Russell terrier

Press RETURN to close window...
28 Apr 2023 12:20 #30241

Thank you for your very explanatory response to my query! Patrick

Please login to reply.