View Single Post
Old 02-04-2022, 08:46 AM   #329
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,509
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Silly question:

I have this rule in emblems:

Code:
program: 

	first_non_empty(
		icons_cleanup_metadata(),
		icons_cleanup_missingids(),
		icons_cleanup_fanfic(),
		icons_marked(),
		if 'Cleanup' in virtual_libraries() then 'polish.png' fi
	)
[...]
Is there a better option than first_non_empty? For now, I'm using if is_marked() then 'nope' fi as that won't render anything.
You can use a series of ifs like this:
Code:
program: 
	if 	v = icons_cleanup_metadata() then v
	elif	v = icons_cleanup_missingids() then v
	elif	v = icons_cleanup_fanfic() then v
	elif	v = icons_marked() then v
	elif   'Cleanup' in virtual_libraries() then 'polish.png'
	fi
It stops at the first condition that is true, returning whatever v is even if it is empty.

With your change the icons_marked line would become
Code:
	elif	is_marked() then ''
The condition is true so it returns the empty string.

The two 'tricks' are:
  • The value of an if statement is the value of a then or else block. That is why it has the value of the first evaluated then block.
  • Use the embedded assignment so you don't need to call the function (stored template) twice or can return whatever you want as you do in the last elif.
chaley is offline   Reply With Quote