View Single Post
Old 02-26-2011, 12:41 PM   #6
Doug-W
Member
Doug-W began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Feb 2011
Device: Nook
Quote:
Originally Posted by chaley View Post
The documentation is correct for the section it is in, single function mode. In that mode, the 'value' is always the field named in the beginning of the template and is never supplied as an argument, no argument is quoted, and spaces are significant. In template program mode or general program mode, the 'value' (first) argument must be provided and all constant arguments must be quoted. In template program mode, the variable '$' is assigned the value of the field used in the template. For example, for {series:'test($, 'A', 'B')'} the $ will be assigned the value contained in the field 'series'.
But that's the only section that describes test. There's no description on that page of test where it takes 3 values. Indeed nothing in template programming mode section which introduces the $ concept indicates which of the functions introduced in single function mode would now take an additional parameter of the field the expression is to operate on. Would I be correct in assuming that every function introduced in the previous section will take a new 1st parameter which can be '$'?


My confusion was thinking that $ wasn't a default variable but was rather the regex expression for end of line, which would always be true.

Combined with this example:
Quote:
# Set the save template to {series:lookup(.,AA,BB)}. This template chooses composite field AA if series is not empty, and composite field BB if series is empty. We therefore have two completely different save paths, depending on whether or not series is empty.
Which does use a regex for the first parameter, I was just marveling at a different way of expressing a concept of 'always match' vs 'always match if not empty' is all.
Doug-W is offline   Reply With Quote