Page 2 of 2

Re: Sort cards

Posted: Thu Nov 02, 2017 10:34 pm
by Tomalain
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

Re: Sort cards

Posted: Thu Nov 02, 2017 11:40 pm
by dunbarx
Good.

You can tighten up excess spaces in several ways. One good one is something like this:
repeat for each word tWord in it
put tWord & space after temp
end repeat
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?

C'mon, Jacque, just a little?

Craig

Re: Sort cards

Posted: Fri Nov 03, 2017 3:40 am
by bogs
dunbarx wrote: Thu Nov 02, 2017 11:40 pm C'mon, Jacque, just a little?
You know, I heard she has a little something tucked away in her secret files... :twisted:

Re: Sort cards

Posted: Fri Nov 03, 2017 9:57 am
by Tomalain
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

Re: Sort cards

Posted: Fri Nov 03, 2017 2:39 pm
by dunbarx
@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

Re: Sort cards

Posted: Fri Nov 03, 2017 5:02 pm
by bogs
:oops: putting on my dunce cap, and moving to the corner :oops:

Re: Sort cards

Posted: Fri Nov 03, 2017 6:00 pm
by MaxV
Tomalain wrote: Fri Nov 03, 2017 9:57 am 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
Did you specify the sortType?

Re: Sort cards

Posted: Fri Nov 03, 2017 7:39 pm
by dunbarx
@ Max. I had mentioned the sortType in an earlier post, when speaking about the field "annee".

@ Tomalain. But Max's point bears examination.

Craig

Re: Sort cards

Posted: Fri Nov 03, 2017 7:46 pm
by Tomalain
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

Re: Sort cards

Posted: Fri Nov 03, 2017 8:15 pm
by dunbarx
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

Re: Sort cards

Posted: Fri Nov 03, 2017 9:29 pm
by jacque
dunbarx wrote: Fri Nov 03, 2017 2:39 pmJacque 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.
Just this once then. I will grit my teeth and move on. :P

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