![]() |
#1 |
Member
![]() Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Functions not found when used in Export script
Hello, I made a function to make the correct folder name on disk or book.
I have the result in a column, which shows the correct content. However, when I try to use that column in the export script I get an error in the file names. The function call for the column is this: {title:folderOnDevice({#genre},{series},{series_in dex},{#max_number_in_series},10)} The other needed columns (genre and max_number_in_series) are correct too. The column is called: folder_on_device_10 When I use this script for output, it does show the correct output: {#genre} When I use this script for output: {#folder_on_device_10} I get this file: folderOnDevice_ onbekende functie (onbekende functie means: unknown function) Please help me to put the files in the correct place on my devices!! Is this a bug which will be resolved soon? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,346
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I am not sure what you mean by "export script". Also, I am confused by the term "function call".
From what I can tell, you have a composite custom column called "folder_on_device_10". The template for that column is Code:
{title:folderOnDevice({#genre},{series},{series_index},{#max_number_in_series},10)} First comment: you should not use template references inside function arguments. There are many ways that this breaks. I consider it a bug that it works at all, but people have asked me not to fix it. Instead of template references, you should be using one of the program modes. Given that your function does not use title, you should probably use general program mode. Your function would look something like: Code:
program:folderOnDevice(field('#genre'), field('series'), field('series_index'), field('#max_number_in_series'),10) |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Member
![]() Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Thanks for helping!!
However, when I use what you wrote, I get an error: SJABLOONFOUT Formatter: incorrect number of arguments for function folderOnDevice dichtbij ) With "Export" I meant save to disk (Having the Dutch language I have to translate every item, sorry for that...) But I think this will not work when sending to device. Could you please give me the definition for this function? (correct parameters are enough, I think) Currently I have this: Code:
def evaluate(self, formatter, kwargs, mi, locals, val, genretext, serietext, number_in_series, max_number_in_series, aantal_menu_items): titletext=val try: aant_mi = int(aantal_menu_items) except: return 'aantal_menu_items is geen aantal!' if number_in_series is None: num_in_serie = 0 else: try: num_in_serie = int(number_in_series) except: num_in_serie = 0 #return 'number_in_series is geen aantal!' MaxAantInSerie = 0 if num_in_serie > 0: if max_number_in_series is None: MaxAantInSerie = num_in_serie else: try: MaxAantInSerie = int(max_number_in_series) except: MaxAantInSerie = num_in_serie # return 'max_number_in_series is niet ingevuld!' s = '' DoeBerekening = 1 if MaxAantInSerie == 0: DoeBerekening = 0 if num_in_serie == 0: DoeBerekening = 0 #return 'MaxAantInSerie={0}, num_in_serie={1}, DoeBerekening={2}'.format(MaxAantInSerie, num_in_serie, DoeBerekening) if DoeBerekening == 1: #try: # Menu structuur aanbrengen f = num_in_serie - 1 f1 = f / aant_mi f2 = f1 / aant_mi f3 = f2 / aant_mi f4 = f3 / aant_mi f5 = f4 / aant_mi # Aantal items dat per menudiepte kan worden geplaatst items_in_menu_diepte1 = aant_mi items_in_menu_diepte2 = items_in_menu_diepte1 * aant_mi items_in_menu_diepte3 = items_in_menu_diepte2 * aant_mi items_in_menu_diepte4 = items_in_menu_diepte3 * aant_mi items_in_menu_diepte5 = items_in_menu_diepte4 * aant_mi # Bereken diepst benodigde niveau max_mi_diepte=5 if MaxAantInSerie <= items_in_menu_diepte5: max_mi_diepte=4 if MaxAantInSerie <= items_in_menu_diepte4: max_mi_diepte=3 if MaxAantInSerie <= items_in_menu_diepte3: max_mi_diepte=2 if MaxAantInSerie <= items_in_menu_diepte2: max_mi_diepte=1 if MaxAantInSerie <= items_in_menu_diepte1: max_mi_diepte=0 # Bereken de van.. tot per menudiepte voor betreffende boek fl1 = f1 * items_in_menu_diepte1 + 1 fh1 = (f1 + 1) * items_in_menu_diepte1 fl2 = f2 * items_in_menu_diepte2 + 1 fh2 = (f2 + 1) * items_in_menu_diepte2 fl3 = f3 * items_in_menu_diepte3 + 1 fh3 = (f3 + 1) * items_in_menu_diepte3 fl4 = f4 * items_in_menu_diepte4 + 1 fh4 = (f4 + 1) * items_in_menu_diepte4 fl5 = f5 * items_in_menu_diepte5 + 1 fh5 = (f5 + 1) * items_in_menu_diepte5 # Zorg ervoor dat de hoogste niet meer wordt dan het maximum in de serie if fh1 > MaxAantInSerie: fh1 = MaxAantInSerie if fh2 > MaxAantInSerie: fh2 = MaxAantInSerie if fh3 > MaxAantInSerie: fh3 = MaxAantInSerie if fh4 > MaxAantInSerie: fh4 = MaxAantInSerie if fh5 > MaxAantInSerie: fh5 = MaxAantInSerie # Bepaal aantal cijfers benodigd om maximum vast te houden ac=1 if MaxAantInSerie>9: ac=2 if MaxAantInSerie>99: ac=3 if MaxAantInSerie>999: ac=4 if MaxAantInSerie>9999: ac=5 # Bepaal hier de feitelijke string voor de menustructuur acs='{0:02}'.format(ac) #Levert een string op zoals: 01 of 02 if max_mi_diepte == 0: #1-10 s = '' if max_mi_diepte > 1: #1-100, dus gelijk al 2 diep: 001-100/001-010, 001-100/011-020, ... 101-200/101-110 s = serietext + ' {2:' + acs + '}-{3:' + acs + '}' + '/{0:' + acs + '}-{1:' + acs + '}' if max_mi_diepte > 2: s = serietext + ' {4:' + acs + '}-{5:' + acs + '}' + '/' + s if max_mi_diepte > 3: s = serietext + ' {6:' + acs + '}-{7:' + acs + '}' + '/' + s if max_mi_diepte > 4: s = serietext + ' {8:' + acs + '}-{9:' + acs + '}' + '/' + s #if max_mi_diepte > 5: # s = serietext + ' {10:' + acs + '}-{11:' + acs + '}' + '/' + s #return 'ac={0}, MaxAantInSerie={1}, max_mi_diepte={2}, s={3}'.format(ac,MaxAantInSerie,max_mi_diepte,s) s = s.format(fl1,fh1,fl2,fh2,fl3,fh3,fl4,fh4,fl5,fh5) #return 'items_in_menu_diepte: 1={0}, 2={1}, 3={2}, 4={3}; aant_menu_nodig_voor_max_serie={4}; max_mi_diepte={5}; s={6}'.format(items_in_menu_diepte1,items_in_menu_diepte2,items_in_menu_diepte3,items_in_menu_diepte4,aant_menu_nodig_voor_max_serie,max_mi_diepte,s); #except: # pass # return 'OEPS!' if genretext != '': genretext = genretext + '/' if serietext != '': serietext = serietext + '/' if (genretext + serietext != '') and (s != ''): s = s + '/' return genretext + serietext + s so this is the manual for Calibre itself, right? If you can point me to any place where the construction 'program:' is used, please do so! Last edited by Arco Witter; 09-23-2011 at 09:46 AM. |
![]() |
![]() |
![]() |
#4 | |||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,346
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
That function requires six arguments: val, genretext, serietext, number_in_series, max_number_in_series, aantal_menu_items. The example in your first post implies that 'val' is really title. Using this assumption, and further assuming template program mode, you would call it something like Code:
{title:folderOnDevice($, field('#genre'), field('series'), field('series_index'), field('#max_number_in_series'),10)'} Code:
program: folderOnDevice(field('title'), field('#genre'), field('series'), field('series_index'), field('#max_number_in_series'),10) Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
I do have the column correctly now.
However, save to disk still does not work. I tried this: Code:
program:folderOnDevice(field('#genre'), field('series'), field('series_index'), field('#max_number_in_series'),10) Code:
{#folder_on_device_10} When I do the save to disk itself, I get these filenames: Code:
#folder_on_device_10.jpg #folder_on_device_10.mobi #folder_on_device_10.opf #folder_on_device_10.pdf I can't think of anything to make this work... Hopefully you do! |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,346
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
There is indeed a problem with using user-defined functions in save-to-disk and send-to-device templates. Unfortunately, it isn't easy to fix. The problem is that the template functions are stored in the library, which is not available within the save/send jobs. I need to find a way to pass these functions without breaking anything. This needs some thought.
|
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Good to see that we're up on something!
Now the solution :P (Since I am a programmer myself (though Delphi) I might be of some service?) |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,346
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Fix is in the 'trunk' source and will be in the next release.
And thanks for offering to help. ![]() |
![]() |
![]() |
![]() |
#9 |
Member
![]() Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Nice to see how quick this problem is solved!
Let's hope this is the working solution. (Can't wait to see the upcoming version) Thanks! |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Most often used calibre functions | thearr | Calibre | 17 | 08-07-2011 02:44 PM |
New functions | poco06 | Calibre | 4 | 05-01-2010 01:39 PM |
Can I use all Kindle functions outside USA? | khanhtm | Amazon Kindle | 11 | 01-04-2010 08:15 AM |
Changing Button functions | vadindot | iRex | 3 | 03-26-2009 10:49 AM |
Cybook not found in linux, found in win XP | fjf | Bookeen | 15 | 01-18-2008 06:57 PM |