Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 01-14-2022, 08:19 AM   #796
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,108
Karma: 3858661
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by ownedbycats View Post
Regarding:
Code:
program:
	totalpage = $#pagecount;
	pagenum = globals(pagenum);
	newpercent = round(multiply ((totalpage / pagenum), 100));
"globals" is like "arguments", not really a function. You should say
Code:
globals(pagenum);
not
Code:
pagenum = globals(pagenum);
In your case it works by accident because globals returns the value it assigns to the last argument. It would stop working if you said
Code:
pagenum = globals(pagenum, foobar);
chaley is offline   Reply With Quote
Old 01-14-2022, 09:58 AM   #797
capink
Guru
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 706
Karma: 211790
Join Date: Aug 2015
Device: Kindle
OK, I think I understand what is happening to you now. Since you are still trying to configure an action without having run the chain, the value of pagenum is an empty string (chain variables are only assigned at runtime, even without the runtime option ticked).

So, at this point in time, the value of pagenum (empty string) cannot be used in mathematical operations, and the template evaluator will return an error and you will not be able to save it. To remedy this:

Code:
program:
   pagenum = ifempty(globals(pagenum), 1)
   pagenum = globals(pagenum=1)
This will give the evaluator a valid default, and the template should be accepted. You can use any numerical value, except ZERO, as you are using it as the denominator.

Last edited by capink; 01-14-2022 at 11:36 AM. Reason: include chaley's solution
capink is offline   Reply With Quote
Old 01-14-2022, 10:03 AM   #798
chaley
Grumpy old git
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.
 
chaley's Avatar
 
Posts: 10,108
Karma: 3858661
Join Date: Jan 2010
Location: UK
Device: Reader
Quote:
Originally Posted by capink View Post
OK, I think I understand what is happening to you now. Since you are still trying to configure an action without having run the chain, the value of pagenum is an empty string (chain variables are only assigned at runtime, even without the runtime option ticked).
@capink: do the chain variables actually have the value of '', or are they undefined? If they are undefined then this will work:
Code:
    globals(pagenum=1)
chaley is offline   Reply With Quote
Old 01-14-2022, 11:34 AM   #799
capink
Guru
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 706
Karma: 211790
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by chaley View Post
@capink: do the chain variables actually have the value of '', or are they undefined? If they are undefined then this will work:
Code:
    globals(pagenum=1)
They are undefined. Your solution is better . I totally forgot about this.

Edit: Chain Variables documentation updated.

Last edited by capink; 01-14-2022 at 02:01 PM.
capink is offline   Reply With Quote
Old 01-14-2022, 06:30 PM   #800
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,395
Karma: 14100982
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
That worked. Thank you
ownedbycats is online now   Reply With Quote
Old 01-15-2022, 08:19 PM   #801
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,395
Karma: 14100982
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
quick question: Does the variable name need to be One_String_Without_Any_Spaces? I tried changing it to "Current Page" and couldn't get that into the template without an error. Current_Page works though.
ownedbycats is online now   Reply With Quote
Old 01-15-2022, 09:11 PM   #802
capink
Guru
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 706
Karma: 211790
Join Date: Aug 2015
Device: Kindle
Spaces are not allowed in variable names.
capink is offline   Reply With Quote
Old 01-22-2022, 11:51 PM   #803
ownedbycats
Wizard
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 3,395
Karma: 14100982
Join Date: Oct 2018
Device: Kobo Aura HD (retired), Kobo Libra H2O
Question: How does Action Chains treat Calibre Action dialogs?

Does the chain wait until I press ok/cancel to close the dialog, or proceed running in the background?
ownedbycats is online now   Reply With Quote
Old Yesterday, 07:39 AM   #804
capink
Guru
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 706
Karma: 211790
Join Date: Aug 2015
Device: Kindle
It depends on the dialog itself.
  • For dialogs that block the main thread (e.g. Edit Metadata Dialog), action chains will naturally wait until the dialog finishes and hands back control of the main thread.
  • For dialogs that do not block the main thread (e.g. progress bar dialogs, but other dialogs might do the same), but instead act from another thread, action chains will immediately proceed to the next action, even before the dialog finishes. This is almost always undesirable, hence, the option in Calibre Actions to wait for the dialog until it finishes. (see attachment).
    Note that this involves guesswork, and is sometimes susceptible to breaking as per the warning in the screenshot.
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	11
Size:	19.3 KB
ID:	191803  

Last edited by capink; Today at 01:12 PM.
capink is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] KindleUnpack - The Plugin DiapDealer Plugins 484 01-14-2022 01:49 PM
[GUI Plugin] Manga plugin mastertea Plugins 6 01-06-2022 03:43 AM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 06:25 AM
[GUI Plugin] Wordpress frescogamba Plugins 11 04-06-2015 10:09 PM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 01:27 PM


All times are GMT -4. The time now is 11:05 PM.


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