- Timestamp:
- 01/17/08 11:22:22 (9 months ago)
- Files:
-
- trunk/patTemplate/Modifier/Calc.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/patTemplate/Modifier/Calc.php
r465 r468 13 13 /** 14 14 * patTemplate modifier Calculator 15 * 15 * 16 16 * Perfom simple mathematic operations like + - * / 17 * 17 * 18 18 * Example: 19 * 19 * 20 20 * Declare variable a with default value 10 and perform + operation. 21 * With the memory parameter you can specify diffrent buffers. If no memory 21 * With the memory parameter you can specify diffrent buffers. If no memory 22 22 * parameter isset, the operation will be performend on default memory. 23 * 23 * 24 24 * <patTemplate:var default="10" name="a" modifier="calc" operator="+" memory="axel"/> 25 25 * <patTemplate:var default="5" name="b" modifier="calc" operator="+" memory="axel"/> 26 26 * <patTemplate:var default="5" name="sum" modifier="calc" operator="=" memory="axel"/> 27 * 28 * If you dont specify a default value it is improtant that the variable is 27 * 28 * If you dont specify a default value it is improtant that the variable is 29 29 * assigned in your php code like this: 30 30 * $tmpl->AddVar( 'page', 'a', 9 ) 31 * 32 * If you don't setup a default value and don't assign a variable the modifier 31 * 32 * If you don't setup a default value and don't assign a variable the modifier 33 33 * wouldn't be called. 34 * 34 * 35 35 * Available operators are: 36 * 37 * Addition + 38 * Subtraction - 39 * Multiplication * 40 * Division / 41 * Clear the buffer c 36 * 37 * + Addition 38 * - Subtraction 39 * * Multiplication 40 * / Division 41 * c Clear the buffer 42 * sig Return the sign (1 for positive values, 0 for 0, -1 for netagive nums) 43 * abs Return the absolute value of the number 42 44 * 43 45 * @package patTemplate … … 99 101 return null; 100 102 break; 103 case 'sig': 104 if( $buffer[$memory] > 0 ) { 105 return 1; 106 } 107 if( $buffer[$memory] < 0 ) { 108 return -1; 109 } 110 return 0; 111 case 'abs': 112 return abs( $buffer[$memory] ); 101 113 } 102 114
