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, 07:19 AM   #796
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: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
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, 08:58 AM   #797
capink
Wizard
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: 1,081
Karma: 1948136
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 10:36 AM. Reason: include chaley's solution
capink is offline   Reply With Quote
Old 01-14-2022, 09:03 AM   #798
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: 11,703
Karma: 6658935
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
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, 10:34 AM   #799
capink
Wizard
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: 1,081
Karma: 1948136
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 01:01 PM.
capink is offline   Reply With Quote
Old 01-14-2022, 05:30 PM   #800
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
That worked. Thank you
ownedbycats is online now   Reply With Quote
Old 01-15-2022, 07:19 PM   #801
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
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, 08:11 PM   #802
capink
Wizard
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: 1,081
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Spaces are not allowed in variable names.
capink is offline   Reply With Quote
Old 01-22-2022, 10:51 PM   #803
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
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 01-23-2022, 06:39 AM   #804
capink
Wizard
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: 1,081
Karma: 1948136
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:	58
Size:	19.3 KB
ID:	191803  

Last edited by capink; 01-24-2022 at 12:12 PM.
capink is offline   Reply With Quote
Old 01-27-2022, 07:46 PM   #805
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Is it possible to use a module to set a variable?

Context: Mostly as curiosity/to figure out how the code works, I wanted to see if I could make a modification of this chain that, instead of raise chain.UserInterrupt when clicking 'no,' instead sets a specified variable to a specified value on clicking 'yes'. That could then be used in a chain modifier to enable a specific action.

Similar to the attached chain, but with a yes/no dialog in place of typing in 'yes' manually.
Attached Files
File Type: zip ToggleMarkOnYes.zip (594 Bytes, 51 views)

Last edited by ownedbycats; 01-28-2022 at 07:25 AM.
ownedbycats is online now   Reply With Quote
Old 01-29-2022, 10:24 AM   #806
capink
Wizard
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: 1,081
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
Is it possible to use a module to set a variable?

Context: Mostly as curiosity/to figure out how the code works, I wanted to see if I could make a modification of this chain that, instead of raise chain.UserInterrupt when clicking 'no,' instead sets a specified variable to a specified value on clicking 'yes'. That could then be used in a chain modifier to enable a specific action.

Similar to the attached chain, but with a yes/no dialog in place of typing in 'yes' manually.
Code:
chain.set_chain_vars({'my_var_name': 'false'})
capink is offline   Reply With Quote
Old 01-29-2022, 07:57 PM   #807
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
It works. Thank you.

Just for confirming something I noticed: Are variable values case-sensitive?

Last edited by ownedbycats; 01-29-2022 at 09:45 PM.
ownedbycats is online now   Reply With Quote
Old 01-29-2022, 11:14 PM   #808
ownedbycats
Custom User Title
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: 8,419
Karma: 59666665
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Also, silly question: Where exactly in single-field edit is the "add format from predefined path"? I only see the option to remove formats.
Attached Thumbnails
Click image for larger version

Name:	2022-01-30 04_47_40-Single Field Edit.png
Views:	58
Size:	15.6 KB
ID:	192006  

Last edited by ownedbycats; 01-30-2022 at 03:49 AM.
ownedbycats is online now   Reply With Quote
Old 01-30-2022, 08:09 AM   #809
capink
Wizard
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: 1,081
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
It works. Thank you.

Just for confirming something I noticed: Are variable values case-sensitive?
Yes. They are case-sensitive.
capink is offline   Reply With Quote
Old 01-30-2022, 08:10 AM   #810
capink
Wizard
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: 1,081
Karma: 1948136
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
Also, silly question: Where exactly in single-field edit is the "add format from predefined path"? I only see the option to remove formats.
I was going to include that option and decided not to, since it can be done from the template option.

Last edited by capink; 01-30-2022 at 08:55 AM.
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
[Editor Plugin] Editor Chains capink Plugins 80 03-09-2024 12:30 PM
Action Chains Resources capink Plugins 54 01-29-2024 11:24 PM
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB lrpirlet Plugins 2 08-18-2022 03:15 PM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 05:25 AM


All times are GMT -4. The time now is 08:53 AM.


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