| 
			
			 | 
		#136 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			It worked  
		
	
		
		
		
		
		
		
		
		
		
		
	
	 
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#137 | |
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  
		Last edited by ownedbycats; 07-07-2021 at 05:36 AM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#138 | |||
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Quote: 
	
 In general, for a sequence of && clauses put them in the order you expect them to most often fail. For a sequence of || clauses put them in the order you expect them to most often succeed. Quote: 
	
 Code: 
	strcat(format_number(subtract(a, 1), '{0:,d}'), '/',ccount)
Code: 
	strcat(format_number(re(input, '.*\/file(\d+).*', '\1') - 1, '{0:,d}'), '/',ccount)
Last edited by chaley; 07-07-2021 at 01:35 PM. Reason: Fix shortcutting  | 
|||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#139 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			That worked.  
		
	
		
		
		
		
		
		
		
		
		
		
	
	  I swapped the order of the bookmark check and the status check. Also I didn't realize it was possible to avoid calling subtract.
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#140 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			For columns specifically, does commented out template code have any affect on performance? e.g. before the virtual_libraries() thing got fixed, would commenting it out just have it skip entirely or calculate the result and then toss it out?
		 
		
	
		
		
		
		
		
		
		
		
		
		
		
			Last edited by ownedbycats; 07-09-2021 at 06:27 PM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#141 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#142 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Question: 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I have this template in an Action Chains single-field edit for semi-automated updating of my Kobo collection/shelf column: Code: 
	program:
	g = field('#genres');
	k = field('#kobocoll');
	vl = field('#vls');
	v = first_non_empty(
		list_contains(vl, ',', '^Loans$', 'Loans', ''),
		list_contains(g, ',', '^Fanfiction$', 'Fanfiction', ''),
		list_contains(g, ',', '^Horses$', 'Horses', ''),
		list_contains(g, ',', '^Cozy Mystery$', 'Cozy Mysteries', ''),
		list_contains(g, ',', '^(Fantasy|Science Fiction)$', 'Fantasy & Sci-Fi', ''),
	);
	list_union(k, v, ',')
 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#143 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	'OVERDRIVE' inlist approximate_formats() If you use any of the formats_???() functions then the time needed to touch the disk to check the physical files will swamp any template processing time.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#144 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Question: for my composite chapter count column: 
		
	
		
		
			Is it possible, with a template, to display icon only if the first number is one less than the second? 1/2 - icon.png 2/2 - no icon 99/100 - icon.png 50/100 - no icon 50 - no icon If it helps, here's the composite. It pulls the numbers from #chaptercount and #kobobookmark: Code: 
	program:
input = $#kobobookmark;
status = $#fanficstatus;
ccount = $$#chaptercount;
	if 
		$#fanficcat
	then
		if		
				substr(input, 0, 10) == 'OEBPS/file'
			&& 	
				!status inlist 'Anthology,Oneshot'
		then		
			strcat(format_number(re(input, '.*\/file(\d+).*', '\1') - 1, '{0:,d}'), '/',ccount)
		else
			ccount
		fi
	elif
		ccount == 'None'
	then
		'Not Set'
	elif
		ccount >#1
	then
		ccount
	fi
Last edited by ownedbycats; 08-23-2021 at 05:49 AM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#145 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	program: t = $#tool; if '/' in t then f = re(t, '(.*)/.*', '\1'); s = re(t, '.*/(.*)', '\1'); if f <# s then 'icon.png' fi fi  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#146 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Thank you. That also seems to get the 50/100 example though. I'll see if math functions might help here.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#147 | |
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Code: 
	program: t = $#tool; if '/' in t then f = re(t, '(.*)/.*', '\1'); s = re(t, '.*/(.*)', '\1'); if (s - f) ==# 1 then 'icon.png' fi fi  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#148 | 
| 
			
			
			
			 Custom User Title 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,359 
				Karma: 79528341 
				Join Date: Oct 2018 
				Location: Canada 
				
				
				Device: Kobo Libra H2O, formerly Aura HD 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			I actually managed to come up with pretty much the same thing before seeing your post. Thank you.  
		
	
		
		
		
		
		
		
		
		
		
		
	
	 
		 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#149 | 
| 
			
			
			
			 Connoisseur 
			
			![]() Posts: 95 
				Karma: 10 
				Join Date: Jun 2011 
				Location: Albany NY 
				
				
				Device: Moonreader+ 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			This is a repost as I posted in the wrong thread 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I'm a complete nube in calibre template language. I'm trying to take the output of the plugin Pagecount which is the number of words in a book and dividing that by 320 which is my words per minute reading rate and output the total number of minutes to read the book into my custom integer col "#minutes" I don't know how to assign the product of divide(vals, 320); to my custom column #minutes. program: col = '#pagecount'; vals = from_selection(col); '#minutes' = divide(vals, 320); But I get this result EXCEPTION: Formatter: Expected end of program, found '=' near '#minutes' on line 4  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#150 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,216 
				Karma: 1995558 
				Join Date: Aug 2015 
				
				
				
				Device: Kindle 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			from_selection() is used in Action Chains Formula action to perform mathematical operations that needs input from more than one book. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Templates for composite columns only work for mathematical operations that pulls the data from one book at at time. If I understand what you want to do correctly, your template should look like this: Code: 
	program:
    $$#pagecount / 320
 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Library Management: various questions not worth their own thread | ownedbycats | Library Management | 253 | 10-21-2025 09:15 AM | 
| [Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 03:35 AM | 
| Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 12:37 PM | 
| [OLD Thread] Some questions before buying the fire. | darthreader13 | Amazon Fire | 7 | 05-10-2013 10:19 PM | 
| Thread management questions | meme | Feedback | 6 | 01-31-2011 06:07 PM |