1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#+TITLE: 7Units Datafile Specification
#+SUBTITLE: For Version 0.5.0
#+DATE: 2024 February 24
#+LaTeX_HEADER: \usepackage[a4paper, lmargin=25mm, rmargin=25mm, tmargin=25mm, bmargin=25mm]{geometry}
#+LaTeX: \newpage
* Unit and Prefix Files
Unit and prefix files specify the units and prefixes that are available to 7Units. Their format is intended to be compatible with 7Units's inspiration, [[https://www.gnu.org/software/units/][GNU Units]].
Each unit or prefix is specified by a line in the following format:
#+BEGIN_SRC
<name><one or more whitespace><definition>
#+END_SRC
The name may not contain whitespace, but the definition can and often will. Lines can be separated by either a line feed (0x0A) or a carriage return followed by a line feed (0x0D 0x0A).
** Ignored Lines & Comments
All of the following should be ignored:
- Any line containing only whitespace
- Any trailing whitespace
- Any characters between a ~#~ (0x23) character and the end of the line.
This allows unit and prefix files to be easily organized and divided.
** Unit Expressions
The definition part of a unit's line is a unit expression - the same sort of expression you would use in the complex unit converter.
Expressions should be a standard mathematical expression, which can operate on either numbers or units. The following operators are supported: addition (+), subtraction (-), multiplication (~*~ or no operator), division (~/~ or ~|~), exponentation (~^~; exponent must be a number). Brackets (~(~ and ~)~) may be used to change order of operations, but otherwise standard BEDMAS order is followed (exponentation first, then multiplication and division, then addition and subtraction), with two exceptions: if a number is multiplied by a unit using spaces, the multiplication will have precedence over division, and division with ~|~ has higher precedence than any other operator. For example, "2 m / 1 m" is equal to the dimensionless value 2, not 2 m^2. An example of a line defining a unit is:
#+BEGIN_SRC
yard 9 dm + 1.4 cm + 4 mm^2 / 10 mm
#+END_SRC
If the definition is an exclamation mark (~!~), this defines a base unit, which is expected to already be stored in the system.
** Prefixes & Prefix Expressions
If a line's name part ends in the ASCII dash (~-~, 0x2D), it defines a prefix instead of a unit (this dash is not included in the prefix's name). Prefix expressions are like unit expressions, but the operands are prefixes and numbers, not units and numbers. Because prefixes do not have a dimension, there are no base prefixes - the exclamation mark is forbidden in prefix expressions.
* Dimension Files
Dimension files give names to unit dimensions, so they can be selected in the unit converter to determine which units are shown. Dimension files are similar to unit and prefix files, except that they use a different set of base /dimensions/ (defined with ! as usual), and that addition and subtraction are not supported in dimension expressions.
* Metric Exception Files
Metric exception files list exceptions to the One-Way Conversion rule. Units included in these files are always shown on both sides of the unit converter, even if One Way Conversion is enabled. They are just a list of units, one per line. Ignored lines and comments work the same way as in other data files.
* Configuration Files
A configuration file contains one line for each configuration setting, in the format ~key=value~. Check the user manual for the list of configurable setting keys. Ignored lines and comments work the same way as in other data files.
|