Sort cards
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Sort cards
Hello,
beginners with LC, I got a problem with a handler which was working well, but after some updates (which ones?) does not function anymore.
Clicking the button to sort, nothing happening
The script is:
on mouseUp
Answer "Séquence de tri des cartes bibliothèque:" with "Année" or "Auteur"
or
"Numéro"
If it = "Année" then sort cards by field "Année" of bg "BG-Livre"
else
if it = "Auteur" then sort cards by field "Auteur" of bg "BG-Livre"
else sort cards by field "No" of bg "BG-Livre"
end if
beep
ask "Fin du Tri "&it
end mouseUp
Could it deal with Group?
Thanks for any help
Tomalain
beginners with LC, I got a problem with a handler which was working well, but after some updates (which ones?) does not function anymore.
Clicking the button to sort, nothing happening
The script is:
on mouseUp
Answer "Séquence de tri des cartes bibliothèque:" with "Année" or "Auteur"
or
"Numéro"
If it = "Année" then sort cards by field "Année" of bg "BG-Livre"
else
if it = "Auteur" then sort cards by field "Auteur" of bg "BG-Livre"
else sort cards by field "No" of bg "BG-Livre"
end if
beep
ask "Fin du Tri "&it
end mouseUp
Could it deal with Group?
Thanks for any help
Tomalain
Re: Sort cards
Hi.
Your handler compiles without issue.
Is the group present on all cards? It has to be.
But I have no idea what is in the fields that the "sort" command is using as a sortKey, so I have no idea how they should work. The contents of those fields ("Année" and "Auteur") , whether in a group or not, will determine the nature of the resultant sorting. That is why the referenced fields have to be on every card in the sort, otherwise any card without that field will be neglected.
Sometimes you want to neglect certain cards, but that is another story.
Craig Newman
Your handler compiles without issue.
Is the group present on all cards? It has to be.
But I have no idea what is in the fields that the "sort" command is using as a sortKey, so I have no idea how they should work. The contents of those fields ("Année" and "Auteur") , whether in a group or not, will determine the nature of the resultant sorting. That is why the referenced fields have to be on every card in the sort, otherwise any card without that field will be neglected.
Sometimes you want to neglect certain cards, but that is another story.
Craig Newman
Re: Sort cards
Welcome to this forum, Bienvenue (I speak french and a little bit "Lemanic's english)
I tried your script and i discover it works with "group" instead "bg". I also replaced ask with answer at the end
Best regards
Jean-Marc
I tried your script and i discover it works with "group" instead "bg". I also replaced ask with answer at the end
Code: Select all
on mouseup
Answer "Séquence de tri des cartes bibliothèque:" with "Année" or "Auteur" or "Numéro" or "Annuler"
if it = empty then exit mouseup
If it = "Année" then sort cards by field "Année" of group "BG-Livre"
else
if it = "Auteur" then sort cards by field "Auteur" of group "BG-Livre"
else sort cards by field "No" of group "BG-Livre"
end if
beep
answer "Fin du Tri "&it --
end mouseup
What about "script debug mode" of "Development" menu ?Clicking the button to sort, nothing happening
Best regards
Jean-Marc
https://alternatic.ch
Re: Sort cards
Jean-Marc.I tried your script and i discover it works with "group" instead "bg".
These are synonyms, no? Did it NOT work with "group"?
Craig
Re: Sort cards
thank you jean-marc for your suggestions, I am afraid it's a problem with Groups.
I had to modify the original group adding more controls, and it's rather a nightmare.
It may happen that not all cards have the same bg definition ?
I will try the debug mode
I tried to attach the stack but this is rejected.
I had to modify the original group adding more controls, and it's rather a nightmare.
It may happen that not all cards have the same bg definition ?
I will try the debug mode
I tried to attach the stack but this is rejected.
Re: Sort cards
Group can work like a background (background behavior = true) or not and shared or not,
If it background behavior = true this group is placed automaticaly when you create a new cd (it become also shared in this case).
If you modify a background, it will modified in all card which have this background.
Please note that the script of a background commes between cd script and stack script in the messages hierarchy.
I believe you can post a zip of a stack after you posted 10 messages
Best
Jean-Marc
If it background behavior = true this group is placed automaticaly when you create a new cd (it become also shared in this case).
If you modify a background, it will modified in all card which have this background.
Please note that the script of a background commes between cd script and stack script in the messages hierarchy.
I believe you can post a zip of a stack after you posted 10 messages
Best
Jean-Marc
https://alternatic.ch
Re: Sort cards
Hi Craig,
Jean-Marc
I thought but it doesn't work without error when i use "bg" instead "group" (LC 8.1.6)These are synonyms, no? Did it NOT work with "group"?
Jean-Marc
https://alternatic.ch
Re: Sort cards
Hi
Reply to Craig's advices,
Thank you Craig, The field "Année" contains Year on 4 digits, while "Auteur" is the Author of the book, alphanumeric.
The field "No" is a number , from 1 to 1000, normally numeric, but some field contain left space.
Presently the sort command does not work at all, neither on field "No" nor "Auteur".
Is the some property in the Group that prevent its field to be seen by the sort command?
I believe the best I have to do is to write a Handler which export all cards (about 1000) and another one to reload the stack.
Then can I be sure that every card will have the same (correct?) background.
Alain
Reply to Craig's advices,
Thank you Craig, The field "Année" contains Year on 4 digits, while "Auteur" is the Author of the book, alphanumeric.
The field "No" is a number , from 1 to 1000, normally numeric, but some field contain left space.
Presently the sort command does not work at all, neither on field "No" nor "Auteur".
Is the some property in the Group that prevent its field to be seen by the sort command?
I believe the best I have to do is to write a Handler which export all cards (about 1000) and another one to reload the stack.
Then can I be sure that every card will have the same (correct?) background.
Alain
Re: Sort cards
No, don't do anything rash quite yet. Sorting by the contents of a field is old magic.
LC will use the contents of each field on each card as a sortKey. If a field does not appear on a card, it is ignored. This can either be useful or annoying.
It is the field reference that matters; it makes no difference to which group that field belongs to or not.
So the field "Annee" contains a plain four digit number? If in the message box:
what happens? Try again with field "Auteur" (no numeric). What happens?
You can scramble the card order at any time so that you can see if the above commands do their job by:
Craig
LC will use the contents of each field on each card as a sortKey. If a field does not appear on a card, it is ignored. This can either be useful or annoying.
It is the field reference that matters; it makes no difference to which group that field belongs to or not.
So the field "Annee" contains a plain four digit number? If in the message box:
Code: Select all
sort cards numeric by field "Annee"
You can scramble the card order at any time so that you can see if the above commands do their job by:
Code: Select all
sort cards by random(999)
Re: Sort cards
Hi Alain,
Craig,
Yes it also works with fld "Auteur"
Jean-Marc
You may verify this with a script which get the id of group "BG-Livre" in each cd.Then can I be sure that every card will have the same (correct?) background.
Craig,
Yes it also works with fld "Auteur"
Jean-Marc
Last edited by jmburnod on Thu Nov 02, 2017 6:13 pm, edited 1 time in total.
https://alternatic.ch
Re: Sort cards
"Group" and "bg" can be interchangeable sometimes but are not always synonyms. Group refers to the card level and bg to the stack level. Asking if there is a grp x or there is a bg x will both return true if there is a shared group with background behavior on the current card. You'll get different responses if the group isn't currently placed on the card: there will not be a grp x but there will be a bg x.
Sorting cards requires inspecting the groups on each card, which is why "bg" won't work here.
There is also a difference in the message path. Groups with background behavior receive messages after the card gets them, while card groups get messages before the card does.
Sorting cards requires inspecting the groups on each card, which is why "bg" won't work here.
There is also a difference in the message path. Groups with background behavior receive messages after the card gets them, while card groups get messages before the card does.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Sort cards
tested "sort cards by random(999)" using the message box,... works well, ... cards get random
try then my handler, called from a "Home" card, nothing happens, as the sort would be ignored. The handler is launched. Same for all 3 sort options.
One question,
is it necessary to specify that field "No" belongs to bg 'BG-Livre"
some trial show that it works as well without
sort card by field "Auteur" behave as sort card by field "Auteur" of bg "BG-Livre"
(when the sort operates !
Alain
try then my handler, called from a "Home" card, nothing happens, as the sort would be ignored. The handler is launched. Same for all 3 sort options.
One question,
is it necessary to specify that field "No" belongs to bg 'BG-Livre"
some trial show that it works as well without
sort card by field "Auteur" behave as sort card by field "Auteur" of bg "BG-Livre"
(when the sort operates !
Alain
Re: Sort cards
Tomalain
With all the information you have, you should know that sorting by using a field reference will work, regardless of whether that field belongs to a group or not, and whether or not that group is a backGround group.
The sortKey is the field itself.
If you are having issues, it must be that the field is not present on all cards. Such cards will sort before any others that do indeed contain the sort field. LC will sort such a card as if the field was there, but was empty.
Or perhaps the data in that field is not what you expect?
What do you see when you try the handler? Is there simply no sort at all, or a sort different from what you expect?
Craig
With all the information you have, you should know that sorting by using a field reference will work, regardless of whether that field belongs to a group or not, and whether or not that group is a backGround group.
The sortKey is the field itself.
If you are having issues, it must be that the field is not present on all cards. Such cards will sort before any others that do indeed contain the sort field. LC will sort such a card as if the field was there, but was empty.
Or perhaps the data in that field is not what you expect?
What do you see when you try the handler? Is there simply no sort at all, or a sort different from what you expect?
Craig
Re: Sort cards
Alain,
Please, replace "bg" with "group" in your script
Jean-Marc
No, if you have only one fld "no"is it necessary to specify that field "No" belongs to bg 'BG-Livre"
Please, replace "bg" with "group" in your script
Jean-Marc
https://alternatic.ch
Re: Sort cards
Hello Graig,
Thanks
there is no sort at all
I tried with the Handler i Posted, but also from the message box
and from a button specially created on a card
Nothing
The only sort I got is the random one from the message box
Thanks
there is no sort at all
I tried with the Handler i Posted, but also from the message box
and from a button specially created on a card
Nothing
The only sort I got is the random one from the message box