View Single Post
Old 05-04-2021, 05:59 PM   #7
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Related to this: I am trying to remove "Crossover" from fanfics that technically aren't crossovers:

Code:
program:
	f = $#fanficcat;
	if 
		contains(
			f, '^Crossover, Mass Effect Trilogy, Mass Effect: Andromeda$', '1', ''
		)
	then 
		'Mass Effect Trilogy, Mass Effect: Andromeda' 
	elif
		contains(
			f, '^Crossover, Half-Life, Portal$', '1', ''
		)	
		then 'Half-Life, Portal' 
	else
		$#fanficcat;
	fi
However, this fails on two fronts:

1. In template tester, it only works if the tags are in that exact order. Since it appears sorted in book details it's hard to tell.
2. Putting this in Action Chains' single-field edit on a book that tested fine just results in the column becoming empty.

Any idea how to do this?
The function list_difference() removes items, but it isn't clear what you want to do. Are you asking to remove 'Crossover' if #fanficcat contains some other items, and possibly only those items? What exactly are the rules?

EDIT: writing down the rules can help with formulating the correct expressions. If you run into situations where the answer is "It depends" then you aren't done.
chaley is offline   Reply With Quote