View Single Post
Old 11-24-2022, 09:27 PM   #430
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: 11,104
Karma: 77213681
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program:

## Splitting tags
	if 
		'^(Fiction|Nonfiction)' in $#booktype 
	then 
		split_tags = re($tags, '\.', ',') 
	fi;

## Removing a few unwanteds
	cleaned_tags = list_difference(
		split_tags,
		'Fiction, Nonfiction, Cultures & Regions, Social Issues',
		',');
Three things this template to do:
1. Retrieve tags when the booktype is Fiction|Nonfiction.
2. Replace the '.' with a ',' to turn hierarchical tags into a list.
3. Remove a few unwanted entries from the list.

It works... mostly. If booktype is not Fiction|Nonfiction, it returns EXCEPTION: Interpreter: Unknown identifier 'split_tags' - line number 12. What should I do?

EDIT: I found that also adding a second if-then check for Fiction|Nonfiction before cleaning the tags works.

Last edited by ownedbycats; 11-25-2022 at 06:50 AM.
ownedbycats is offline   Reply With Quote