View Single Post
Old 01-29-2022, 04:41 AM   #316
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
Code:
if select(ids, 'url') then
	if 
		'(Archive of Our Own|Fanfiction.net)' in $publisher 
		&& '(Completed|Abandoned|Oneshot|Incomplete)' in status
	then "metadata.png"

	elif
		!select(ids, 'ao3')
		&& $publisher == 'Archive of Our Own' 
		&& status == 'In-Progress'
		then 'metadata.png' 
	
	elif 
		!select(ids, 'ffnet')
		&& $publisher == 'FanFiction.net'
		&& status == 'In-Progress'
		then "metadata.png" 
	fi 
fi
Would it be able to combine the two bottom elifs into one? Regex (ao3|ffnet) is one way, but is there a way to keep the id/publisher pair separate from each other?
I think you mean something like this:
Code:
program:
	if 
		'(Archive of Our Own|Fanfiction.net)' in $publisher 
		&& '(Completed|Abandoned|Oneshot|Incomplete)' in status
	then "metadata.png"

	elif	(!select(ids, 'ao3')
		 && $publisher == 'Archive of Our Own' 
		 && status == 'In-Progress' )
	      ||
		(!select(ids, 'ffnet')
		 && $publisher == 'FanFiction.net'
		 && status == 'In-Progress')
	then
		"metadata.png" 
	fi
Quote:
EDIT: Another question:

Attachment 191967

Did I somehow accidentally turn it into last_non_empty?
No. But by using a semicolon instead of a comma you turned the two 'if' statements into a single statement sequence, not two parameters. The value of a statement sequence is the last statement in the sequence, in your case the authors if.

It should look like this:
Code:
program:
	first_non_empty(
		if $title then 'title' fi, <==== comma here
		if $authors then 'authors' fi
	)
chaley is offline   Reply With Quote