[Thread Prev][Thread Next][Index]

Re: [ferret_users] string composition



Here's another workaround that avoids the immediate-mode (backquote) evaluation, so that the final result will update if the units change later:

  NOAA/PMEL TMAP
  FERRET v7.52 (optimized)
  Linux 2.6.32-754.23.1.el6.x86_64 64-bit - 12/03/19
  19-Feb-20 13:09    

yes? let/units="m/s" v1 = 1.1
yes? let/units="mmol C m-3" v2 = 2.2
yes? let v1_units = v1.units; let v2_units = v2.units
yes? list/nohead v1_units + v2_units
        "m/smmol C m-3"

Andrew


On Wed, Feb 19, 2020 at 12:45 PM Ansley C. Manke <ansley.b.manke@xxxxxxxx> wrote:
I agree this seems like a bug, and I'll have a look at this. Addition of
strings is one way to work with them, but for combining two strings, the
STRCAT function is the most reliable:


yes? list/nohead strcat(v1.units, v2.units)
         "m/smmol C m-3"

A variation on your last command could be this, creating a single string.

yes? list/nohead "`v1.units` + `v2.units`"
         "m/s + mmol C m-3"


On 2/19/2020 1:15 AM, Marco van Hulten wrote:
> Hi Ferreters—
>
> When I was composing unit strings from a product of variables, I found
> an unexpected behaviour:
>
> yes? let/units="m/s" v1 = 1.1
> yes? let/units="mmol C m-3" v2 = 2.2
> yes? list/nohead v1.units + "XYZ"
>          "m/sXYZ"
> yes? list/nohead v1.units + v2.units
>          "m/sm/s"
> yes? list/nohead "`v1.units`" + "`v2.units`"
>          "m/smmol C m-3"
>
> I expected that the result of the panultimate command would be the same
> as that of the last command.
>
> (The last command can be used as a solution or workaround to this issue.)
>
> —Marco
>

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement