View Single Post
Old 06-24-2021, 05:46 PM   #1
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,064
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Template: Extracting a number from a string

I have two columns, text #kobobookmark and integer #chaptercount.

I'd like to create a new column to keep track of read chapters in a fanfic, e.g. 5/25.

I thought the best way to do that is a GPM template that
a) checks a book is a fanfic, is currently being read, and has something in #kobobookmark to count,
b) extract the number of read chapters from #kobobookmark,
c) display that number next to #chaptercount.

I managed to get the first part working already:

Code:
program:
	if 
			$#fanficcat 
		&& 
			$#currentlyreading 
		&& 
			$#kobobookmark
	then
		$#chaptercount
	fi
Unfortunately the implementation of b and c I'm a bit stuck on. The bookmarks are always in a string similar to this:

OEBPS/file0003.xhtml#kobo.1.1

The "0003.xhtml" means that it's currently on chapter 3. What would be the best way to get the number and display it as '3/{#chaptercount} chapters read'?


Last edited by ownedbycats; 06-24-2021 at 07:11 PM.
ownedbycats is online now   Reply With Quote