Webtags/Parameters (preserving history): Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
→‎Use of spaces: ok, now finally the code shows correctly
m (→‎Use of spaces: Rewrite of last paragraph)
m (→‎Use of spaces: ok, now finally the code shows correctly)
(5 intermediate revisions by the same user not shown)
Line 206: Line 206:
===Use of spaces===
===Use of spaces===


There are multiple parameters for specifying dates and times, and you might want spaces to appear in that output format.
There are multiple symbols for specifying dates and times, and you might want spaces to appear between symbols in that output format.


If we need to include spaces, then we have to enclose the whole specifier in double quotation marks e.g. <code><#tag_name format="x y z"></code>
You need to add quotation marks to the output format specifier if spaces are present.


Any literals (i.e. characters we do not want to be interpreted by the date time parameter parser) are generally enclosed in single quotation marks, within the double quotation marks delimiting the specifierYou will find literals discussed fully at [[#Including literals in format parameters]] later.
The first complication is that the parser that interprets time/date characters has two ways of interpreting a space character, depending on what immediately follows. In the tables, below, I have used a "%" in various places. In any of those places, a space is not a gap between characters, but an alternative to "%"I discuss this later in [[#Migrating from legacy Cumulus 1 to MX]] section.


For now just remember, the use of literals can cause you a problem if you want to use a date/time specification in a script because the script wants literal delimiters outside any web tags, so that delimiters remain when the web tag itself has been processed into a string by Cumulus.  The complicated sounding (but actually simple solution) is to avoid placing literals within any output format specifier, instead put single quotes round the whole content. What you thought of putting as literals within any web tag is instead typed outside with separate web tags for the part of the specification before and after each literal.
For a space character to be interpreted as a gap between symbols, the symbol that follows the space must include at least two characters. The syntax <code><#tag_name format="x y z"></code> works if the y and z in it are representing multi-character symbols. To explain this, an example is '''<#TpressTH format="h:mm tt">''' as both ''h:mm'' and ''tt'' are multi-character symbols, we have inserted a space after the minutes.
 
That approach would not work if we wanted to use single character specifiers, a simple example is '''<#MonthPressHD format=" d' 'M">''', here the month number is a single character "M", so to insert the space we have to treat it as a literal by enclosing the space character in single quotes and the whole specifier in double quotes.  Literals are discussed fully in the [[#Including literals in format parameters]] sub-section later. If we want to include other characters not to be interpreted by the date time parameter parser, and spaces, then both double and single quotes must be used, and the spaces must be within the single quotes.  An example, that shows all the options that MX allows, with literals is <code> <#TpressH format="\a't 'h:mm'&nbsp;' tt' <nowiki><small>on 'd/M/yyyy' </small></nowiki>'"> </code>.
 
Finally, the use of literals can cause you ''a problem if you want to use a date/time specification in a script'' because the script wants literal delimiters outside any web tags, so that delimiters remain when the web tag itself has been processed into a string by Cumulus.  This means the type of quotes (single or double) used outside the web tag, cannot be used within the web tag. The complicated sounding (but actually simple solution) is to avoid placing literals, and/or spaces, within any output format specifier, instead put single quotes round the whole content. What you thought of putting as literals within any web tag is instead typed outside with separate web tags for the part of the specification before and after each literal.


===Which tag names take date/time output formatting modifiers===
===Which tag names take date/time output formatting modifiers===
Line 720: Line 724:




== Migrating from legacy to MX==
== Migrating from legacy Cumulus 1 to MX==


If you use NOAA type report functionality, and choose to transfer your existing [[Cumulus.ini (Cumulus 1)|existing configuration file (cumulus.ini)]] to [[Cumulus.ini|MX]], you need to be concerned about how to represent a month.
If you have created any legacy cumulus template files, then in each template, you will need to do some editing. Everywhere a web tag appears with an output modifiers that is used to specify a date and/or time format, has to be edited before that template will work for MX.  


If you have created any Cumulus template files, then every place in each template, where an output modifiers is used to specify a date and/or time format, has to be edited. For web tags it is much more complicated, simply because it is not just month we may be representing, and we might require only one specifier (being careful whether we use a standard or custom modifier) or we might want to specify a combination of modifiers (and we might want to add a space character or other literals). It is difficult to summarise, but here are some potential issues:
Here are the main reasons:
* the reserved characters are different in C1 and MX (affecting use of literals like "on" and "at" that appear in many English time-stamps)
* the reserved characters are different in C1 and MX (affecting use of literals like "on" and "at" that appear in many English time-stamps)
* the Delphi in legacy Cumulus is case insensitive, so for example "H" and "h" have the same meaning
* MX is case sensitive, and symbols mostly have different meanings when one symbol is used to when that symbol is used with others, so for example "H" and "h" have different meanings, and if not used with other symbols will need to be preceded with a "%" to have same meaning as they have in combination with other symbols
* In the legacy cumulus, a symbol like "d" has the same meaning for any tag
* MX is inconsistent, a symbol like "d" changes its meaning depending on the tag it is used with (e.g. the script conditional ''''<#metdateyesterday format=d>' == '<#yesterday format=d)>''''  will never be equal as the LHS returns a full date and the right hand side returns day of month only)
* the symbols used for representing such modifiers as minutes, month, am/pm, are different between C1 and MX.
* MX introduces the concept of escaping characters (a '''\''' placed before a character can be either a control sequence or an instruction to display the character)
* MX introduces the concept of escaping characters (a '''\''' placed before a character can be either a control sequence or an instruction to display the character)
* MX is inconsistent e.g. '''format=d''' gives a different result depending on the tag it is applied to (e.g. the script conditional ''''<#metdateyesterday format=d>' == '<#yesterday format=d)>''''  will never be equal as the LHS returns a full date and the right hand side returns day of month only)
* In the legacy Cumulus, a space is a gap between characters
* in MX space in some cases may need to be within the single quotes containing other literals (as in MX space can change the interpretation of a modifier character).
* In MX, a space must be within a literal, as a space before a symbol has the same effect as "%", (it changes the interpretation of a modifier character).


'''Confused even more now?''' I'm not surprised, but maybe some examples will help before we actually list the available modifiers.
'''Confused even more now?''' I'm not surprised, but maybe some examples will help.


=== Examples ===
=== Examples ===
Line 753: Line 762:
** but alternatively you can escape each verbatim character with a backslash as prefix (Cumulus MX).  
** but alternatively you can escape each verbatim character with a backslash as prefix (Cumulus MX).  
* You may need to use both single quotes and back slashes in some format specifiers, depending whether the characters you want to include can be interpreted as control characters (yes, backslash is also used to escape control characters, so backslash will NOT work for some characters such as those in "on" and "at" [\n will produce new line not the letter n, \t will produce a tab not the letter t]), consequently for some characters you must use the literal approach to include them in your format.
* You may need to use both single quotes and back slashes in some format specifiers, depending whether the characters you want to include can be interpreted as control characters (yes, backslash is also used to escape control characters, so backslash will NOT work for some characters such as those in "on" and "at" [\n will produce new line not the letter n, \t will produce a tab not the letter t]), consequently for some characters you must use the literal approach to include them in your format.


== Past history for this page==
== Past history for this page==
5,838

edits

Navigation menu