× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yes, its possible....  You have to build the logic to detect which column was 
clicked on, by using the RTNCSRLOC keyword.  For this sort of thing, I prefer 
the form that return record format, field name, and position in field.  For 
this task, all you need is the field name.  Once you have the ability to detect 
the click and return the field name that you clicked on, you then control your 
SQL statement to sort the results by the newly select column.  I believe you 
can accomplish this either through dynamic SQL, where you construct a new SQL 
statement with your custom ORDER BY clause, or you can make use of 
short-circuit logic to construct a packaged SQL statement that allows for 
multiple sort order possibilities.  I think Birgitta has posted several 
examples of this technique.....

http://archive.midrange.com/rpg400-l/200402/msg00439.html
http://archive.midrange.com/rpg400-l/200406/msg00472.html

I have some sample code that demonstrates the RTNCSRLOC technique.  This 
example does not have any SQL in it, but its simple enough to fit those bits 
in....

Since its fairly short, I'll just append it here...  It was only a test, so 
please be kind.... <g>

<DSPF>
A                                      DSPSIZ(24 80 *DS3)
A                                      INDARA            
A          R TEST2                                                         
A                                      CF03(03)                            
A                                      CF13(13)                            
A                                      CF14(14)                            
A                                      CF15(15)                            
A                                      CF16(16)                            
A                                      RTNCSRLOC(*RECNAME &$CURREC &$CURFL-
A                                      D &$CURPOS)      
A                                      MOUBTN(*ULD CF13)
A                                      MOUBTN(*ULP CF14)
A                                      MOUBTN(*URD CF15)
A                                      MOUBTN(*URP CF16)
A                                  1 34'HEADING LINE'   
A            $CURREC       10A  H                       
A            $CURFLD       10A  H                       
A            $CURPOS        4S 0H               
A                                  1  2DATE     
A                                      EDTCDE(Y)
A                                  2  2TIME     
A                                  8 21'Event:' 
A            EVENT         14   O  8 29         
A                                  9 21'Button:'
A            LASTFLD       10   O  9 29         
A*                                                       
A            $FNCHANGE      8A  O 12 29DSPATR(RI)        
A                                      DFTVAL(' Change ')
A                                      COLOR(BLU)        
A            $FNCANCEL      8A  O 12 39DSPATR(RI)        
A                                      DFTVAL(' Cancel ')
A                                      COLOR(BLU)        
A  31        $FNNEXT       10A  O 12 49DSPATR(RI)        
A                                      DFTVAL(' Next ->> ')
A                                      COLOR(BLU)          


<RPG>
FTestMouse2CF   E             Workstn                                           
   
F                                     IndDS($DspInd)                            
   
                                                                                
   
 *File Indicator Data-Structure - Interface for INDARA (Workstation Indicator 
Area)
D $DspInd         DS                                                            
   
D* Function Keys Controls                                                       
   
D   $F03                  3      3N   Inz(*Off)                                 
   
D   $F13                 13     13N   Inz(*Off)                                 
   
D   $F14                 14     14N   Inz(*Off)                                 
   
D   $F15                 15     15N   Inz(*Off)                                 
   
D   $F16                 16     16N   Inz(*Off)                                 
   
D   $ShowNext            31     31N   Inz(*Off)                                 
   
                                                                                
   
                                                                                
   
                                                                                
   
C                   ExFmt     Test2                                             
   
C                                                                               
   
C                   Select                                                      
   
C                   When      $F03                                              
   
C                   Seton                                        LR
C                   Return                                         
C                                                                  
C                   When      $CurFld = '$FNCANCEL'                
C                   Eval      LastFld = $CurFld                    
C                   Eval      $ShowNext = *Off                     
C                                                                  
C                   When      $CurFld = '$FNCHANGE'                
C                   Eval      LastFld = $CurFld                    
C                   Eval      $ShowNext = not $ShowNext            
C                                                                  
C                   When      $CurFld = '$FNNEXT'                  
C                   Eval      LastFld = $CurFld                    
C                   EndSl                                          
C                                                                  
C                   Select                                         
C                   When      $F13                                 
C                   Eval      event = 'L Dbl Clk'                  
C                   When      $F14                                 
C                   Eval      event = 'L Sng Clk'                  
C                   When      $F15                
C                   Eval      event = 'R Dbl Clk' 
C                   When      $F16                
C                   Eval      event = 'R Sng Clk' 
C                   EndSl                         

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Turnidge, Dave
Sent: Thursday, December 07, 2006 3:25 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: SQL Statement 'ORDER BY'


I have been looking at the possibility of using a mouse click for a
subfile on a green screen. Is this possible? I have used
MOUBTN(*SLP/*ULD CF16) and it appears to do nothing. Is there something
else that is needed?

I have columns on my subfile that I want to sort by. Right now, I place
my cursor somewhere on the column and CF16 sorts by that column. I was
thinking it would be cool to be able to double-click on the column and
have that column sorted... Possible?

Dave


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.