Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2025, 08:52 AM   #1
JohnAndJane
Junior Member
JohnAndJane began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2025
Location: Germany
Device: Tolino Shine
Problem with template function

Hi,
I want to decide how to construct the filename depending on a tag entry.

Simple code for testing the tags...

Code:
program:
if list_contains(field('tags'), ',', 'Western') then
    strcat('true ->' , field('tags'), '<-')
else
    strcat('false ->' , field('tags'), '<-')
fi
For example two books running in the template function editor gives the following values
Code:
true ->Science Fiction<-
true ->Heftserie, Western<-
But there is something wrong in my code because it returns always true.
So I tried some other code.
Code:
program:
if list_contains(field('tags'), ',', 'Western',1,0) then
    strcat('true ->' , field('tags'), '<-')
else
    strcat('false ->' , field('tags'), '<-')
fi
Same behavior, next try with
Code:
program:
_is_in = list_contains(field('tags'), ',', 'Western',1,0);
shows
Code:
1
0
for the example above. Fine, but if I try to test the variable
Code:
program:
_is_in = list_contains(field('tags'), ',', 'Western',1,0);
if _is_in = 1 then 'true' else 'false' fi
or with
Code:
program:
_is_in = list_contains(field('tags'), ',', 'Western',1,0);
if _is_in then 'true' else 'false' fi
you get
Code:
1
1
for the example above.

Seems to be on a wrong way - someone can help?

Using Calibre 7.26.0 on Win 11 Pro
JohnAndJane is offline   Reply With Quote
Old 03-16-2025, 01:35 PM   #2
JohnAndJane
Junior Member
JohnAndJane began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2025
Location: Germany
Device: Tolino Shine
Solved... == is better than =
JohnAndJane is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changes to template function documentation processing chaley Library Management 6 11-24-2024 07:36 AM
BuiltinAdd template language function DyckBook Editor 4 10-19-2021 04:21 PM
Using built-in template functions in a custom template function ilovejedd Library Management 4 01-28-2018 12:20 PM
Problem with contains function in save template MicaOlaAdams Calibre 5 10-21-2016 10:25 AM


All times are GMT -4. The time now is 04:13 PM.


MobileRead.com is a privately owned, operated and funded community.