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 12-05-2022, 01:36 PM   #436
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks

New quesiton: When checking that a text column value is undefined, is there difference between !$foo and $foo == '', or any reason to prefer one or the other??
ownedbycats is offline   Reply With Quote
Old 12-05-2022, 05:23 PM   #437
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Thanks

New quesiton: When checking that a text column value is undefined, is there difference between !$foo and $foo == '', or any reason to prefer one or the other??
They (should) give the same answer. !$foo is a bit faster because it avoids evaluating the value to be compared.

That said, $#foo == '' can be easier to understand, should self documentation be a goal.
chaley is offline   Reply With Quote
Advert
Old 12-10-2022, 11:57 PM   #438
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I made this template to check for the value of Story Does Not Exist. in one column. If it's present, then generate a new value (based on the publisher) and use list_union to merge it into #admin_tags.
Code:
program:

	if 
		$#fanficerror == "Story Does Not Exist." 
	&& 
		$publisher == 'Archive Of Our Own'
	then
		removedtags = list_item('removedfromsite:ao3',0,',') 

	elif
		$#fanficerror == "Story Does Not Exist." 
	&& 
		$publisher == 'FanFiction.net'
	then
		removedtags = list_item('removedfromsite:ffnet',0,',') 			
	fi;

	list_union($#admin_tags, removedtags, ',')
Running this on a book that doesn't match the checks (e.g. empty $#fanficerror) makes this error:

Code:
EXCEPTION: Interpreter: Unknown identifier 'removedtags' - line number 18
The last time it happened, I was able to use a second if-then check but since there's two of them here I don't think it'll work. Any other suggestions?

EDIT: Perhaps an "else removedtags = {something}" to set it for the non-matches? But I'm not sure what to put for the something.

Last edited by ownedbycats; 12-11-2022 at 12:35 AM.
ownedbycats is offline   Reply With Quote
Old 12-11-2022, 07:33 AM   #439
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Running this on a book that doesn't match the checks (e.g. empty $#fanficerror) makes this error:

Code:
EXCEPTION: Interpreter: Unknown identifier 'removedtags' - line number 18
The last time it happened, I was able to use a second if-then check but since there's two of them here I don't think it'll work. Any other suggestions?

EDIT: Perhaps an "else removedtags = {something}" to set it for the non-matches? But I'm not sure what to put for the something.
I presume you want removedtags to be an empty list. Use
Code:
	else
		removedtags = ''
You could accompany it with this, which might be clearer and would be a bit faster in the case where removedtags is empty.
Code:
	if removedtags then
		list_union($#admin_tags, removedtags, ',')
	else
		$#admin_tags
	fi

Last edited by chaley; 12-11-2022 at 01:37 PM. Reason: Added missing code tags
chaley is offline   Reply With Quote
Old 12-11-2022, 11:01 AM   #440
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks. I also used an empty list for the earlier split_tags and that worked too.
ownedbycats is offline   Reply With Quote
Advert
Old 12-22-2022, 11:17 AM   #441
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Question: Here's a template I use to select, split, and sort hierarchical tags for a #subjects column:

Code:
program:

## Splitting tags
	if 
		'^(Fiction|Nonfiction|Magazines & Periodicals)' in $#booktype 
	then 
		split_tags = re($tags, '\.', ',') 
	else
## empty for other booktypes with more specific columns
		split_tags = ''
	fi;

## Removing a few unwanteds and sorting
	cleaned_tags = list_sort(
		list_difference(
			split_tags,
			'Fiction, Nonfiction, Magazines & Periodicals, Cultures & Regions, Social Issues',
			','), 0, 
		',')
Seeing as my books are always tagged as, e.g.
Fiction.Science Fiction.Space Opera
Nonfiction.Biographies and Memoirs, Nonfiction.Music

I thought it might make sense to change re($tags, '\.', ',') to exclude the 'topmost' (anything to the left of the first period) rather than remove them out after the fact.

a) Would this improve performance? I also have other tags to remove, so I wouldn't be removing the list_difference entirely.
b) What regex would I use? re($tags, '(.*)\.', ',') only semi-worked; I see why but I'm not sure how to properly capture it.

Last edited by ownedbycats; 12-22-2022 at 11:53 AM. Reason: fixing the indenting on template
ownedbycats is offline   Reply With Quote
Old 12-22-2022, 01:35 PM   #442
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question: Here's a template I use to select, split, and sort hierarchical tags for a #subjects column:

[...]

Seeing as my books are always tagged as, e.g.
Fiction.Science Fiction.Space Opera
Nonfiction.Biographies and Memoirs, Nonfiction.Music

I thought it might make sense to change re($tags, '\.', ',') to exclude the 'topmost' (anything to the left of the first period) rather than remove them out after the fact.

a) Would this improve performance? I also have other tags to remove, so I wouldn't be removing the list_difference entirely.
b) What regex would I use? re($tags, '(.*)\.', ',') only semi-worked; I see why but I'm not sure how to properly capture it.
If you are going to call list_difference in any event then there isn't much point to removing the unwanted prefixes earlier in the template. It is more work to remove them then to use the existing list_difference().

For fun, here is a Python template that does what I think you want. I used #genre for both the booktype and tags values.
Code:
python:
def evaluate(book, context):
	t = book.get('#genre') # For you this would be '#booktype'
	# Check if any of the items in the list t startwith one of the values
	if any((s.startswith(('Science Fiction', 'Nonfiction', 'Magazines & Periodicals')) for s in t)):
		# At least one does. Split all the items into single words.
		# You would want the " in t " to be " in book.get('tags')"
		res = {t3 for t2 in t for t3 in t2.split('.')}
		# Remove the undesired items
		res -= set(('Science Fiction', 'Nonfiction', 'Magazines & Periodicals', 'Cultures & Regions', 'Social Issues'))
		# Sort the items then build a comma-separated string of them
	    return ', '.join(sorted(res))
	return ''

Last edited by chaley; 12-24-2022 at 07:48 AM. Reason: Remove doubled "python:" in template.
chaley is offline   Reply With Quote
Old 12-24-2022, 09:34 PM   #443
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Thanks

Quick question. I modified my template to add 'Omnibus' to the beginning of the list for easier searching. Lines 3-12 and 29-30:

Code:
program:

## Checking for omnibus
	if 
		'omnibus' 
	in 
		$#admin_tags 
	then 
		omnibus = 'Omnibus' 
	else 
		omnibus = ''
	fi;

## Splitting tags
	if 
		'^(Fiction|Nonfiction|Magazines & Periodicals)' in $#booktype 
	then 
		split_tags = re($tags, '\.', ',') 
	else
		split_tags = ''
	fi;

## Removing a few unwanteds and sorting
		cleaned_tags = list_sort(list_difference(
			split_tags,
			'Fiction, Nonfiction, Magazines & Periodicals, Cultures & Regions, Social Issues',
			','), 0, ',');

## Last runthrough
	cleaned_tags = list_union(cleaned_tags, omnibus, ',')
two questions:


a) Why does list_union seem to work in reverse? (e.g. if I put 'omnibus' first in template, it appears at the end of the list).

b) Currently, an icon rule checks #admin_tags for 'omnibus.' Would there be any performance impact by checking the composite column instead?

Thanks and merry christmas (or whatever you celebrate)

Last edited by ownedbycats; 12-25-2022 at 01:50 AM.
ownedbycats is offline   Reply With Quote
Old 12-25-2022, 12:33 PM   #444
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
two questions:

a) Why does list_union seem to work in reverse? (e.g. if I put 'omnibus' first in template, it appears at the end of the list).
list_union and several other list operations don't guarantee order.
Quote:
b) Currently, an icon rule checks #admin_tags for 'omnibus.' Would there be any performance impact by checking the composite column instead?
The composite will be slower, possibly much slower. The template must be evaluated for every book being displayed. If it is evaluated in any event, for example to display the computed list, then the performance penalty is much reduced.

FWIW: Since you want Omnibus at the head of the list, I would write the template like this.
Code:
program:
## Splitting tags
	if 
		'^(Fiction|Nonfiction|Magazines & Periodicals)' in $#booktyoe 
	then 
		split_tags = re($tags, '\.', ',') 
	else
		split_tags = ''
	fi;

## Removing a few unwanteds and sorting
	cleaned_tags = list_sort(list_difference(
		split_tags,
		'Fiction, Nonfiction, Magazines & Periodicals, Cultures & Regions, Social Issues',
		','), 0, ',');

## Last runthrough - Checking for omnibus
	if 
		'omnibus' 
	in 
		$tags 
	then 
		cleaned_tags  = 'Omnibus' & if cleaned_tags then ', ' & cleaned_tags fi
	fi;
	cleaned_tags
Quote:
Thanks and merry christmas (or whatever you celebrate)
Thank you. I hope the same (now past tense) for you.
chaley is offline   Reply With Quote
Old 12-26-2022, 11:55 AM   #445
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Is using list_join the preferred way to de-duplicate entries?

context: https://www.mobileread.com/forums/sh...07&postcount=3

edit: I forgot list_remove_duplicates existed

Last edited by ownedbycats; 12-26-2022 at 01:01 PM.
ownedbycats is offline   Reply With Quote
Old 01-02-2023, 05:34 AM   #446
mtjj
Member
mtjj began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Oct 2017
Device: Android, Windows 10
I'm having some trouble with if statements in the template editor for Saving books to disk.

What I want is to handle three different cases:

If the custom column "Admin tags" (admin_tags) contains "#MAS" then

Code:
#MAS/{series}/{series_index:0>2s| - |}{title} ({authors})
Else, if the Series is not blank:

Code:
{author_sort[0]}/{authors}/{series}/{series_index:0>2s| - |}{title}
Else:
Code:
{author_sort[0]}/{authors}/{title}/{title}
This will hopefully give me:
[export folder]/#MAS/Doctor Who New Adventures/04 - Timewyrm Revalation (Paul Cornell).epub
[export folder]/C/Paul Cornell/The Severed Streets/01 - London Falling.epub
[export folder]/C/Paul Cornell/Chalk/Chalk.epub

(ideally the output would be as listed above, so the /C/ is from the author sort and the other outputs are from the non-sort fields, but I don't really care, if everything comes out with sort order, so it's /C/Cornell, Paul/Severed Streets, The/.... I'm also happy.)

I'm trying to setup a single export job that can be picked up by another program, that needs a folder by series (or, if a book is not part of a series, a folder per book). But it has a lot of trouble with multi-author series that end up in different author folders, so I will tag those manually, so they end up in the "#MAS" folder.

Looking at examples above, they seem to be written as programs. Can I put if statements in the simple template format, or I need to re-write it as a program?

Thanks in advance to anyone who can advise!
mtjj is offline   Reply With Quote
Old 01-02-2023, 06:09 AM   #447
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by mtjj View Post
I'm having some trouble with if statements in the template editor for Saving books to disk.

What I want is to handle three different cases:

If the custom column "Admin tags" (admin_tags) contains "#MAS" then

Code:
#MAS/{series}/{series_index:0>2s| - |}{title} ({authors})
Else, if the Series is not blank:

Code:
{author_sort[0]}/{authors}/{series}/{series_index:0>2s| - |}{title}
Else:
Code:
{author_sort[0]}/{authors}/{title}/{title}
This will hopefully give me:
[export folder]/#MAS/Doctor Who New Adventures/04 - Timewyrm Revalation (Paul Cornell).epub
[export folder]/C/Paul Cornell/The Severed Streets/01 - London Falling.epub
[export folder]/C/Paul Cornell/Chalk/Chalk.epub

(ideally the output would be as listed above, so the /C/ is from the author sort and the other outputs are from the non-sort fields, but I don't really care, if everything comes out with sort order, so it's /C/Cornell, Paul/Severed Streets, The/.... I'm also happy.)

I'm trying to setup a single export job that can be picked up by another program, that needs a folder by series (or, if a book is not part of a series, a folder per book). But it has a lot of trouble with multi-author series that end up in different author folders, so I will tag those manually, so they end up in the "#MAS" folder.

Looking at examples above, they seem to be written as programs. Can I put if statements in the simple template format, or I need to re-write it as a program?

Thanks in advance to anyone who can advise!
Yes, you must use General Program Mode to use if statements.

Here is an example ofwhat I think you want to do:
Code:
program:
	if '^#MAS$' inlist $#admin_tags then
		template('#MAS/{series}/{series_index:0>2s| - |}{title} ({authors})')
	elif $series then
		template('{author_sort[0]}/{authors}/{series}/{series_index:0>2s| - |}{title}')
	else
		template('{author_sort[0]}/{authors}/{title}/{title}')
	fi
To head off one question: the value of an if statement is the value of the last statement executed inside the if, in the case the last template() call.

If you want $series and $title to use the non-sort values then change the tweak (Preferences / Tweaks) "Control formatting of title and series when used in templates (ID: save_template_title_series_sorting)". Set it to strictly_alphabetic.

FWIW: You have the ' - ' in the series_index portions of the templates in the wrong place. Your examples say they should go after the second '|' so you get the index, the dash, then the title. Example:
Code:
{series_index:0>2s|| - }
chaley is offline   Reply With Quote
Old 01-02-2023, 06:28 AM   #448
mtjj
Member
mtjj began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Oct 2017
Device: Android, Windows 10
Quote:
Originally Posted by chaley View Post
Yes, you must use General Program Mode to use if statements.

Here is an example ofwhat I think you want to do:
Code:
program:
	if '^#MAS$' inlist $#admin_tags then
		template('#MAS/{series}/{series_index:0>2s| - |}{title} ({authors})')
	elif $series then
		template('{author_sort[0]}/{authors}/{series}/{series_index:0>2s| - |}{title}')
	else
		template('{author_sort[0]}/{authors}/{title}/{title}')
	fi
To head off one question: the value of an if statement is the value of the last statement executed inside the if, in the case the last template() call.

If you want $series and $title to use the non-sort values then change the tweak (Preferences / Tweaks) "Control formatting of title and series when used in templates (ID: save_template_title_series_sorting)". Set it to strictly_alphabetic.

FWIW: You have the ' - ' in the series_index portions of the templates in the wrong place. Your examples say they should go after the second '|' so you get the index, the dash, then the title. Example:
Code:
{series_index:0>2s|| - }
Great, thank you, I'll give it a go....that looks easier than I thought if I can use template(), I thought I'd need to re-do the whole thing!

And yes, I put the ' - ' in the wrong place!

Many thanks!
mtjj is offline   Reply With Quote
Old 01-03-2023, 08:39 PM   #449
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: 11,047
Karma: 75555555
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
As part of a first_non_empty, I have a if-then that checks that:

a) #kobostatus is defined
b) #kobostatus is also not 'Kobo Store'
c) #kobopath is undefined

Code:
if $#kobostatus && !'Kobo Store' in $#kobostatus && !$#kobopath then 'snippets.png' fi
Is there a slightly better way to check the first two?

EDIT: Additional question:

Code:
program: 

days_between(format_date(today(), 'yyyy-MM-dd'), $#fanficupdated);

days_between(today(), $#fanficupdated);
What is the difference between these two lines? On most of the books I tested (but not all of them; perhaps timezone?) there's a difference of 1.

Last edited by ownedbycats; 01-03-2023 at 10:35 PM.
ownedbycats is offline   Reply With Quote
Old 01-04-2023, 07:59 AM   #450
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: 12,456
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
As part of a first_non_empty, I have a if-then that checks that:

a) #kobostatus is defined
b) #kobostatus is also not 'Kobo Store'
c) #kobopath is undefined

Code:
if $#kobostatus && !'Kobo Store' in $#kobostatus && !$#kobopath then 'snippets.png' fi
Is there a slightly better way to check the first two?
Depends on what #kobostatus is. If it is a list then what you have is good. If #kobostatus is a single-valued field (enum perhaps) then
Code:
$#kobostatus != 'Kobo Store'
is faster.
Quote:
EDIT: Additional question:

Code:
program: 

days_between(format_date(today(), 'yyyy-MM-dd'), $#fanficupdated);

days_between(today(), $#fanficupdated);
What is the difference between these two lines? On most of the books I tested (but not all of them; perhaps timezone?) there's a difference of 1.
The second includes the time of day while the first doesn't. The function uses the number of seconds between the values in the calculation. For the first the number of seconds in the first argument is zero. For the second the number of seconds is whatever it is based on the time of day.

If both are complete times (date, time, timezone) then the difference in the time of day will figure in the date arithmetic.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Library Management: various questions not worth their own thread ownedbycats Library Management 225 08-04-2025 06:31 PM
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates Boilerplate4U Development 13 07-07-2020 02:35 AM
Questions on Kobo [Interfered with another thread topic] spdavies Kobo Reader 8 10-12-2014 11:37 AM
[OLD Thread] Some questions before buying the fire. darthreader13 Kindle Fire 7 05-10-2013 09:19 PM
Thread management questions meme Feedback 6 01-31-2011 05:07 PM


All times are GMT -4. The time now is 09:52 AM.


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