bb.donnay-software.com

Donnay Software Web Forums
It is currently Sun Sep 15, 2019 3:18 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Indexed Array
PostPosted: Mon Apr 29, 2019 7:19 am 
Offline

Joined: Thu Jan 28, 2010 9:34 am
Posts: 452
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


Top
 Profile  
 
 Post subject: Re: Indexed Array
PostPosted: Mon Apr 29, 2019 3:16 pm 
Offline
User avatar

Joined: Wed Feb 24, 2010 3:44 pm
Posts: 1139
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


Top
 Profile  
 
 Post subject: Re: Indexed Array
PostPosted: Tue Apr 30, 2019 7:20 am 
Offline

Joined: Thu Jan 28, 2010 9:34 am
Posts: 452
I don't have that. Must be in a different release.

Fred


Top
 Profile  
 
 Post subject: Re: Indexed Array
PostPosted: Tue Apr 30, 2019 11:06 am 
Offline

Joined: Wed Jan 27, 2010 10:25 pm
Posts: 338
Location: Berlin Germany
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.

_________________
_______________________
Best Regards
Wolfgang


Top
 Profile  
 
 Post subject: Re: Indexed Array
PostPosted: Tue Apr 30, 2019 4:22 pm 
Offline
User avatar

Joined: Thu Jan 28, 2010 10:27 am
Posts: 125
Location: NYC
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


Top
 Profile  
 
 Post subject: Re: Indexed Array
PostPosted: Thu May 16, 2019 8:17 am 
Offline

Joined: Thu Jan 28, 2010 9:34 am
Posts: 452
Thanks, that was very helpful. Got it to work fine.

Fred


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group