User Tools

Site Tools


en:cachevariables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:cachevariables [2022/02/22 10:14] – [Numeric operators] lineflyeren:cachevariables [2022/11/25 11:58] (current) – [Range expressions] New syntax for range expressions lineflyer
Line 1: Line 1:
-**FIXME** This will be used to describe the new tab on cache details used for cache variables. 
- 
-**FIXME** We could add a chapter with some practical How-To examples (e.g. typical lettervalue case) 
- 
 ====== Cache Variables ====== ====== Cache Variables ======
  
Line 82: Line 78:
 |Integer | Number without decimal places | Use digits | ''1234'', ''-3''| |Integer | Number without decimal places | Use digits | ''1234'', ''-3''|
 |Decimal | Number with decimal places | Use digits with decimal point or comma | ''3.14'', ''-3.14'', ''3,14''| |Decimal | Number with decimal places | Use digits with decimal point or comma | ''3.14'', ''-3.14'', ''3,14''|
-|String | Text | Surround value with '' ''' or ''"''\\  To use the '' ' '' or '' " '' their selves, type '' **FIXME** '' or '' "" ''| '' 'test''', ''"test"''\\ ''"He said ""yes""!"''|+|String | Text | Surround value with ''%%'%%'' or ''%%"%%''\\  To use the ''%%'...'%%'' or ''%%"..."%%'' their selves, type ''%%''%%'' or ''%%""%%''| ''%%'test'%%'', ''%%"test"%%''\\ ''"He said ""yes""!"''|
  
-**FIXME** using monotext does not work for ' in this table as its also part of the monotext syntax in Dokuwiki. :( 
  
 ==== Numeric operators ==== ==== Numeric operators ====
Line 92: Line 87:
 ^ Operator ^ Function ^ Example ^ ^ Operator ^ Function ^ Example ^
 |''+''|Addition|''2+4'' evaluates to '' 6''| |''+''|Addition|''2+4'' evaluates to '' 6''|
-|''-''|Subtraction (or negating a number)|''6-4'' evaluates to ''2''\\ ''-(5-2)'' evaluates to ''-3''|+|''-''|Subtraction\\ (or negating a number)|''6-4'' evaluates to ''2''\\ ''-(5-2)'' evaluates to ''-3''|
 |''*''|Multiplication|''3*4'' evaluates to ''12''| |''*''|Multiplication|''3*4'' evaluates to ''12''|
 |''/''|Division|''12/3'' evaluates to ''4''| |''/''|Division|''12/3'' evaluates to ''4''|
 |''%''|Modulo|''12%5'' evaluates to ''2''| |''%''|Modulo|''12%5'' evaluates to ''2''|
-|''^''|Potentiate|''3^3'' evaluates to ''9''|+|''^''|Potentiate|''3^3'' evaluates to ''27''|
 |''!''|Factorize|''4!'' evaluates to ''24''| |''!''|Factorize|''4!'' evaluates to ''24''|
  
Line 114: Line 109:
 * Else the fifth parameter is returned * Else the fifth parameter is returned
  
-For example ''if(A==5;50;A==4;40;30)'' will evaluate to ''50'' if ''A=50'', to ''40'' if ''A=4'' and to ''30'' for any other value of ''A''.+For example ''if(A==5;50;A==4;40;30)'' will evaluate to ''50'' if ''A=5'', to ''40'' if ''A=4'' and to ''30'' for any other value of ''A''.
  
 ^ Operator ^ Meaning ^ Example ^ ^ Operator ^ Meaning ^ Example ^
Line 132: Line 127:
 The following functions are defined: The following functions are defined:
  
-^ Function ^ Synonyms ^ Description ^ Parameter1 ^ Parameter 2 ^ Example ^+^ Function ^ Synonyms ^ Description ^ Parameter 1 ^ Parameter 2 ^ Example ^
 |''sqrt''|-|calculates square root of given parameter|numeric parameter| - |''sqrt(9)'' evaluates to ''3''| |''sqrt''|-|calculates square root of given parameter|numeric parameter| - |''sqrt(9)'' evaluates to ''3''|
 |''sin''/''cos''/''tan'' |-| calculates sinus/cosinus/tangens of given parameter | numeric parameter in degree(!)| - | ''sin(90)'' evaluates to ''1''| |''sin''/''cos''/''tan'' |-| calculates sinus/cosinus/tangens of given parameter | numeric parameter in degree(!)| - | ''sin(90)'' evaluates to ''1''|
 |''abs''|-| calculates absolute value | numeric parameter | - | ''abs(-34)'' evaluates to ''34''| |''abs''|-| calculates absolute value | numeric parameter | - | ''abs(-34)'' evaluates to ''34''|
-|''round''|-| rounds decimal values mathematically | value to round | optional: number of places to round to | ''round(4.65)'' evaluates to ''5'', ''round(4.65; 1)'' evaluates to ''4.7''|+|''round''|-| rounds decimal values mathematically | value to round | optional: number of places to round to | ''round(4.65)'' evaluates to ''5'', ''round(4.65;1)'' evaluates to ''4.7''
 +|''trunc''|-| Truncates decimal values to the (optional) provided number of places | value to truncate | optional: Number of places to remain after truncation (default:0) | ''trunc(123.456)'' evaluates to ''123'', ''trunc(123.456;2)'' evaluates to ''123.45'' |
 |''if''|-| evaluates conditions and returns conditional values | list of if-then-else-values. See previous section for details | - | ''if(3<4;5;6)'' evaluates to ''5''| |''if''|-| evaluates conditions and returns conditional values | list of if-then-else-values. See previous section for details | - | ''if(3<4;5;6)'' evaluates to ''5''|
 |''checksum''|''cs''| calculates checksum of given numeric value. Calculates lettervalue if given paramter is of type text | positive integer or text | - | ''checksum(345)'' evaluates to ''12''| |''checksum''|''cs''| calculates checksum of given numeric value. Calculates lettervalue if given paramter is of type text | positive integer or text | - | ''checksum(345)'' evaluates to ''12''|
Line 145: Line 141:
 |''roman''|-| scans a given string value as a roman number and returns its decimal value | string | - | ''roman('VI')'' evaluates to ''6''.| |''roman''|-| scans a given string value as a roman number and returns its decimal value | string | - | ''roman('VI')'' evaluates to ''6''.|
 |''vanity''|''vanitycode'', ''vc''| returns the vanity code of a string | string | - | ''vanity('cgeo')'' evaluates to ''2436''.| |''vanity''|''vanitycode'', ''vc''| returns the vanity code of a string | string | - | ''vanity('cgeo')'' evaluates to ''2436''.|
- 
  
 ==== Variables ==== ==== Variables ====
Line 186: Line 181:
   * The Formula ''1_A'' with ''A=2'' will evaluate to ''102''   * The Formula ''1_A'' with ''A=2'' will evaluate to ''102''
   * The Formula ''1_A'' with ''A=23'' will evaluate to ''123''   * The Formula ''1_A'' with ''A=23'' will evaluate to ''123''
-  * The Formula ''1__A'' with ''A=23'' will evaluate to ''1023'' +  * The Formula ''%%1__A%%'' with ''A=23'' will evaluate to ''1023'' 
-  * The Formula ''1__A'' with ''A=234'' will evaluate to ''1234''+  * The Formula ''%%1__%%A'' with ''A=234'' will evaluate to ''1234'' 
  
-**FIXME** Double underscore is interpreted as underline by Dokuwiki 
 ==== Range expressions ==== ==== Range expressions ====
  
-You can specify ranges in formulas using ''[]''. This is needed when variables are used in a context where a range of values should be iterated over. A prominent example is the "Generate Waypointsfunction.+You can specify ranges in formulas using ''[:]''. This is needed when variables are used in a context where a range of values should be iterated over. A prominent example is the [[.:waypointcalculator|Generate Waypoints]] function.
  
-An example for a range expression is ''[0-9]''. This specifies a range with 10 values (the integer values 0 to 9).+**FIXME** Link to anchor on waypoint calc page as soon as its updated to cover waypoint generation with ranges. 
 + 
 +An example for a range expression is ''[:0-9]''. This specifies a range with 10 values (the integer values 0 to 9).
  
 You may specify consecutive values using '','' as a delimiter. You may exclude values or value ranges by prepending a ''^'' to it. Ranges are parsed from left-to-right, giving an order to the elements in the range. For example the following are valid range specifications: You may specify consecutive values using '','' as a delimiter. You may exclude values or value ranges by prepending a ''^'' to it. Ranges are parsed from left-to-right, giving an order to the elements in the range. For example the following are valid range specifications:
-  * ''[0-2, 4]'' evaluates to a range containing ''0'', ''1'', ''2'' and ''4''+  * ''[:0-2, 4]'' evaluates to a range containing ''0'', ''1'', ''2'' and ''4''
-  * ''[0-3, ^1-2]'' evaluates to a range containing ''0'' and ''3''+  * ''[:0-3, ^1-2]'' evaluates to a range containing ''0'' and ''3''
-  * ''[0-3, ^1-2, 5]'' evaluates to a range containing ''0'', ''3'' and ''5''.+  * ''[:0-3, ^1-2, 5]'' evaluates to a range containing ''0'', ''3'' and ''5''.
  
-When a range is used in a context where only one value is allowed (this is the case in normal calculation), the first range value is used for calculation. For example, the expression ''[8, 0-9]'' will evalulate to ''0'' in a normal calculation context, while ''[8, 0-9]'' will evalulate to ''8''.+When a range is used in a context where only one value is allowed (this is the case in normal calculation), the first range value is used for calculation. For example, the expression ''[:0-9]'' will evaluate to ''0'' in a normal calculation context, while ''[:8, 0-9]'' will evaluate to ''8''.
  
 Ranges currently support only positive constant integer values. A range must always be evaluate to at least 1 value and a range may not evaluate to more than 20 values. For example the following ranges are invalid: Ranges currently support only positive constant integer values. A range must always be evaluate to at least 1 value and a range may not evaluate to more than 20 values. For example the following ranges are invalid:
-  * ''[]'': empty +  * ''[:]'': empty 
-  * ''[5, ^0-9]'': evaluates to empty +  * ''[:5, ^0-9]'': evaluates to empty 
-  * ''[0-1000]'': evaluates to more than 20 entries +  * ''[:0-1000]'': evaluates to more than 20 entries 
-  * ''[-5]'': negative int not allowed +  * ''[:-5]'': negative int not allowed 
-  * ''[A]'': variables not allowed+  * ''[:A]'': variables not allowed
  
 A formula may include one or more range definitions mixed with normal other formula parts. For example the following formulas are valid: A formula may include one or more range definitions mixed with normal other formula parts. For example the following formulas are valid:
-  * ''3*[0-2]'': evaluates to values ''0'', ''3'' and ''6'' +  * ''3*[:0-2]'': evaluates to values ''0'', ''3'' and ''6'' 
-  * ''A*[4, 7]'': for ''A=3'' this evaluates to values ''12'' and ''21'' +  * ''A*[:4, 7]'': for ''A=3'' this evaluates to values ''12'' and ''21'' 
-  * ''[1-2]*[3-4]'': evaluates to ''3'', ''6'', ''4'' and ''8''.+  * ''[:1-2]*[:3-4]'': evaluates to ''3'', ''6'', ''4'' and ''8''. 
 + 
 + 
 +==== Comments ==== 
 + 
 +You may enter comments into formula expressions using the ''#'' character. Comments end at next ''#'' or at end of expressions. Everything in a comment is ignored during evaluation. For example: 
 +  * ''A * 5 # test comment'' for ''A=3'' evaluates to ''15'' 
 +  * ''3.14 # this is pi # * 2 # and this is two'' evaluates to ''6.28''
en/cachevariables.1645521261.txt.gz · Last modified: 2022/02/22 10:14 by lineflyer