replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Problem with TRIM
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 

Problem with TRIM

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



Joined: 22 Mar 2009
Posts: 14

PostPosted: Tue Oct 23, 2012 4:37 pm    Post subject: Problem with TRIM Reply with quote

I didn't have this problem in 2009 but now -

CHARACTER*8 STRINGS(3)
STRINGS=(/'Longer ','Short ','Longest '/)
STRINGS=TRIM(STRINGS)
PRINT '(/(A8))',STRINGS
END

doesn't work properly. OK if longest first, otherwise not.
Truncation is determined by the first string.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8208
Location: Salford, UK

PostPosted: Tue Oct 23, 2012 5:45 pm    Post subject: Reply with quote

This should fail to compile because TRIM is not "elemental".

You could use...

Code:
CHARACTER*8 STRINGS(3)
STRINGS=(/'Longer  ','Short   ','Longest '/)
do i=1,3
  STRINGS(i)=TRIM(STRINGS(i))
enddo 
PRINT '(/(A8))',STRINGS
END
Back to top
View user's profile Send private message AIM Address
skeptic



Joined: 22 Mar 2009
Posts: 14

PostPosted: Tue Oct 23, 2012 7:25 pm    Post subject: Problem with TRIM Reply with quote

PRINT *,TRIM(STRINGS) fails to compile

but STRINGS=TRIM(STRINGS) compiles OK
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1899

PostPosted: Tue Oct 23, 2012 11:13 pm    Post subject: Re: Problem with TRIM Reply with quote

skeptic wrote:
... STRINGS=TRIM(STRINGS) compiles OK


It may compile, but the assignment, as well as the assignment STRINGS(i)=TRIM(STRINGS(i)) in a DO loop, does nothing useful. The expression on the right of the assignment is a trimmed string. However, when a string expression is assigned to a variable, the expression is truncated or padded up with blanks to match the length of the CHARACTER variable.

Try
Code:
PRINT '(/(1h|,A,1h|))',(TRIM(STRINGS(i)),i=1,3)
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8208
Location: Salford, UK

PostPosted: Wed Oct 24, 2012 8:07 am    Post subject: Reply with quote

Good point.

The original code does indeed compile under FTN95 but this reflects a bug in FTN95. It should produce a compilation error report.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8208
Location: Salford, UK

PostPosted: Wed Mar 27, 2013 6:07 pm    Post subject: Reply with quote

I have fixed this bug for the next release (after 6.35).
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support 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