I have built an array being displayed in an xbrowse. It lists accounts in numberic order (account numbers). I'd like to display the list in alpha order (account title). Element no 1 is "account no", element 2 is "title".
Thanks in advance.
Array in alpha order
Re: Array in alpha order
A Example :
PRIVATE aBARSTYLE[11][2]
aBARSTYLE[1] := { " 1", "Gradient" }
aBARSTYLE[2] := { " 2", "Brush" }
aBARSTYLE[3] := { " 3", "Image" }
aBARSTYLE[4] := { " 4", "Color" }
aBARSTYLE[5] := { " 5", "Office" }
aBARSTYLE[6] := { " 6", "Crystal" }
aBARSTYLE[7] := { " 7", "Office 3D" }
aBARSTYLE[8] := { " 8", "Crystal 3D" }
aBARSTYLE[9] := { " 9", "Bricks" }
aBARSTYLE[10] := { "10", "Tiled" }
aBARSTYLE[11] := { "11", "Borland" }
aBARST := ASORT ( aBARSTYLE, , , {|x,y| x[2] < y[2] } )
aBARSTYLE := aBARST
![Image](http://www.pflegeplus.com/pictures/arraysort.jpg)
Best regards
Uwe![Laughing :lol:](./images/smilies/icon_lol.gif)
PRIVATE aBARSTYLE[11][2]
aBARSTYLE[1] := { " 1", "Gradient" }
aBARSTYLE[2] := { " 2", "Brush" }
aBARSTYLE[3] := { " 3", "Image" }
aBARSTYLE[4] := { " 4", "Color" }
aBARSTYLE[5] := { " 5", "Office" }
aBARSTYLE[6] := { " 6", "Crystal" }
aBARSTYLE[7] := { " 7", "Office 3D" }
aBARSTYLE[8] := { " 8", "Crystal 3D" }
aBARSTYLE[9] := { " 9", "Bricks" }
aBARSTYLE[10] := { "10", "Tiled" }
aBARSTYLE[11] := { "11", "Borland" }
aBARST := ASORT ( aBARSTYLE, , , {|x,y| x[2] < y[2] } )
aBARSTYLE := aBARST
![Image](http://www.pflegeplus.com/pictures/arraysort.jpg)
Best regards
Uwe
![Laughing :lol:](./images/smilies/icon_lol.gif)
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Array in alpha order
Nice example.
But if anyway we are using XBrowse, we can allow xbrowse to do the sorting instead of ourselves doing it.
Another way using command syntax
But if anyway we are using XBrowse, we can allow xbrowse to do the sorting instead of ourselves doing it.
Code: Select all | Expand
#include "Fivewin.ch"
#include "xbrowse.ch"
function main()
local aBARSTYLE[11][2], oWnd, oBrw
aBARSTYLE[1] := { " 1", "Gradient" }
aBARSTYLE[2] := { " 2", "Brush" }
aBARSTYLE[3] := { " 3", "Image" }
aBARSTYLE[4] := { " 4", "Color" }
aBARSTYLE[5] := { " 5", "Office" }
aBARSTYLE[6] := { " 6", "Crystal" }
aBARSTYLE[7] := { " 7", "Office 3D" }
aBARSTYLE[8] := { " 8", "Crystal 3D" }
aBARSTYLE[9] := { " 9", "Bricks" }
aBARSTYLE[10] := { "10", "Tiled" }
aBARSTYLE[11] := { "11", "Borland" }
DEFINE WINDOW oWnd
oBrw := TXBrows():New( oWnd )
oBrw:SetArray( aBarStyle, .t., 2 )
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd
return nil
Another way using command syntax
Code: Select all | Expand
#include "Fivewin.ch"
#include "xbrowse.ch"
function main()
local aBARSTYLE[11][2], oWnd, oBrw
aBARSTYLE[1] := { " 1", "Gradient" }
aBARSTYLE[2] := { " 2", "Brush" }
aBARSTYLE[3] := { " 3", "Image" }
aBARSTYLE[4] := { " 4", "Color" }
aBARSTYLE[5] := { " 5", "Office" }
aBARSTYLE[6] := { " 6", "Crystal" }
aBARSTYLE[7] := { " 7", "Office 3D" }
aBARSTYLE[8] := { " 8", "Crystal 3D" }
aBARSTYLE[9] := { " 9", "Bricks" }
aBARSTYLE[10] := { "10", "Tiled" }
aBARSTYLE[11] := { "11", "Borland" }
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd AUTOCOLS AUTOSORT ARRAY aBarStyle LINES CELL
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd ON INIT ( oBrw:aCols[2]:SetOrder(), oBrw:Gotop() )
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Array in alpha order
Thank you both. Uwes worked great. By the way the array is 200+ lines in the xbrowse and the user can select from 6 different arrays. Works great.
Thank you
Harvey
Harvey