Page 1 of 1

DCBROWSECOL SORT On an Array

Posted: Sun Mar 25, 2012 8:08 am
by GeneB
I am doing a massive Clipper conversion and have converted to dozens of DCBROWSE on arrays. I realize now that to go back and add DCBROWSECOL SORT that I would need to browse a dbf not an array.

Is there a way to use Sort on an array browse? Perhaps use Asort() in the SORT codeblock ?
Can't find an example or any posts on this forum.
Just wondering if it is possible or do I go back in a cave and begin rewriting dozens of Browses.

Re: DCBROWSECOL SORT On an Array

Posted: Sun Mar 25, 2012 11:06 am
by sdenjupol148
Hey GeneB,

Easy to do.
Just use ASort() within your SORT clause as in:

#DEFINE FIRST_NAME 1
#DEFINE LAST_NAME 2

aNames := { {"Roger", "Donnay"}, {"Gene","B"}, {"Bobby",Drakos"}}

DCBROWSECOL HEADER "Last Name";
ELEMENT LAST_NAME WIDTH 10 ;
TOOLTIP "Person's Last Name" ;
SORT {|| ASort(aNames,,,{|a,b| a[DUE_MEDNUM] < b[DUE_MEDNUM] })}


Bobby

Re: DCBROWSECOL SORT On an Array

Posted: Sun Mar 25, 2012 2:23 pm
by GeneB
Thanks, Bobby, that works perfectly.

As a point of information, when I was first trying to use it I left OrdSetFocus() in the block for the first element as shown because that column would sort as in the example but it didn't seem to let other columns sort.

You have saved me many, many hours.
The more I discover new features in Express the more impressed I am. It is an amazing product, and this forum is priceless.

GeneB