View Single Post
Old 04-03-2019, 04:47 AM   #3
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Marco24 View Post
1rst example :
if #genre contains SF or Fantasy or Weird then populate the column with SFFF else empty
Try this General Program Mode template:
Code:
program:
	test(list_intersection('SF, Fantasy, Weird', field('#genre'), ','), 'SFFF', '')
Quote:
another example of test I want to realize :
if #nationalite not in (fr, ca) and #translator is null and #VO-title is null
then #customcolumn = "translation data missing"
else empty
Code:
program:
	test(
		strcat(
			list_intersection('fr, ca', field('#nationalite'), ','),
			field('#translator'),
			field('#VO-title')
		), 
	'', 'translation data missing')
NB: I can't test this template because I don't have the three columns it references.

The template produces output only if the three expressions produce an empty value, determined by concatenating the results of the three expressions.
  • The first, the list_intersection, produces a non-empty value if the field contains one of the two nationalities.
  • The second produces a non-empty value if #translator contains a value.
  • The second produces a non-empty value if #VO-title contain a value.
If the strcat is non-empty (any of the expressions returned a value) then the test produces empty.

In effect, the template implements your expression altered using De Morgan's Laws
Code:
if not (#nationalite in (fr, ca) or #translator is not null or #VO-title is not null)
then "translation data missing"
else empty

Last edited by chaley; 04-03-2019 at 04:51 AM. Reason: Minor fixes
chaley is offline   Reply With Quote