Re: add a0 format to language to print trimmed character variables



On Apr 29, 2:33 pm, Gary Scott <garylsc...@xxxxxxxxxxxxx> wrote:
Clive Page wrote:
In message <YrOdnaEiBo7Xk67bnZ2dnUVZ_tqnn...@xxxxxxxxxxx>, glen

Beliavsky wrote:

I wish there were an "a0" format for character variables, analogous to
i0 for integers, which would not print trailing spaces in character
variables.

I think that's an excellent suggestion - pity nobody thought of it in
time for F2003.

In order to be analogous to I0 though wouldn't it need to trim both
leading and trailing spaces? I don't think that would be the usual
desire though, but maybe you could specify '0a0' to trim leading and
trailing spaces.

ADJUSTL can be (and is) ELEMENTAL, unlike TRIM, because the LEN of the
RESULT is the same as that of the argument. Quoting the gfortran
documentation, "ADJUSTL(STR) will left adjust a string by removing
leading spaces. Spaces are inserted at the end of the string as
needed."

If a0 were in the language, one could just write

write (*,"(1000(1x,a0))") adjustl(char_vec)

to print an array of character variables with leading and trailing
spaces removed from character variables and one space inserted between
variables.

.



Relevant Pages

  • Re: Simple Select Query
    ... was able to Trim them all out after the Chrwas removed (what a BAD ... I have a few simple character strings that won't "Trim", ... No luck with trailing spaces - does not make sense. ...
    (microsoft.public.access.gettingstarted)
  • Re: MS Query Problem
    ... The field is a 20 character text string which represents an industry code, ... access & excel that are a problem. ... It would be a very unusual circumstance to keep trailing spaces. ...
    (microsoft.public.access.queries)
  • Re: How do you remove trailing spaces withour Trim function?
    ... Then type in the Charcharacter by: ... delimiter and see if that takes it out. ... How do you remove trailing spaces? ... I have tried using the Trim function to remove the trailing space, ...
    (microsoft.public.excel.misc)
  • Re: Need pkey data type of 32 < x < 64 bits size.
    ... binary types. ... Character types are for words, and trailing spaces don't ... matter, case and accents may or may not matter, and bytes that represent ...
    (microsoft.public.sqlserver.programming)
  • Re: add a0 format to language to print trimmed character variables
    ... which would not print trailing spaces in character ... Spaces are inserted at the end of the string as ...
    (comp.lang.fortran)