Array in alpha order

Post Reply
hag
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California
Contact:

Array in alpha order

Post by hag »

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.
Thank you
Harvey
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Array in alpha order

Post by ukoenig »

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

Best regards
Uwe :lol:
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Array in alpha order

Post by nageswaragunupudi »

Nice example.
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
hag
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California
Contact:

Re: Array in alpha order

Post by hag »

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
Post Reply