[Thread Prev][Thread Next][Index]
Re: [ferret_users] trailing slash in symbol
- To: ferret_users@xxxxxxxx
- Subject: Re: [ferret_users] trailing slash in symbol
- From: "Ansley C. Manke" <ansley.b.manke@xxxxxxxx>
- Date: Tue, 23 Jun 2020 10:27:37 -0700
- Arc-authentication-results: i=2; mx.google.com; dkim=pass header.i=@noaa.gov header.s=google header.b=KC1TnBgZ; spf=pass (google.com: domain of ansley.b.manke@xxxxxxxx designates 209.85.220.41 as permitted sender) smtp.mailfrom=ansley.b.manke@xxxxxxxx; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=noaa.gov
- Arc-authentication-results: i=1; mx.google.com; dkim=pass header.i=@noaa.gov header.s=google header.b=KC1TnBgZ; spf=pass (google.com: domain of ansley.b.manke@xxxxxxxx designates 209.85.220.41 as permitted sender) smtp.mailfrom=ansley.b.manke@xxxxxxxx; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=noaa.gov
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-archive:list-help:list-post:list-id:mailing-list:precedence :content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :dkim-signature; bh=TzY5odBBoeWvVnkttjN5qhES1+s/4qRF6DP+oHTOUrU=; b=tPK0w6Z9oRMr5MOO+nN24TReSYYDzMSXXJeVpu9uTdgI2eC6LR6wtTzBuVmln9HpB+ gff20P9D+FutAQCTibnIh/LZEobZFwep7qr26akGafmV2m1ZgAnRnUAuaPWU4h/ROUtO XuWlP+GafKDuiYnGZ9NdfWrN/DXtXwlLxWi+pYAa3gcrBxOwzkXUADDbzCIhfzkrIbuv qD88Zs0OsRI4NV5NHtc5ouLXq80BcCwB+9wInRxfte+8PhpefMSfQ22TAgk72cQMEfKF 31FZnyZC4KRldUrT6saUQf2qwCZnY5Vuhy3nTfak8wT10VKwKxfDk1+LnwX6W+8pkH3b GR5w==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :dkim-signature; bh=TzY5odBBoeWvVnkttjN5qhES1+s/4qRF6DP+oHTOUrU=; b=zbQriWuRvIu/RbccEYJUhmlhG0snr0LNJz0Cq+ZEcoEvwuIrCci7XXCtYWpUMWsSyI wHFETGlMj90U7g9CE4MCLtYW7aIHa8JTr6igwGRZmfwTlf7A8BU/aBMXHUqPnZEbWdjr mtqVGxKehJ9X0FHE0Kj1eyyGWQQLz1a2jzMnY8SLCdWDolotsql6JQ+o6BZtOYvimjSL YscptBHK4mKn+H9D6zs/GXhSS/ezKosEfkRuA9X22a7web+cXYpB0jU8we0nDBZYLFV4 oK0bw1avkpn8bpuvdi9wfOfp6fIREysP8dxCs1bkGcDsNa1FlDu7nk3/xyGztArbob9G BoiA==
- Arc-seal: i=2; a=rsa-sha256; t=1592933264; cv=pass; d=google.com; s=arc-20160816; b=JiqdZJv5fOXVyAkFWOYBXADGzIozWau1UreMw6Zta1VY2jmoTRS7QJT6wt0qd7dILc OUHgFpoGV2Ck8oC0dUmQMot++fVkv4FFiuwUEgKYzvpL3ff9GW/85oqMTv7/F+2ryKNX I2Lq3/ftHNQ32QRHrVhDuMXfpjyPlXEbd1F6KFGWdPU/5TlJ5p5BQF0EvOTmLZeDm7Y5 H3Wxl5fOVpDBtnkj7gfU5D0U4zN0ONcWoC6Q6oV7jxApZhx5qVIurmtmSPsG6Bwyrydi VmdEZoEYryI+sAzFw/OwlEqRp/MTXZZ0rs7mN0m05MdT6sXkgDXO+6TLiFT8EQU5U0xf weew==
- Arc-seal: i=1; a=rsa-sha256; t=1592933260; cv=none; d=google.com; s=arc-20160816; b=V7N7A9ag11afMzqVKWgGArw/VDR2tUrrlrbdT5Ne/soGVe1qASjBQyYiypbtoGlMbP jsCXoshjnA7oUU7qsy5UBFbA0Svn1L8c+2M0I9PTPSJK9FTtl7VtPTqd1W1gpPIEYyBY hmWoloacZB5rbDDNc/4LQqUJ7ayQMQN690R4H9j87tUOyak7j4oBmft32yAk3oUmsgr5 va28L+py4EeA0NIEv8OI1PJJRyxlbYFNxweYswbYA83bAJS+EIkyae/zuTrcsWmjDCAJ zvD6brgkJn03iPHvtzOsE0V1Q3sBz/IQRD9geBA8z7hptVxIv4RR2iiAcqW/TRWyM//e EXHQ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=noaa.gov; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive; bh=TzY5odBBoeWvVnkttjN5qhES1+s/4qRF6DP+oHTOUrU=; b=LxEczbXybyBx0wxiFE4l/XHHjqH+jgDicHxh6BKXlKiFXF5qMyqc7EYw1TpafLSNLx a8YXGvdcy11IRQTVH6uFqXgfS2z6kiVGeENJbnKBffatM5n+UEuhGsChEaKlBBq8TZfQ eQcxbNYjBrg+84FHiTF6KmeiScYe0mdO1xFq0W1iL53fsYwor/+Xg14WG/B+yHouqCpd R7wCLpFCUJSqncybtjgzPksmSwiFiHqBliYGqmF1UVigtjDArxY4kVKQIlADSNFna3sk XKD1H7LtCjNI1N3Q/liVCvdOtLz9RzTPp3cQJVHieeM/4ic8a/vaHIJbRrYfM+on70Ei ZCqQ==
- In-reply-to: <20200620215506.7bfb0175@uib.no>
- List-archive: <https://groups.google.com/a/noaa.gov/group/ferret_users/>
- List-help: <https://support.google.com/a/noaa.gov/bin/topic.py?topic=25838>, <mailto:ferret_users+help@noaa.gov>
- List-id: <ferret_users.noaa.gov>
- List-post: <https://groups.google.com/a/noaa.gov/group/ferret_users/post>, <mailto:ferret_users@noaa.gov>
- Mailing-list: list ferret_users@xxxxxxxx; contact ferret_users+owners@xxxxxxxx
- References: <20200619115546.226a51cd@gfi063209.klientdrift.uib.no> <CAEwQpa+DFAUcHj0_WU6KBvwu4SqwoxuOsUT=fUWQvrWEvnZSyg@mail.gmail.com> <20200620215506.7bfb0175@uib.no>
- Sender: owner-ferret_users@xxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0
Hi,
Interesting thread. I hadn't been aware of that detail regarding the
equal sign on DEFINE SYMBOL.
Some of this is described in Command Syntax,
https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/introduction/COMMAND-SYNTAX
and other documentation about syntax is linked in that section,
In the Ferret/PyFerret command parser, the first thing that happens, is
that the different "words" in the command are located. They're
separated by spaces,
LET variable = 7
or by slashes
PLOT/X=157/Y=33/Z=20/COLOR=blue/title="measured oxygen" o2_observed
If it finds quotes, then everything inside those quotes is grouped
together, until the next quote is found. Likewise the start and end of
square brackets or curly braces is located.
During command parsing, any expression within any grave-accents, so
`stuff` is immediately evaluated and its value put into the command line.
Once the "words" are located, their role is identified, is it a command,
or a subcommand, e.g. DEFINE SYMBOL are a command and subcommand. Or is
it a qualifier, /X=157, or /TITLE= or is it an argument, or an element
of an expression.
There seem to be some odd little artifacts about trailing slashes.
On the left-hand side of an equal sign, a slash is generally seen as the
start of the next qualifier, and if there isn't one,
yes? let/title=myvar/units=m/ var = 8
**ERROR: unknown command qualifier: var = 8
but if it's in an expression, it's ignored.
yes? let/title=myvar/units=m var = 9/
yes? list var
VARIABLE : myvar (m)
9.000
DEFINE SYMBOL seems to be set up so the value of the symbol is taken to
be everything following "define symbol" on the command line, up to but
not including a ! comment, and not including a trailing slash.
yes? define symbol sym1 = Some text including $ and / but not including
this comment ! comment
yes? define symbol sym2 Some text including $ and / but not including
this comment ! comment
yes? show symbol sym*
SYM1 = "Some text including $ and / but not including this comment"
SYM2 = "Some text including $ and / but not including this comment"
In scripts, I sometimes build up a set of qualifiers, so the qualifiers
for a PLOT command might be built up depending on the state of things
and different settings, so over the course of running a set of scripts
that open a dataset and make a plot, these definitions might be
scattered in there. If the first one starts with a slash, and each new
one gets its own slash, it all works out in the end. The PLOT command
also works even if there are no qualifiers set at all.
cancel symbol qualifiers ! at the start of the session.
DEFINE SYMBOL qualifiers = ($qualifiers)/X=157/Y=33/Z=20
DEFINE SYMBOL qualifiers = ($qualifiers)/T=1-jan-2020:31-mar-2020
DEFINE SYMBOL qualifiers = ($qualifiers)/title="the title"
DEFINE SYMBOL qualifiers = ($qualifiers)/dash/color=red
plot($qualifiers) theta
!-> plot/X=157/Y=33/Z=20/T=1-jan-2020:31-mar-2020/title="the
title"/dash/color=red theta
On 6/20/2020 12:55 PM, Marco van Hulten wrote:
Ryo—
Je Sat, 20 Jun 2020 14:52:57 +0900 skribis Ryo:
On Fri, Jun 19, 2020 at 6:57 PM Marco van Hulten <Marco.Hulten@xxxxxx>
wrote:
I noticed that a trailing slash is ignored for in a string variable,
I guess the correct statement is that trailing slashes are ignored *by the
commands.*
yes? define symbol ss "/abc/"
yes? show symbol ss
SS = "/abc/"
yes? define symbol ss /abc/
yes? show symbol ss
SS = "/abc"
That means that it was the "DEFINE SYMBOL" command which ignored the
trailing backslash.
Furthermore,
yes? define symbol ss "/abc/"
yes? say ($ss)
!-> MESSAGE/CONTINUE /abc
/abc
yes? say "($ss)"
!-> MESSAGE/CONTINUE "/abc/"
/abc/
In this case, it was the SAY command which ignored the trailing backslash.
So, to avoid the trailing slash from being interpreted by the command, you
quote the string.
Thanks, it looks like this works very well!
According to the manual [1], however, the syntax should contain an
equal sign, like
define symbol ss = something
instead of
define symbol ss something
Without the equal sign it works best, though, because you can use
quotation marks without them becoming part of the symbol. The
following two statements seem equivalent (according to what a quoted
SAY command tells me):
define symbol sja = ka\/\/
define symbol sja "ka/"
Earlier I was referring to my "solution" as "doubly escaping", but that
would rather look like \\/ (or \\\\ that one sometimes needs to print
a backslash); I don't know what \/\/ is or why I thought it was a good
idea to try it out.
The behaviour of variables of type string (DEFINE VARIABLE or LET)
seems more predictable to me, so I guess it is best to only use DEFINE
SYMBOL when absolutely needed (basically, to avoid `embedded
`backtics``).
If one would use the non-= syntax for LET, this happens:
yes? let aa = 3
yes? list aa
VARIABLE : 3
3.000
yes? let bb 7
yes? list bb
VARIABLE : 7
7.000
yes? let cc "abc"
**ERROR: command syntax: abc"
unclosed quotation, parenthesis, or bracket
suggesting it may be a bad habit to omit the equal sign. But I really
don't know! It seems that Ferret is quite lax in its syntax, but that
introduces some unpredictable behaviour! Unless we read the source, of
course.
—Marco
[1]: https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/DEFINE
--
Ansley Manke
Science Data Integration Group
NOAA Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115
I am currently teleworking and am available Tue-Wed-Thu.
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
Ferret
Privacy Policy | Disclaimer | Accessibility Statement