|  10-20-2016, 02:53 PM | #1 | 
| Member  Posts: 22 Karma: 10 Join Date: Oct 2016 Device: Kobo Aura One | 
				
				Problem with contains function in save template
			 
			
			Hi everybody, I set the following save template Code: {#genre:contains(Sachbuch, {title}, {author}_{title})}Now every book that has any of the following characters in its title throws an error Code: , { } ( )Code: ValueError: Failed to calculate path for save to disk. Template: {#genre:contains(Sachbuch, {title}, {authors}_{title})}
    Error: Incorrect number of arguments for function containsAny ideas how to solve this problem? | 
|   |   | 
|  10-20-2016, 05:52 PM | #2 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
			
			Your problem is happening because you didn't respect what it says in the template language manual, "Do not use subtemplates (`{ ... }`) as function arguments." In addition, in single-function-mode spaces are significant. You should include them only where you want them in the output. The most general way to fix this is to use general program mode. Something like Code: program:
	contains(
		field('#genre'),
		'Sachbuch', 
		field('title'), 
		strcat(field('authors'), '_', field('title'))
	) | 
|   |   | 
| Advert | |
|  | 
|  10-21-2016, 03:36 AM | #3 | 
| Member  Posts: 22 Karma: 10 Join Date: Oct 2016 Device: Kobo Aura One | 
			
			Many thanks. I'm still new to this whole template language thing and have overlooked this warning completely. | 
|   |   | 
|  10-21-2016, 05:58 AM | #4 | 
| Member  Posts: 22 Karma: 10 Join Date: Oct 2016 Device: Kobo Aura One | 
			
			I read now the manual, but I still don't understand how I can include a folder structure for a save template in general program mode. E.g. to save books from the "Sachbuch"-genre into /genre/series/title and everything else into /genre/author/title. Maybe somebody could provide a exemplary code. | 
|   |   | 
|  10-21-2016, 06:19 AM | #5 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Code: program:
	middle = contains(
		field('#genre'),
		'Sachbuch', 
		field('series'), 
		field('authors')
	);
	strcat(field('#genre'), '/', middle, '/', field('title')) | 
|   |   | 
| Advert | |
|  | 
|  10-21-2016, 10:25 AM | #6 | 
| Member  Posts: 22 Karma: 10 Join Date: Oct 2016 Device: Kobo Aura One | 
			
			I've been thinking this whole thing backwards   Thanks again!   | 
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| how to use re() function in Template Program Mode? | msciwoj | Library Management | 3 | 07-07-2016 03:55 PM | 
| Save Books to Disk Template Problem | Buckskin | Library Management | 5 | 11-15-2015 11:37 AM | 
| Save template problem | antoon | Library Management | 12 | 08-17-2012 12:47 PM | 
| A little help with a save template...? | Belfaborac | Library Management | 2 | 02-04-2011 09:47 PM | 
| problem to save with customize template | Roxro | Library Management | 4 | 01-22-2011 07:37 AM |