![]() |
#16 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Hey @chaley I have another question for you.
I follow multiple shows where one of the main characters will have the same of a similar name that is shortened to the same tag on AO3. For example "Lex" being used as a short for Alexandra, Alex, Alexander, Lexa etc. combine this that some shows are crossing over into others it makes for a mess with the tags, so I want to clean this up by building in another if statement that the show needs to contain both show A and Show B. So far I got as far as this: Code:
program: output = ''; for item in $#pair: if $#show == "show A, Show B" then if item == "ABC/XYZ" then ni = "AAA / BBB" elif item == "DEF/UVW" then ni = "CCC / DDD" else ni = item fi; output = output & ',' & ni rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') EXCEPTION: Formatter: if statement: expected 'fi', found 'rof' near Unknown on line 13 So I understand there needs to be another 'fi' as to end the if statement, but I've tried adding it in number of places but it just does not change the fact I keep getting errors. I was hoping you could give me a hint in the right direction. |
![]() |
![]() |
![]() |
#17 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: output = ''; for item in $#pair: if $#show == "show A, Show B" then if item == "ABC/XYZ" then ni = "AAA / BBB" elif item == "DEF/UVW" then ni = "CCC / DDD" fi else ni = item fi; output = output & ',' & ni rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
|
![]() |
![]() |
Advert | |
|
![]() |
#18 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Quote:
Code:
program: output = ''; for item in $#pair: if $#show == "show A, Show B" then if item == "ABC/XYZ" then ni = "AAA / BBB" elif item == "DEF/UVW" then ni = "CCC / DDD" else ni = item fi else ni = item fi; output = output & ',' & ni rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') That means the first if statment should be something like: Code:
if $#show contains item "show A" and "Show B" then
Code:
if $#show != "Show A" && "Show B" then Last edited by ackomb; 12-31-2022 at 08:54 AM. Reason: small error in the code |
|
![]() |
![]() |
![]() |
#19 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Are you looking for code that tells you if both "Show A" and "Show B" are in the list, perhaps along with other values such as "Show C"? If so and if you can guarantee that there are no duplicates in the list then this works. Code:
program: show = list_count_matching($#show, '^(Show A|Show B)$', ',') == 2 output = ''; for item in $#pair: if show then if item == "ABC/XYZ" then ni = "AAA / BBB" elif item == "DEF/UVW" then ni = "CCC / DDD" else ni = item fi else ni = item fi; output = output & ',' & ni rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') Code:
program: show = list_count(list_intersection($#show, 'Show A, Show B', ','), ',') == 2 [code as above] |
|
![]() |
![]() |
![]() |
#20 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Quote:
I am very grateful for people like you. I will try this, thanks again. |
|
![]() |
![]() |
Advert | |
|
![]() |
#21 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Quote:
Trying either of these 2 options actually gives me the following error: EXCEPTION: Formatter: Expected end of program, found 'output' near Unknown on line 3 |
|
![]() |
![]() |
![]() |
#22 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
This happened because I can't test the completed templates because I don't have the right variables with the right values. |
|
![]() |
![]() |
![]() |
#23 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
No worries happy with the help. I should have actually seen that, even if I'm still a amateur at all of this code business.
|
![]() |
![]() |
![]() |
#24 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Is there a way to continue to the next item on the tag list when the first statement is true without actually adding a separate action to the action chain?
I have a number of books that have a large number of crossovers and pairings that I want to change in one action rather then setting up multiple actions for each pairing only slowing things down. I know 'NEXT' won't work but it is to who what I'd like to do. Code:
program: show1 = list_count_matching($#show, '^(Show A|Show B)$', ',') == 2; show2 = list_count_matching($#show, '^(Show A|Show B)$', ',') == 2; output = ''; for item in $#pair: if show1 then if item == "ABC/XYZ" then ni = "AAA / BBB" else ni = item fi else ni = item fi; NEXT if show2 then if item == "KLM/NOP" then ni = "EEE/ FFF" else ni = item fi else ni = item fi; output = output & ',' & ni rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
![]() |
![]() |
![]() |
#25 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
I am not sure exactly what you are trying to do but I think this might lead you to what you want. I can't guarantee that it will run in your context. Code:
program: # As you wrote it, show1 and show2 always have the same value. I think # you mean this. show1 = '^Show A$' inlist $#show; show2 = '^Show B$' inlist $#show; output = ''; for item in $#pair: if show1 then if item == "ABC/XYZ" then output = output & ',' & "AAA / BBB" else output = output & ',' & item fi; # I am not sure exactly where you want the loop to go to the next interation. # This seems like a reasonable guess continue fi; if show2 then if item == "KLM/NOP" then output = output & ',' & "EEE/ FFF" else output = output & ',' & item fi; continue fi; # Put more of the test blocks here, e.g., show3, show4, etc # If we get here then none of the test blocks were true. Add the item. output = output & ',' & item rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
|
![]() |
![]() |
![]() |
#26 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Quote:
So in this case both titles have the same tag "Alex / Liv" in one instance in combination with shows ABC & GHI and in the other ABC & JKL resulting in 2 different pairings (one with female Alexandra and the other mail Alexander However show3 is supposed to change "Jo / Maggy" into "Josefine / Maggie" and "JoJo" into "Josefine / Joe" for the first title only. However the way it works now is that it only hits the 1st tag under both titles and then skips the remaining. Code:
program: show1 = '^ABC$' inlist $#show && '^GHI$' inlist $#show; show2 = '^DEF$' inlist $#show && '^GHI$' inlist $#show; show3 = '^ABC$' inlist $#show && '^JKL$' inlist $#show; output = ''; for item in $#ao3tags_pair: if show1 then if item == "Alex / Liv" then output = output & ',' & "Alexandra / Olivia" else output = output & ',' & item fi; continue fi; if show2 then if item == "Alex / Liv" then output = output & ',' & "Alexander / Olivia" else output = output & ',' & item fi; continue fi; if show3 then if item == "Jo / Maggy" then output = output & ',' & "Josefine / Maggie" elif item == "JoJo" then output = output & ',' & "Josefine / Joe" else output = output & ',' & item fi; continue fi; output = output & ',' & item rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') Ps. I've had to add/remove some semicolons here and there to make it work in the first place, just so you know. And also I could not get the previous code with the Code:
show1 = list_count_matching($#show, '^(Show A|Show B)$', ',') == 2; |
|
![]() |
![]() |
![]() |
#27 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I am really confused about what input becomes what output. Are you saying that more than one of show1, show2, and show3 might be true for some book? If that is the case the 'continue' statements shouldn't be where they are, and perhaps shouldn't be in the template at all.
What I really need is a list of examples showing the value of #show, the value of #ao3tags_pair, and the expected output. EDIT: for example, it appears that for "Title 1" both show2 and show3 are true, and further that in the show3 case both "Jo / Maggy" and "JoJo" exist for the book. If this is true then the show3 block can't have the elif, but instead must probably be two blocks. Last edited by chaley; 01-01-2023 at 02:49 PM. |
![]() |
![]() |
![]() |
#28 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Does this produce the right answer? I added the show and ao3tags_pair variables so I could run the template.
Code:
program: show = $#show # show = 'ABC, JKL, GHI'; show1 = '^ABC$' inlist show && '^GHI$' inlist show; show2 = '^DEF$' inlist show && '^GHI$' inlist show; show3 = '^ABC$' inlist show && '^JKL$' inlist show; output = ''; ao3tags_pair = $#ao3tags_pair # ao3tags_pair = 'Alex / Liv, Jo / Maggy, JoJo'; for item in ao3tags_pair: ni = ''; if show1 then if item == "Alex / Liv" then ni = "Alexandra / Olivia" fi fi; if show2 then if item == "Alex / Liv" then ni = "Alexander / Olivia" fi fi; if show3 then if item == "Jo / Maggy" then ni = "Josefine / Maggie" elif item == "JoJo" then ni = "Josefine / Joe" fi fi; if ni then output = output & ',' & ni else output = output & ',' & item fi rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
![]() |
![]() |
![]() |
#29 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
|
Okay I understand it might be best to give some clarity or at least I hope this gets more clear.
Show "Supergirl" - Character "Alex Danvers" Show "Law and Order" - Character "Alex Cabot" Show "Law and Order" - Character "Olivia Benson" Show "Criminal Minds" - Character "Emily Prentiss" Show "Pretty Little Liars" - Character "Emily Fields" Let's say the tag is "Alex / Emily" If the shows are a crossover between "Criminal Minds" and "Law and Order" the tag "Alex / Emily" becomes "Emily Prentiss / Alex Cabot" If the shows are a crossover between "Pretty Little Liars" and "Law and Order" the tag "Alex / Emily" becomes "Emily Fields / Alex Cabot" However if either is follow by another tag for example "Olivia / Alex" it won't change into "Alex Danvers / Olivia Benson" based on the show "Supergirl" and "Law and Order" So for Title 1 both show1 and show3 are true and for Title 2 both show2 and show3 are true Code:
program: show1 = '^Criminal Minds$' inlist $#show && '^Law and Order$' inlist $#show; show2 = '^Pretty Little Liars$' inlist $#show && '^Law and Order$' inlist $#show; show3 = '^Supergirl$' inlist $#show && '^Law and Order$' inlist $#show; output = ''; for item in $#ao3tags_pair: if show1 then if item == "Alex / Emily" then output = output & ',' & "Emily Prentiss / Alex Cabot" else output = output & ',' & item fi; continue fi; if show2 then if item == "Alex / Emily" then output = output & ',' & "Emily Fields / Alex Cabot" else output = output & ',' & item fi; continue fi; if show3 then if item == "Olivia / Alex" then output = output & ',' & "Alex Danvers / Olivia Benson" else output = output & ',' & item fi; continue fi; output = output & ',' & item rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
![]() |
![]() |
![]() |
#30 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
This seems to work. You will need to uncomment line 5 and line 14. After that you should delete line 13 and lines 1-4, which are there so I can test the template.
Code:
program: # show = 'Criminal Minds, Law and Order'; # show = 'Pretty Little Liars, Law and Order, Supergirl'; show = 'Criminal Minds, Law and Order, Supergirl'; # show = $#show; show1 = '^Criminal Minds$' inlist show && '^Law and Order$' inlist show; show2 = '^Pretty Little Liars$' inlist show && '^Law and Order$' inlist show; show3 = '^Supergirl$' inlist show && '^Law and Order$' inlist show; output = ''; ao3tags_pair = 'Alex / Emily, Olivia / Alex'; # ao3tags_pair = $#ao3tags_pair; for item in ao3tags_pair: ni = ''; if show1 then if item == "Alex / Emily" then ni = "Emily Prentiss / Alex Cabot" fi fi; if show2 then if item == "Alex / Emily" then ni = "Emily Fields / Alex Cabot" fi fi; if show3 then if item == "Olivia / Alex" then ni = "Alex Danvers / Olivia Benson" fi fi; if ni then output = output & ',' & ni else output = output & ',' & item fi rof; output = list_sort(list_remove_duplicates(output, ','), 0, ',') |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Jumping to items in book list without activating keyboard shortcuts | ownedbycats | Library Management | 7 | 01-26-2021 03:22 PM |
Commas Following List Items | TheArtfulDodger | Library Management | 3 | 07-15-2018 06:33 PM |
All my documents from "My Items" list on Kindle Touch disappeared | kinkle | Kindle Developer's Corner | 33 | 03-02-2016 02:42 PM |
Recipe for Safari "Reading List" unread items | anoved | Recipes | 6 | 03-19-2013 01:21 PM |
Cant remove items from "Im Reading" list | fictionaddiction | Kobo Reader | 1 | 06-21-2011 12:11 PM |