View Single Post
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,476
Karma: 8025702
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:	155
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