Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-27-2021, 06:43 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: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Template: Indenting

I made a template. It works but I think I indented it wrong. Where should I put the indents?

Code:
program:
 if 
		and(check_yes_no('#read', '', '1', ''),
		raw_field('#percentread') ==# 100,
		field('rating'),) 
		then 	'Yes' 
		else field('#read')
	fi
Context: In FanFicFare, I have it set #read to 'no' when updating a fanfic. But this also runs when I am using 'update metadata' on previously-read fanfics, for instance to update series numbers. This just sets it back to 'yes' if it's 100% read and has a rating. I put it my Cleanup: Fanfiction action chain.


Last edited by ownedbycats; 03-27-2021 at 06:46 PM.
ownedbycats is offline   Reply With Quote
Old 03-27-2021, 07:03 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I made a template. It works but I think I indented it wrong. Where should I put the indents?
Wherever you want to.
Quote:
Code:
program:
 if 
		and(check_yes_no('#read', '', '1', ''),
		raw_field('#percentread') ==# 100,
		field('rating'),) 
		then 	'Yes' 
		else field('#read')
	fi
(Context: In FanFicFare, I have it set #read to 'no' when updating a fanfic. But this also runs when I am using 'update metadata' on previously-read fanfics. This just sets it back to yes.)

My first answer was serious. You indent however it makes sense for you. Really.

I would indent your template differently because of what makes sense for *me*. I try to put 'things' that are syntactically at the same level at the same indent. What is 'syntactically at the same level'? Whatever I want it to be.

This is how I would indent your template.
Code:
program:
	if 
		and(
			check_yes_no('#read', '', '1', ''),
			raw_field('#percentread') ==# 100,
			field('rating')
		) 
	then
		'Yes' 
	else
		field('#read')
	fi
Using the new operators & field syntax I would write
Code:
program:
	if	check_yes_no('#read', '', '1', '') &&
		$$#percentread ==# 100 &&
		$rating 
	then
		'Yes' 
	else
		$#read
	fi
It looks like this screen capture in the template tester I am currently working on.

Click image for larger version

Name:	Clipboard01.jpg
Views:	154
Size:	50.3 KB
ID:	186182

Edit: "Break on print" is my first stab at putting breakpoints into the template tester. If you check the box then the template is evaluated only when you click "Go" (mouse or keyboard). In this case if the template processor encounters a "print" then it pauses evaluation and opens a dialog showing you the arguments of the print and all the local variables. You can click "Go" to continue evaluating the template or "Stop" to cancel evaluation. My goal is to permit "breaks" at line numbers but I haven't yet figured out how to that.

Last edited by chaley; 03-27-2021 at 07:15 PM.
chaley is offline   Reply With Quote
Advert
Old 03-27-2021, 07:18 PM   #3
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: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thank you.

BTW, the new multi-result template editor makes it a lot easier to figure the templates. Thank you.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Template: Converting a search & replace into a template ownedbycats Library Management 11 03-26-2021 04:32 AM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Indenting first line of paragraph jimvde Workshop 3 07-22-2013 04:16 AM


All times are GMT -4. The time now is 01:46 AM.


MobileRead.com is a privately owned, operated and funded community.