.TH "md_src_plugins_mathcheck_README" 3elektra "Sun May 29 2016" "Version 0.8.14" "Elektra" \" -*- nroff -*- .ad l .nh .SH NAME md_src_plugins_mathcheck_README \- README .IP "\(bu" 2 infos = Information about the mathcheck plugin is in keys below .IP "\(bu" 2 infos/author = Thomas Waser thomas.waser@libelektra.org .IP "\(bu" 2 infos/licence = BSD .IP "\(bu" 2 infos/needs = .IP "\(bu" 2 infos/provides = check .IP "\(bu" 2 infos/placements = presetstorage .IP "\(bu" 2 infos/description = .PP .PP Compares a key value to a mathematical expression using polish prefix notation defined in the \fCcheck/math\fP metakey\&. Operations are \fC+ - / *\fP \&. Operants are keys with names relative to the parent key\&. How the values are compared is specified at the beginning of the metakey using the conditions \fC<, <=, ==, !=, =>, >, :=\fP \fC:=\fP is used to set key values\&. All values are interpreted as \fCdouble\fP floating point values\&. .PP .SS "Examples" .PP \fCcheck/math = '== + testval1 + testval2 testval3'\fP compares the keyvalue to the sum of testval1-3 and yields an error if the values are not equal\&. \fCcheck/math = '\\<= - testval1 * testval2 testval3'\fP tests if the keyvalue is less than or equal to testval1 - (testval2 * testval3) and yields an error if not\&. .PP Full example: .PP .nf kdb mount mathcheck.dump /example/mathcheck dump mathcheck kdb set user/example/mathcheck/a 3.1 kdb set user/example/mathcheck/b 4.5 kdb set user/example/mathcheck/k 7.6 kdb setmeta user/example/mathcheck/k check/math "== + a b" kdb set user/example/mathcheck/k 7.7 # fails .fi .PP .PP To calculate values on-demand you can use: .PP .nf kdb setmeta user/example/mathcheck/k check/math ":= + a b" kdb get user/example/mathcheck/k # 12.5 kdb set user/example/mathcheck/a 5.5 kdb get user/example/mathcheck/k # 10 .fi .PP .PP It also works with constants: .PP .nf kdb setmeta user/example/mathcheck/k check/math ":= + a '5'" kdb get user/example/mathcheck/k # 10.5 kdb set user/example/mathcheck/a 8.0 kdb get user/example/mathcheck/k # 13 .fi .PP