View Single Post
Old 12-20-2021, 10:08 AM   #233
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,110
Karma: 77213681
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Also, a question regarding doing math in mixed-use composite columns:

I have a composite column, #chapters, which pulls from integer #chaptercount and provides formatted output. One of those is showing how many chapters of a fanfic I've read (pulled from the Kobo bookmarks column). Another of the outputs is "Not Set" if I haven't set a #chaptercount.

I have an action in one of my action chains that checks the #chapters column to see if there's unread chapter and then changes the #percentread from 100 => 98 if so.

If it matters, #chapters is set to sort by text.

Code:
program:
f = re($#chapters, '(.*)/.*', '\1');
s = re($#chapters, '.*/(.*)', '\1');

	if and(
		$$#fanficcat,
		check_yes_no('#onkobo', '', 1, 1),
		$$#percentread ==#100,
		(s - f) ==# 1
	)

	then '98'
	
	else $$#percentread
	
	fi

This fails with "not set" books. Template tester says could not convert string to float: 'Not Set' Which then breaks the chain when running on books with unset chaptercounts -- I'm guessing from trying to do the math.

I tried adding a $#chapters != 'Not Set', to the checks, but that didn't work. Any idea what I missed?

EDIT: I think I figured it out. I should've set the 'not set' check as a separate check first. Then if it passed make another if with the other checks. Something like this (I probably messed up the indents.)

Code:
program:
f = re($#chapters, '(.*)/.*', '\1');
s = re($#chapters, '.*/(.*)', '\1');

	if 
		$#chapters != 'Not Set'
		then if and(
		$$#fanficcat,
		check_yes_no('#onkobo', '', 1, 1),
		$$#percentread ==#100,
		(s - f) ==# 1
	) 

	then '98'

	
	else $$#percentread
	
	fi 
		fi

Last edited by ownedbycats; 12-20-2021 at 10:19 AM.
ownedbycats is offline   Reply With Quote