Difference between revisions of "Number Inline Expressions"

From MSX - Wiki
Jump to navigation Jump to search
Line 1: Line 1:
It is possible to convert numbers (indicated in milliseconds) with inline expressions into date, time, or duration values. The expressions are similar to the [[Live Inline Expressions]] and look like this: <code>{num:{NUMBER}:{TYPE}:{FORMAT}}</code>. It is also possible to add colored values with the expression syntax <code>{txt:{COLOR}:num:{NUMBER}:{TYPE}:{FORMAT}}</code>. Please see [[Colors]] for possible color values. This feature is available since version '''0.1.91'''. Since version '''0.1.160''', a number can also be classically formatted by using the syntax <code>{num:{NUMBER}:format}</code> (e.g. <code>{num:1234.1234:format}</code>) or <code>{num:{NUMBER}:format:{DECIMAL_DIGITS}{DECIMAL_TRIMMING}}</code> (e.g. <code>{num:1234.1234:format:24}</code>) or <code>{num:{NUMBER}:format:{THOUSANDS_SEPARATOR}{DECIMAL_SEPARATOR}{DECIMAL_DIGITS}{DECIMAL_TRIMMING}}</code> (e.g. <code>{num:1234.1234:format:,.24}</code>). In the first two cases, the number format is taken from the dictionary.
+
It is possible to convert numbers (indicated in milliseconds) with inline expressions into date, time, or duration values. The expressions are similar to the [[Live Inline Expressions]] and look like this: <code>{num:{NUMBER}:{TYPE}:{FORMAT}}</code>. It is also possible to add colored values with the expression syntax <code>{txt:{COLOR}:num:{NUMBER}:{TYPE}:{FORMAT}}</code>. Please see [[Colors]] for possible color values. This feature is available since version '''0.1.91'''. Since version '''0.1.160''', a number can also be basically formatted by using the syntax <code>{num:{NUMBER}:format}</code> (e.g. <code>{num:1234.1234:format}</code>) or <code>{num:{NUMBER}:format:{DECIMAL_DIGITS}{DECIMAL_TRIMMING}}</code> (e.g. <code>{num:1234.1234:format:24}</code>) or <code>{num:{NUMBER}:format:{THOUSANDS_SEPARATOR}{DECIMAL_SEPARATOR}{DECIMAL_DIGITS}{DECIMAL_TRIMMING}}</code> (e.g. <code>{num:1234.1234:format:,.24}</code>). In the first two cases, the number format is taken from the dictionary.
  
 
Please see following example.
 
Please see following example.
 +
 +
== Basic Number Format ==
 +
{| class="wikitable sortable"
 +
|+ Basic format of numbers
 +
|-
 +
! Format Example  !! Output Example !! Since Version
 +
|-
 +
|
 +
<code>{num:123:format}</code><br/>
 +
<code>{num:1234:format}</code><br/>
 +
<code>{num:12345.12345:format}</code><br/>
 +
||
 +
<code>123</code><br/>
 +
<code>1,234</code><br/>
 +
<code>12,344.12345</code><br/>
 +
| data-sort-value=160|'''0.1.160'''
 +
|-
 +
|
 +
<code>{num:1234:format:1}</code><br/>
 +
<code>{num:1234:format:2}</code><br/>
 +
<code>{num:1234:format:02}</code><br/>
 +
<code>{num:1234:format:12}</code><br/>
 +
<code>{num:1234.1:format:1}</code><br/>
 +
<code>{num:1234.1:format:2}</code><br/>
 +
<code>{num:1234.1:format:02}</code><br/>
 +
<code>{num:1234.1:format:12}</code><br/>
 +
<code>{num:1234.1234:format:1}</code><br/>
 +
<code>{num:1234.1234:format:2}</code><br/>
 +
<code>{num:1234.1234:format:02}</code><br/>
 +
<code>{num:1234.1234:format:12}</code><br/>
 +
||
 +
<code>1,234.0</code><br/>
 +
<code>1,234.00</code><br/>
 +
<code>1,234</code><br/>
 +
<code>1,234.0</code><br/>
 +
<code>1,234.1</code><br/>
 +
<code>1,234.10</code><br/>
 +
<code>1,234.1</code><br/>
 +
<code>1,234.1</code><br/>
 +
<code>1,234.1</code><br/>
 +
<code>1,234.12</code><br/>
 +
<code>1,234.12</code><br/>
 +
<code>1,234.12</code><br/>
 +
| data-sort-value=160|'''0.1.160'''
 +
|}
  
 
== Example ==
 
== Example ==

Revision as of 12:29, 31 October 2024

It is possible to convert numbers (indicated in milliseconds) with inline expressions into date, time, or duration values. The expressions are similar to the Live Inline Expressions and look like this: {num:{NUMBER}:{TYPE}:{FORMAT}}. It is also possible to add colored values with the expression syntax {txt:{COLOR}:num:{NUMBER}:{TYPE}:{FORMAT}}. Please see Colors for possible color values. This feature is available since version 0.1.91. Since version 0.1.160, a number can also be basically formatted by using the syntax {num:{NUMBER}:format} (e.g. {num:1234.1234:format}) or {num:{NUMBER}:format:{DECIMAL_DIGITS}{DECIMAL_TRIMMING}} (e.g. {num:1234.1234:format:24}) or {num:{NUMBER}:format:{THOUSANDS_SEPARATOR}{DECIMAL_SEPARATOR}{DECIMAL_DIGITS}{DECIMAL_TRIMMING}} (e.g. {num:1234.1234:format:,.24}). In the first two cases, the number format is taken from the dictionary.

Please see following example.

Basic Number Format[edit]

Basic format of numbers
Format Example Output Example Since Version

{num:123:format}
{num:1234:format}
{num:12345.12345:format}

123
1,234
12,344.12345

0.1.160

{num:1234:format:1}
{num:1234:format:2}
{num:1234:format:02}
{num:1234:format:12}
{num:1234.1:format:1}
{num:1234.1:format:2}
{num:1234.1:format:02}
{num:1234.1:format:12}
{num:1234.1234:format:1}
{num:1234.1234:format:2}
{num:1234.1234:format:02}
{num:1234.1234:format:12}

1,234.0
1,234.00
1,234
1,234.0
1,234.1
1,234.10
1,234.1
1,234.1
1,234.1
1,234.12
1,234.12
1,234.12

0.1.160

Example[edit]

Screenshot[edit]

Example Screenshot (Number Inline Expressions)

Code[edit]

{
    "type": "pages",
    "headline": "Number Inline Expressions",
    "template": {
        "type": "separate",
        "layout": "0,0,2,3",
        "icon": "msx-white-soft:info",
        "color": "msx-glass"
    },
    "items": [{
            "title": "Specific Date/Time",
            "action": "info:{num:1548335764000:date:DD, MM d, yyyy}, {num:1548335764000:time:h:mm/ampm}"
        }, {
            "title": "Current Date/Time",
            "action": "info:{num:now:date:DD, MM d, yyyy}, {num:now:time:h:mm/ampm}"
        }, {
            "title": "Colored Date/Time",
            "action": "info:{txt:msx-blue:num:1548335764000:date:DD, MM d, yyyy}, {txt:msx-blue:num:1548335764000:time:h:mm/ampm}"
        }, {
            "title": "Duration Time",
            "action": "info:{num:5640000:duration:time:hh:mm:ss}"
        }, {
            "title": "Duration Text",
            "action": "info:{num:5640000:duration:text:dhms}"
        }, {
            "title": "Colored Duration",
            "action": "info:{txt:msx-blue:num:5640000:duration:text:dhms}"
        }]
}

Demo[edit]