Sort cards
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Sort cards
Hi Jean-Marc
OK Done with this handler:
on mouseUp
Answer "Séquence de tri des cartes bibliothèque:" with "Année" or "Auteur" or "Numéro"
If it = "Année" then
put "Tri "&it
sort cards by field "Année" of group "BG-Livre"
else
if it = "Auteur" then
put "Tri "&it
sort cards by field "Auteur" of group "BG-Livre"
else
put "Tri "&it
sort cards by field "No" of group "BG-Livre"
end if
end if
beep
ask "Fin du Tri "&it
end mouseUp
Now it operates, result is not completely correct, but due to unexpected spaces in fields
Thanks to all of you for the advices,
Alain
OK Done with this handler:
on mouseUp
Answer "Séquence de tri des cartes bibliothèque:" with "Année" or "Auteur" or "Numéro"
If it = "Année" then
put "Tri "&it
sort cards by field "Année" of group "BG-Livre"
else
if it = "Auteur" then
put "Tri "&it
sort cards by field "Auteur" of group "BG-Livre"
else
put "Tri "&it
sort cards by field "No" of group "BG-Livre"
end if
end if
beep
ask "Fin du Tri "&it
end mouseUp
Now it operates, result is not completely correct, but due to unexpected spaces in fields
Thanks to all of you for the advices,
Alain
-
- VIP Livecode Opensource Backer
- Posts: 9582
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Sort cards
Good.
You can tighten up excess spaces in several ways. One good one is something like this:
C'mon, Jacque, just a little?
Craig
You can tighten up excess spaces in several ways. One good one is something like this:
But know that this will only really work with single lines, which is what I assume your fields contain. If you read the handler, you will see that returns, for example, are deleted. Does this help? If not, can you propose a way to simply lose extra spaces but keep all other control characters intact?repeat for each word tWord in it
put tWord & space after temp
end repeat
C'mon, Jacque, just a little?
Craig
Re: Sort cards
Hi,
thanks to Craig and Jean-Marc,
My Sort now operates, but I remain suspicious: the SORT command seams to be not predictable, and not stable over the releases of LC.
Concerning spaces, thanks for the suggestion, I will reinforce checking at data entry
Alain
thanks to Craig and Jean-Marc,
My Sort now operates, but I remain suspicious: the SORT command seams to be not predictable, and not stable over the releases of LC.
Concerning spaces, thanks for the suggestion, I will reinforce checking at data entry
Alain
-
- VIP Livecode Opensource Backer
- Posts: 9582
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Sort cards
@Tomalain
I bet that there still are small glitches in the stack, not in the command.
@ Bogs.
Jacque believes that we should never task new users with what I used to call homework. I was asking if just this one time I could.
Craig
I bet that there still are small glitches in the stack, not in the command.
@ Bogs.
Jacque believes that we should never task new users with what I used to call homework. I was asking if just this one time I could.
Craig
Re: Sort cards
putting on my dunce cap, and moving to the corner
Re: Sort cards
Did you specify the sortType?Tomalain wrote: ↑Fri Nov 03, 2017 9:57 amHi,
thanks to Craig and Jean-Marc,
My Sort now operates, but I remain suspicious: the SORT command seams to be not predictable, and not stable over the releases of LC.
Concerning spaces, thanks for the suggestion, I will reinforce checking at data entry
Alain
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- VIP Livecode Opensource Backer
- Posts: 9582
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Sort cards
@ Max. I had mentioned the sortType in an earlier post, when speaking about the field "annee".
@ Tomalain. But Max's point bears examination.
Craig
@ Tomalain. But Max's point bears examination.
Craig
Re: Sort cards
Hi,
As sort type I used "Numeric" for field supposed to contain number ("No"), and later suppressed this parameter.
I will re-introduce when I will be sure all spaces cleared
probably yes, a small glitch in the stack, no idea what it could be
thanks
Alain
As sort type I used "Numeric" for field supposed to contain number ("No"), and later suppressed this parameter.
I will re-introduce when I will be sure all spaces cleared
probably yes, a small glitch in the stack, no idea what it could be
thanks
Alain
-
- VIP Livecode Opensource Backer
- Posts: 9582
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Sort cards
Alain, note that there is a native "dateTime" sortKey for your field "annee".
We must all be careful when sorting dates, numbers and text, and VERY careful when sorting combinations of those data types.
Craig
We must all be careful when sorting dates, numbers and text, and VERY careful when sorting combinations of those data types.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7215
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Sort cards
Just this once then. I will grit my teeth and move on.
Since plain "sort" only looks at the beginning of the text, it might be faster to loop through the lines. This will trim leading and trailing spaces:
Code: Select all
function stripSpaces pList
repeat for each line L in pList
put word 1 to -1 of L & cr after tList
end repeat
return tList
end stripSpaces
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com