When I run the following template on a book that has "Not Set" in my #chapters (composite) column, it gives me
EXCEPTION: could not convert string to float: 'Not Set'.
I thought that the check on line 7 would prevent it. Did I make a mistake and leave out an else or misunderstand the != compare?
Code:
program:
f = re($#chapters, '(.*)/.*', '\1');
s = re($#chapters, '.*/(.*)', '\1');
newpercent = round(multiply ((f / s), 100));
if
$#chapters != 'Not Set'
then
## updates #percentread for updated fanfics comparing no. of read chapters to total.
## fanfic_unreadchaps() check for unread chaps based on kobo bookmark.
if and(
fanfic_unreadchaps(),
$$#percentread ==#100,
)
then
if
newpercent <#99
then
newpercent
else
98
fi
else
$$#percentread
fi
else $$#percentread
fi
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.