FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Array in alpha order
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Array in alpha order
Posted: Tue Jul 27, 2010 05:48 PM

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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Array in alpha order
Posted: Tue Jul 27, 2010 06:10 PM
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



Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Array in alpha order
Posted: Wed Jul 28, 2010 01:56 AM
Nice example.
But if anyway we are using XBrowse, we can allow xbrowse to do the sorting instead of ourselves doing it.
Code (fw): Select all Collapse
#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 (fw): Select all Collapse
#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
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Array in alpha order
Posted: Wed Jul 28, 2010 05:19 PM

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

Continue the discussion