View Single Post
Old 01-21-2022, 02:02 AM   #295
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,098
Karma: 76037135
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
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.

Last edited by ownedbycats; 01-21-2022 at 04:16 AM.
ownedbycats is online now   Reply With Quote