View Single Post
Old 05-29-2025, 05:08 AM   #840
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:
program:

bookformat =
	switch_if(
		'PAPERBOOK' inlist_field 'formats', 'Physical Books',
		('OVERDRIVE' || 'PAPERLOAN') inlist_field 'formats', 'Loans',
		'eBooks');
Test book with only a PAPERLOAN format, returns eBooks. What I do wrong?

EDIT: ('OVERDRIVE' inlist_field 'formats' || 'PAPERLOAN' inlist_field 'formats') works, was hoping to avoid repeated.
inlist and inlist_field have a regular expression on the left hand side. You put a boolean expression. What you want is a regular expression using alternatives.

This should work:
Code:
program:

bookformat =
	switch_if(
		'PAPERBOOK' inlist_field 'formats', 'Physical Books',
		'OVERDRIVE|PAPERLOAN' inlist_field 'formats', 'Loans',
		'eBooks');
chaley is offline   Reply With Quote