Quote:
Originally Posted by ownedbycats
EDIT: Commenting out line four makes it return #percentread (expected result). Was it trying to do math even if there was nothing matching for f and s? I guess I need to fix the newpercent bit somehow or rearrange the template so that lines 2-4 run after the 'not set' check.
|
The re() function isn't doing what you think it does. If the regular expression in
Code:
s = re($#chapters, '.*/(.*)', '\1')
matches nothing then s is assigned the value of $#chapters. You need to account for what happens if the pattern doesn't match the value. One way to do it is to verify that there is a '/' in $#chapters before extracting the values and doing the computation.
Yes, it will try to do the math with the values in s and f no matter what those values are.
You can use the debugger and breakpoints to look at the values of the variables and expressions to better get a handle on what your template is doing.