DCBROWSECOL .... FOOTER

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

DCBROWSECOL .... FOOTER

#1 Post by unixkd »

Hi all

I discovered that DCBROWSECOL .... FOOTER cause IDC error.

Run the code below:

Code: Select all

FUNCTION XSample_19                                                            
                                                                               
/*  ARRAY BROWSER WITH COLORS                                                                                                                                 
 This example demonstrates how to control the color of cells in                
 an array browser using DCBROWSE.  In this example, the color of               
 the SIZE cells is dependent on the size of the file.  The                     
 function DC_GETCOLARRAY() is used as a pointer into the array                 
 being browsed.                                                                                                                                              
*/                                                                             
                                                                               
LOCAL GetList := {}, cDir, oFileName, aDirectory, i, ;                    
      nPointer, oDirectory, aColors, bColor, GetOptions, cFooter := TRANSFORM(0,"###,###,###")                        
                                                                               
cDir := Space(30)                                                         
                                                                               
@ 2,2 DCGET cDir GETSIZE 43  POPUP {|c|DC_PopDir(c)}                           
                                                                               
aDirectory := Directory()                                                      
FOR i := 1 TO Len(aDirectory)                                                  
  ASize(aDirectory[i],5)                                                       
  aDirectory[i,5] := .f.                                                       
NEXT                                                                           
ASort(aDirectory,,,{|a,b|a[1]<b[1]})                                           
                                                                               
@ 3.5,2 DCBROWSE oDirectory DATA aDirectory ;                                  
      SIZE 60,12 ;                                                             
      FONT '10.Helv Bold' ;                                                    
      PRESENTATION DC_BrowPres() ;                                             
      POINTER nPointer ;                                                       
      OPTIMIZE ;                                                               
      FIT ;                                                                    
      NOHSCROLL ;                                                              
      MARK 5 ;                                                                 
      MKCOLOR 5, GRA_CLR_WHITE, GRA_CLR_BLUE                                   
                                                                               
aColors := { {GRA_CLR_WHITE,GRA_CLR_DARKRED}, ;                                
             {GRA_CLR_WHITE,GRA_CLR_DARKBLUE}, ;                               
             {GRA_CLR_BLACK,GRA_CLR_DARKGREEN}, ;                              
             {GRA_CLR_BLACK,GRA_CLR_YELLOW} }                                  
                                                                               
bColor := {| nSize, nCase | nSize := DC_GetColArray(2,oDirectory),;            
              nCase := DC_PickCase(nSize,'>=',;                                
                          {1000000,100000,10000,0}, ;                          
                          {      1,     2,    3,4} ), aColors[nCase] }         
                                                                               
DCBROWSECOL ELEMENT 1 WIDTH 10 HEADER "Name" PARENT oDirectory                 
                                                                               
DCBROWSECOL ELEMENT 2 WIDTH 7 HEADER "Size" PARENT oDirectory ;                
  EVAL { |o|o:colorBlock := bColor } // FOOTER {|| cFooter }                                          
                                                                               
DCBROWSECOL ELEMENT 3 WIDTH 8 HEADER "Date" PARENT oDirectory                  
                                                                               
DCBROWSECOL ELEMENT 4 WIDTH 6 HEADER "Time" PARENT oDirectory                  
                                                                               
DCBROWSECOL ELEMENT 5 WIDTH 4 HEADER "Marked" PARENT oDirectory   

@ 2,50  DCPUSHBUTTON CAPTION "Display" SIZE 7,0.8 ;
        ACTION {|| _UpdateDirFooter(aDirectory, cDir, @cFooter, GetList, oDirectory)}             
                                                                               
DCGETOPTIONS NOMINBUTTON NOMAXBUTTON NORESIZE TABSTOP                          
                                                                               
DCREAD GUI ;                                                                   
   OPTIONS GetOptions ;                                                        
   FIT ;                                                                       
   MODAL ;                                                                     
   BUTTONS DCGUI_BUTTON_OK + DCGUI_BUTTON_CANCEL ;                             
   TITLE 'Array Browse of Directory'  
                                                                               
RETURN nil 
*
Static Function _UpdateDirFooter(aDir, cDir, cFooter, GetList, oDirectory)
Local nSize := 0, i
aDir := Directory(AllTrim(cDir)+"\*.*")
aEval(aDir, {|e| nSize += e[2]})
cFooter := TRANSFORM(nSize, "###,###,###")
FOR i := 1 TO Len(aDir)                                                  
  ASize(aDir[i],5)                                                       
  aDir[i,5] := .f.                                                       
NEXT
DC_GetBrowArray(oDirectory,aDir)                           
DC_GetRefresh(GetList)
Return nil                                                                    
                                                                               
* ------------    

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCBROWSECOL .... FOOTER

#2 Post by unixkd »

DCBrowseColFooter.png
DCBrowseColFooter.png (172.52 KiB) Viewed 10641 times

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCBROWSECOL .... FOOTER

#3 Post by Tom »

You need a footer in every column. Create empty footers for the other columns (... FOOTER "-").
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCBROWSECOL .... FOOTER

#4 Post by unixkd »

Thanks Tom

Worked now. Roger should mention it in the doc.

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCBROWSECOL .... FOOTER

#5 Post by Tom »

This is not Roger's mistake.

Anyway, look at your screenshot. Besides it doesn't work - it doesn't look very good, having footers at a position where column values are expected. ;)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSECOL .... FOOTER

#6 Post by rdonnay »

Worked now. Roger should mention it in the doc.
I suppose I should have mentioned that, but it never occurred to me that someone would want footers only on some columns, and not others. Tom is right. That's a strange way to design a browse.

It will require much more work for me to modify my code to fill in the empty footers than it will for you to do as Tom suggested.

Each column object knows nothing about other column objects, so the only way to handle this is to add another clause to the DCBROWSE object that would set some kind of default. That's more changes to DCDIALOG.CH, DC_XbpBrowse() class and the documentation. If this issue had been brought up 15-20 years ago, when I first wrote the browse system, I may have thought that this was a major design flaw. But after this long, with no other complaints from eXpress++ users, I will leave well enough alone. I have some bigger fish that I am frying right now which adds major new features to the browse system.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: DCBROWSECOL .... FOOTER

#7 Post by unixkd »

Roger

I agree with you totally

Thanks

Post Reply