bb.donnay-software.com
http://bb.donnay-software.com/donnay/

Indexed Array
http://bb.donnay-software.com/donnay/viewtopic.php?f=2&t=2577
Page 1 of 1

Author:  omni [ Mon Apr 29, 2019 7:19 am ]
Post subject:  Indexed Array

Roger,

Do you have any samples for using dcbrowse, sort with arrays instead of file indexes?

I have used files for this but never arrays and users want to be able to select the sort for records that are in different files.

Fred
Omni

Author:  Auge_Ohr [ Mon Apr 29, 2019 3:16 pm ]
Post subject:  Re: Indexed Array

omni wrote:
Do you have any samples for using dcbrowse, sort with arrays instead of file indexes?
i do not know if there is a Express++ Sample but you can look at \Source\samples\basics\GuiBrow\FBROWSE.prg.
it does use Directory() as Arrays and you can sort it (ALT-1 - ALT-4)

Author:  omni [ Tue Apr 30, 2019 7:20 am ]
Post subject:  Re: Indexed Array

I don't have that. Must be in a different release.

Fred

Author:  Wolfgang Ciriack [ Tue Apr 30, 2019 11:06 am ]
Post subject:  Re: Indexed Array

Make a Sortblock, f.e.
Code:
local bSortCol:={|a,n,o| aShow:=SortArrayCol(n,aShow), dc_getbrowarray(oBrowse, aShow), oBrowse:refreshAll(), dc_getrefresh(Getlist)}

a Browser:
Code:
@3.5,1 DCBROWSE oBrowse DATA aShow ;
     CURSORMODE XBPBRW_CURSOR_ROW ;
     NOHORIZSCROLL ;
     FIT ;
     SIZE 50,h ;
     ITEMMARKED {|| ....} ;
     ITEMSELECTED {|| ...} ;
     ....
DCBROWSECOL ELEMENT 1  HEADER "No." WIDTH 4 PARENT oBrowse SORT bSortCol LEFTBUTTON
DCBROWSECOL ELEMENT 2 HEADER "Name" WIDTH 20 PARENT oBrowse SORT bSortCol LEFTBUTTON
.....

and the sort function of the array to your needs:

Code:
static function SortArrayCol(nCol,aShow)
local aR

if nCol=1
   aR:=ASort(aShow,,,{|x,y| x[1] < y[1]})
elseif nCol=2
   aR:=ASort(aShow,,,{|x,y| upper(x[2]) < upper(y[2])})
elseif nCol=3
......
endif
return aR

So you can sort your browse by clicking in the browse header.

Author:  SbDrakos [ Tue Apr 30, 2019 4:22 pm ]
Post subject:  Re: Indexed Array

Fred,

Here's another way.

*-----------------
#include "dcdialog.ch"

proc main

LOCAL GetList[0]
LOCAL aNames, oBrowse

aNames := {{"Steve" , "Rogers", "001"},;
{"Bruce" , "Banner", "002"},;
{"Walt" , "Disney", "003"},;
{"Peter" , "Parker", "004"},;
{"Natashia", "Romanoff", "005"},;
{"Tony" , "Stark", "006"}}

@ 0,0 DCBROWSE oBrowse SIZE 55,8 DATA aNames SCROLLBARHEIGHT 10 FONT '12.Arial'

DCBROWSECOL HEADER "First Name";
ELEMENT 1 PARENT oBrowse WIDTH 10;
SORT {|| ASort(aNames,,,{|a,b| a[1]<b[1]})}

DCBROWSECOL HEADER "Last Name";
ELEMENT 2 PARENT oBrowse WIDTH 10;
SORT {|| ASort(aNames,,,{|a,b| a[2]<b[2]})}

DCBROWSECOL HEADER "ID";
ELEMENT 3 PARENT oBrowse WIDTH 3;
SORT {|| ASort(aNames,,,{|a,b| a[3]<b[3]})}

DCREAD GUI TITLE "Browse Sort" ADDBUTTONS FIT

return

* -------------

procedure appsys; return

Bobby

Author:  omni [ Thu May 16, 2019 8:17 am ]
Post subject:  Re: Indexed Array

Thanks, that was very helpful. Got it to work fine.

Fred

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/