ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Determining which column

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rocky
    replied
    I used SDA to create the above - put an 8 next to the SFLCTL, a Y for Select record keywords. Y for General keywords, Y for RTNCSRLOC and Y for Select paramaters (there may not be an option to put a Y next to RTNCSRLOC - that's ok, put it for Select paramaters) - put a Y for RTNCSRLOC and *RECNAME, put the fields names (CSRRCD, CSRFLD, CSRPOS in my example).

    Enter all the way back out - and add those fields as hidden fields in the record.

    Leave a comment:


  • Rocky
    replied
    Ok - I've been learning, always a good thing.

    In your DDS - after the SSFLCTL statement:

    Code:
         A                                      RTNCSRLOC(*RECNAME &CSRRCD &CSRFLD - 
         A                                      &CSRPOS)                             
    ...
         A            CSRRCD        10   H    
         A            CSRFLD        10   H    
         A            CSRPOS         4  0H
    Compile it and the program - when the user puts the cursor in whichever column he wants to sort by and presses the function key you programmed - CSRFLD should contain the field name of that column...

    Leave a comment:


  • Rocky
    replied
    Birgitta,

    Thank you! Comes from seeing way too much RPG/400 code...

    Rocky

    Leave a comment:


  • Rocky
    replied
    Now why would I want to go and do it the easy way for? LOL

    Leave a comment:


  • B.Hauser
    replied
    Can be done even easier and without any calculation:
    Code:
           Dcl-Ds Wsds;          
             Row Int(3) Pos(370);          
             Col Int(3) Pos(371);        
    End-Ds;
    Birgitta

    Leave a comment:


  • Brian Rusch
    replied
    Another alternative would be to make the column headings be variables instead of constants, so you could determine which column heading the cursor was on by which column heading field name was returned to your program.

    Leave a comment:


  • Rocky
    replied
    On your workstation file add an INFDS to the keywords if it's not already there. In the Data structure specified by the INFDS

    Code:
          Dcl-Ds Wsds;
             Row Int(5) Pos(370);
           End-Ds;
    
            Dcl-S Row#     Int(3);
            Dcl-S Col#     Int(3);
    Then when you need to know where the cursor was:

    Code:
                             Row# = Row / 256;
                             Col# = %Rem(Row : 256);
    Now you know where the cursor was - test the value of col# and act accordingly.

    Leave a comment:


  • Terry Wincheste
    replied
    Couldn't you use the Row and Column numbers to determine which heading the cursor is sitting on? Of course, this implies that if you alter the position of the column headings in the DDS then your code would also have to be changed to accomodate the Row/Col change.

    Another idea: If you have extra function keys available - you could set them up to perform column sorting based on keypress.

    Leave a comment:


  • gregwga50
    replied
    In other words, if the cursor is on the CUSTOMER# heading, then sort the file that is written to the subfile in customer# order. If the cursor is on the ORDER# heading, sort the file by order# before writing it to the subfile

    Leave a comment:


  • gregwga50
    replied
    Originally posted by Terry Wincheste View Post
    Not sure I understand exactly what your trying to retrieve, bu these are the DDS values I usually use to retrieve screen/subfile positioning information:
    I want to sort the subfile based on what column heading on the subfile control record the cursor is on not what field or subfile record it is on.

    Leave a comment:


  • Terry Wincheste
    replied
    Not sure I understand exactly what your trying to retrieve, bu these are the DDS values I usually use to retrieve screen/subfile positioning information:

    Code:
                                           CSRLOC(M3LINNBR  M3COLNBR)      
                                           RTNCSRLOC(&M3SUBRCD &M3SUBFLD)  
                                           RTNCSRLOC(*WINDOW &M3ROW &M3COL)
                                           SFLCSRRRN(&M3SUBRRN)          
    
                 M3RRN          4  0H      SFLRCDNBR(CURSOR)        
                 M3MODE         1   H                                
                 M3ROW          3  0H      TEXT('Current Row')      
                 M3COL          3  0H      TEXT('Current Column')    
                 M3LINNBR       3S 0H      TEXT('Line Number')      
                 M3COLNBR       3S 0H      TEXT('Column Number')    
                 M3SUBRRN       5S 0H      TEXT('Subfile Cursor RRN')
                 M3SUBRCD      10   H      TEXT('Cursor Loc Record')
                 M3SUBFLD      10   H      TEXT('Cursor Loc Field')
    I can usually figure out what to do using one or more of these valeues.

    Leave a comment:


  • gregwga50
    started a topic Determining which column

    Determining which column

    I need to display records in a subfile sorted in an order determined by which column heading the cursor resides on. I know there is a way to determine which field the cursor is place on, but this is based on column heading. I assume you would have to determine what the row# range and column# range is. Anyone know another way?
Working...
X