Indexed Array

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 478
Joined: Thu Jan 28, 2010 9:34 am

Indexed Array

#1 Post by omni »

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

User avatar
Auge_Ohr
Posts: 1189
Joined: Wed Feb 24, 2010 3:44 pm

Re: Indexed Array

#2 Post by Auge_Ohr »

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)
greetings by OHR
Jimmy

omni
Posts: 478
Joined: Thu Jan 28, 2010 9:34 am

Re: Indexed Array

#3 Post by omni »

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

Fred

Wolfgang Ciriack
Posts: 354
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Indexed Array

#4 Post by Wolfgang Ciriack »

Make a Sortblock, f.e.

Code: Select all

local bSortCol:={|a,n,o| aShow:=SortArrayCol(n,aShow), dc_getbrowarray(oBrowse, aShow), oBrowse:refreshAll(), dc_getrefresh(Getlist)}
a Browser:

Code: Select all

@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: Select all

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.
_______________________
Best Regards
Wolfgang

User avatar
SbDrakos
Posts: 131
Joined: Thu Jan 28, 2010 10:27 am
Location: NYC

Re: Indexed Array

#5 Post by SbDrakos »

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

omni
Posts: 478
Joined: Thu Jan 28, 2010 9:34 am

Re: Indexed Array

#6 Post by omni »

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

Fred

Post Reply