sort an array on line Resolved!!

sort an array on line Resolved!!

Postby Silvio.Falconi » Thu Jan 10, 2019 9:41 am

can I sort an array is on xbrowse ?

sample :
AaDd(atemp,{strzero(n,4),; //0001
SP->id,; // "O"
SP->DESC,; //"ooooooo"
SP->SETTORE,; //"A"
nGiorni,; //"1"
nPriceTemp,; //"10.00"
lIslock,; /7".t."
nIdListino } ) //"01"

I wish sort on idlistino
Last edited by Silvio.Falconi on Tue Jan 15, 2019 10:09 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby nageswaragunupudi » Thu Jan 10, 2019 12:35 pm

Create xbrowse with AUTOSORT clause and click on the last header.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: sort an array on line

Postby Silvio.Falconi » Thu Jan 10, 2019 5:16 pm

Sorry but i wish sort on idlistino is not on x browse
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby nageswaragunupudi » Thu Jan 10, 2019 5:22 pm

First sort the array

ASort( aTemp, , , { |x,y| x[ 8 ] < y[ 8 ] } )

Then build the XBrowse and do not use AUTOSORT.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: sort an array on line

Postby Silvio.Falconi » Thu Jan 10, 2019 7:27 pm

Sorry i make a mistake i have on array records having idlistino =1 and other =2 and i select with a combobox if 1 or 2 and i wish refrrsh the xbrowes showing only the idlistino =nselect
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby nageswaragunupudi » Fri Jan 11, 2019 4:53 am

Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oDlg, oFont, oBrw
   local cFilter     := "01"
   local nFilterCol  := 3
   local aData       := { ;
         { "one",    "two",   "01" }, ;
         { "three",  "four",  "01" }, ;
         { "five",   "six",   "02" }, ;
         { "seven",  "eight", "02" }, ;
         { "nine",   "ten",   "02" }  }


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 300,300 PIXEL TRUEPIXEL FONT oFont

   @ 70,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE FilterArray( aData, nFilterCol, cFilter ) ;
      COLUMNS 1,2 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   @ 20,20 COMBOBOX cFilter ITEMS { "01", "02" } SIZE 100,400 PIXEL OF oDlg ;
      ON CHANGE ( oBrw:aArrayData := FilterArray( aData, nFilterCol, cFilter ), ;
                  oBrw:GoTop(), oBrw:Refresh() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

static function FilterArray( aData, nFilterCol, cFilter )

   local aFilter  := {}

   AEval( aData, { |a| If( a[ nFilterCol ] == cFilter, AAdd( aFilter, a ), nil ) } )

return aFilter
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: sort an array on line

Postby Silvio.Falconi » Fri Jan 11, 2019 9:10 am

thanks .it was just what I was trying to do
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby Silvio.Falconi » Fri Jan 11, 2019 9:32 am

Only I have a listini with two array (name,type)
type "Listino 1" ,"01"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby Silvio.Falconi » Fri Jan 11, 2019 12:35 pm

I correct with

@ 36,75 COMBOBOX cFilter ITEMS ArrTranspose( aListini )[ 1] SIZE 100,400 PIXEL OF oDlgTariffe;
ON CHANGE ( oBrwBase:aArrayData := FilterArray( aData, nFilterCol, cFilter ), ;
oBrwBase:GoTop(), oBrwBase:Refresh() )

Image

but Now i not see any record on when I select one items

Image


the code

Code: Select all  Expand view  RUN


#include "fivewin.ch"

REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO


function Tariffe()

   local oDlg, oFont,oBold
   local oBrwBase,oBrwTariffe
   local aget[1]
   local nFilterCol  := 8
   local aListini    := Crea_Array_listini()   //creation price_list
   local aData       := Crea_Base(aListini)
   local cFilter     := alistini[1][2]

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-14 BOLD

   DEFINE DIALOG oDlgTariffe SIZE 500,600;
   PIXEL TRUEPIXEL RESIZABLE FONT oFont;
   TITLE " Tariffe"

    @ 10, 40 SAY oSay1 PROMPT "Tariffe Base"  SIZE 400,24 PIXEL OF oDlgTariffe CENTER FONT oBold
    @ 38,20 SAY "Listino :"  SIZE 80,14 PIXEL OF oDlgTariffe

   @ 70,20 XBROWSE oBrwBase SIZE -5,200 PIXEL OF oDlgTariffe ;
      HEADERS "Elemento","Settore","Giorni","Costo", "Bloccato";
      DATASOURCE FilterArray( aData, nFilterCol, cFilter ) ;
      COLUMNS 3,4,5,6,7;
      CELL LINES NOBORDER

   WITH OBJECT oBrwBase
      :CreateFromCode()
   END

 @ 36,75 COMBOBOX  cFilter ITEMS  ArrTranspose( aListini )[ 1]  SIZE 100,400 PIXEL OF oDlgTariffe;
     ON CHANGE ( oBrwBase:aArrayData := FilterArray( aData, nFilterCol, cFilter ), ;
                  oBrwBase:GoTop(), oBrwBase:Refresh() )




   @ 550,260 BUTTON oBtnClose PROMPT "Conferma" SIZE 80,30 PIXEL OF oDlgTariffe;
   ACTION  NIL

   @ 550,360 BUTTON oBtnOK    PROMPT "Annulla"    SIZE 80,30 PIXEL OF oDlgTariffe;
   ACTION NIL



 oDlgTariffe:bResized  := <||
         local oRect    := oDlgTariffe:GetCliRect()

         oBtnClose:nLeft   := oRect:nRight - 220
         oBtnClose:nTop    := oRect:nBottom - 50

         oBtnOK:nLeft      := oRect:nRight - 120
         oBtnOK:nTop       := oRect:nBottom - 50

       oBrwBase:refresh()

     *  oBrwTariffe:refresh()

         RETURN nil
         >


   ACTIVATE DIALOG oDlgTariffe CENTERED
   RELEASE FONT oFont, oBold
   RETURN nil
//----------------------------------------------------------------//



static function FilterArray( aData, nFilterCol, cFilter )

   local aFilter  := {}

   AEval( aData, { |a| If( a[ nFilterCol ] == cFilter, AAdd( aFilter, a ), nil ) } )

return aFilter


//----------------------------------------------------------------//

Function Crea_Array_listini()
   Local alist_temp:={}

   USE LISTINI ALIAS LI SHARE NEW VIA "DBFCDX"
        INDEX ON NAME TAG "IDXLISTINI"
            LI->(dbgotop())

        DO While !LI->(eof())
             AaDd(alist_temp,{ LI->NAME,LI->ID  })
            LI->(dbskip())
        ENDDO

   return alist_temp

//----------------------------------------------------------------//

Static Function Crea_Base(aListini)
Local atemp:={}
Local n         := 1
Local nGiorni   := 1
Local nPriceTemp:= 10
Local lIsLock   := .t.
Local cId       :=" "
Local cSector   :=" "

 USE SPIAGGIA ALIAS SP SHARE NEW VIA "DBFCDX"

     INDEX ON id+settore TAG "IDXSETTORE"

    SP->(ordSetFocus("IDXSETTORE")) //indicizzo su settori
    SP->(dbgotop())


//Creo tariffe base secondo gli elementi che sono in archivio e per listino

  Do while .not. SP->(eof())

       IF !Empty(SP->SETTORE) .and. (sp->SETTORE!=cSector .or. sp->Id!=cId)

         For k=1 to Len(aListini)

           AaDd(atemp,{strzero(n,4),;
                        SP->id,;
                        SP->DESC,;
                        SP->SETTORE,;
                        nGiorni,;
                        nPriceTemp,;
                        lIslock,;
                        aListini[k][2]  } )

                    n++

               next

            Endif

         cSector := sp->SETTORE
         cId := sp->Id
      SP->(dbskip())
   Enddo


   return  aTemp







 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: sort an array on line

Postby Silvio.Falconi » Fri Jan 11, 2019 12:59 pm

If I made (idea)

Code: Select all  Expand view  RUN
static function FilterArray( aData, nFilterCol, cFilter, alistini )
   local aFilter  := {}

   AEval( aData, { |a| If( a[ nFilterCol ] == Search_cod(cFilter,alistini) , AAdd( aFilter, a ), nil ) } )

   return aFilter


Function search_cod(cFilter,alistini)
   Local   nAt := AScan( alistini, { |a| a[ 1 ] == cFilter } )
   Local cCode:=""
   If nAt>0
      cCode:= alistini[nAt][2]
   endif

   return cCode


it run but on init I see the xbrowse empty ,,,any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 73 guests