ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Page Up and Down moving Cursor in Subfile...

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

  • Page Up and Down moving Cursor in Subfile...

    Hi,

    I was wondering if anyone knew how to stop the cursor from leaving the subfile when the page up or page down button is pressed at the top or bottom of the subfile?

    For instance if the subfile is currently on the last page (on a Load-all-at-Once subfile) and the page down button is pressed (with the system controlling paging) an error is displayed and then the cursor will move out of the subfile (it seems to go to the first field in the subfile control record???) Does anyone know how to ensure the cursor doesn't move on page up and page downs when allowing the system to handle paging? Or will I need to implement a page at a time subfile file with paging controlled by my program to achieve this?

    Any help would be greatly appreciated.

    Steve

  • #2
    Re: Page Up and Down moving Cursor in Subfile...

    not saying this is the only or the best way... its just my way...
    the dds .... look for the currec code that and the Two RRN's


    PHP Code:
          A*=============================================================  
          
    A*  Control for subfile number one                               
          A
    *       Show all routes in error                                
          A
    *=============================================================  
          
    A          R SUB01CTL                  SFLCTL(SUB01)             
          
    A*%%TS  SD  20090427  122320  FLANARY     REL-V5R4M0  5722-WDS   
          A                                      SFLSIZ
    (0020)              
          
    A                                      SFLPAG(0016)              
          
    A                                      WINDOW(FMT1)              
          
    A                                      RTNCSRLOC(&#REC &#FLD)    
          
    A                                      BLINK                     
          A                                      OVERLAY                   
          A                                      SFLCSRRRN
    (&WHERE)         
          
    A  31                                  SFLDSP                    
          A  32                                  SFLDSPCTL                 
          A  30                                  SFLCLR                    
          A  33                                  SFLEND
    (*MORE)             
          
    A            SCRRN          4S 0H      SFLRCDNBR                 
          A            
    #REC          10A  H                                
          
    A            #FLD          10A  H                                
         
    A            WHERE          5S 0H                                            
         A            ATR_DACONM     1A  P                                            
         A            DACONM        30A  O  1 16DSPATR
    (&ATR_DACONM)                   
         
    A            HDPROGRAM     10A  O  1 58                                      
         A            C1TITLE       40A  O  2 11DSPATR
    (&ATR_DACONM)                   
         
    A            C1CNAME       30A  O  3  1DSPATR(HI)                            
         
    A            C1DATE         8Y 0O  1  1EDTWRD('  /  /    ')                  
         
    A                                  4  3'To email note, place cursor on dat-  
         A                                      e, Press <F9>'                        
         
    A                                      COLOR(BLU
    the display file & infds
    PHP Code:
    fARC19AD   cf   e             WORKSTN INFDS(INFDS)           
    f                                     SFILE(SUB01:RRN1)      
    f                                     SFILE(SUB02:RRN2)      
    f                                     SFILE(SUB03:RRN3)      
    f                                     SFILE(SUB04:RRN4)      
                                                            
    d Infds           ds                                    
    d Choice                369    369                      
    d Currec                378    379I 0 
    clear & load subfile
    Code:
           //----------------------------------------
            // $clearSfl - clear the subfile
            //----------------------------------------
                 begsr $clearSFL;
    
                  // clear the subfile first
    
                   *in31 = *Off;
                   *in32 = *Off;
                   *in30 = *On;
    
                   write fmt1;
                   write  SUB01CTL;
    
                   *in31 = *On;
                   *in32 = *On;
                   *in30 = *Off;
    
                   clear RRN1;
                   clear SCRRN;
                   clear SavRrn;
                   wrotecustinfo = *off;
                 endsr;
            //--------------------------------------------------------
            // $loadsfl- load up the entire subfile
            //--------------------------------------------------------
                 begsr $loadsfl;
    
                  if  SavRrn  > *zeros;
                   RRN1  =  SavRrn;
                   SCRRN =  SavRrn;
                  endif;
    
                  // setup the header fields
                  clear c1cname;
                  chain (workcustomer) aracustd;
                  if %found(aracustd);
                   c1cname = title(aaslnm);
                  endif;
    
                 // load the sticky notes  type = 'G' for general
                  exsr $loadINFO;
    
                  sqlstmt = 'select * from sldcomm ' +
                            ' where sdtype  in (' +
                              Q + 'I' + Q + ', ' +
                              Q + 'O' + Q +
                              ')' +
                            ' and sdsl# = ' + %char(workcustomer) +
                            ' order by sddat desc,RRN(sldcomm) ';
    
                  openList();
                  dow fetchNext();
    
                   isodate = %date(sddat:*cymd);
                   h1cymd = sddat;
                   if sddat <> lastdate;
                    exsr $writedate;
                    lastdate = sddat;
                   endif;
    
                   clear s1note;
                   if sdevcm <> *blanks;
                    %subst(S1note :2) = %trim(SDEVCM);
                    if SDEVCS > *zeros;     // expenses
                     %subst(s1note:2) =
                     %trim(s1note) + '  Cost: ' +
                     %trim(%editc(sdevcs: 'A' : '$'));
                    endif;
                    RRN1 += 1;
                    SCRRN = RRN1;
                    write SUB01;
                   else;
    
                    clear s1note;            // use the code and write description to subfile
                    chain (sdevcd) slfevnta;
                    if %found(slfevnta);
                     %subst(s1note:3) = title(SFEVDS);
                     if SDEVCS > *zeros;     // expenses
                      %subst(s1note:3) =
                      %trim(s1note) + '  Cost: ' +
                      %trim(%editc(sdevcs: 'A' : '$'));
                     endif;
                     RRN1 += 1;
                     SCRRN = RRN1;
                     write SUB01;
                    endif;
                   endif;
    
                  enddo;
                  closeList();
    
                  *in33 = *on;
                  savrrn = SCRRN;
    
               //
               //  If no records in subfile then do not disply the subfile.
               //
                  if SavRrn  = *zeros;
                   *in31 = *off;
                  else;
                   RRN1  = 1;
                   SCRRN  = 1;
                  endif;
    
                 endsr;

    Then the screen processing
    Code:
           //--------------------------------------------------------
            // $Screen1 - parameter screen
            //--------------------------------------------------------
                 begsr $Screen1;
    
                 reset  EndScreen1;
                  dow  EndScreen1 = 'N';
    
                   if ScreenError = 'N';
                    $clearmsg('*' : *zero : *Blanks : '*ALL' : APIError);
                   endif;
    
                   write MSGCTL;
                   write fmt1;
                   exfmt SUB01CTL;
                   $clearmsg('*' : *zero : *Blanks : '*ALL' : APIError);
                   reset ScreenError;
                   if Currec <> *Zeros;
                    RRN1  =  Currec;
                    SCRRN =  Currec;
                   endif;
    
                   select;
                //
                // F3 pressed end the program F3 = LeaveProgram
                //
                    when  Choice = LeaveProgram;
                     EndScreen1 = 'Y';
    
                //
                // F6 pressed add/maintain note(s) to customer
                //    always default to TODAY!
                //
                    when  Choice = addnotes;
                     isodate =%date();
                     c3date = %dec(isodate:*mdy);
                     h3date = c3date;
                     exsr $addnotes;
                //
                // F9 pressed email this note
                //
                    when  Choice = emailnote;
                     if where > *zeros;
                      chain where sub01;
                      if %found(arc19ad);
                       isodate = %date(h1cymd:*cymd);
                       c3date = %dec(isodate:*mdy);
                       s2code = 'CL';
                       exsr $clearsfl3;
                       exsr $loadsfl3;
                       exsr $clearsfl4;
                       exsr $loadsfl4;
                       exsr $screen4;
                      endif;
                     endif;
    
                //
                // Enter Key pressed
                //
                    when  Choice = enterKey;
                     exsr $process;
    
                    endsl;
                   enddo;
    
                 endsr;
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Page Up and Down moving Cursor in Subfile...

      Thanks for the great coding examples...

      I've been doing a bunch of testing on this and have found that it seems to be an issue when using the SFLEND keyword with the *SCRBAR parameter with the final service pack release for Client Access for Windows V5R3.

      Changing the SFLEND keyword to *MORE or *PLUS results in the behaviour I'd expect from a page up or page down on the first or last page (ie. The subfile doesn't scroll but the cursor remains in it's current position). So it seems that the positioning of the cursor after a pagedown while on the final page of a subfile works differently when using *SCRBAR than to when using *MORE or *PLUS.

      Even stranger, using an older Service Pack release results in the *SCRBAR working the same as *MORE and *PLUS (and how I would expect it to work). Further still using the *SCRBAR parameter on a selection list (a subfile with the SFLSNGCHC keyword) results in what I would consider the expected behaviour for positioning of the cursor regardless of which service pack is being used???

      So if anyone has found they've experienced the same problem just be aware that it seems IBM have changed the behaviour of the SFLEND keyword with the *SCRBAR parameter to be different than when using the *MORE and *PLUS parameters (unless your using the SFLSNGCHC keyword which means it continues to act in the old way?????) We're are still using V5R3 here so I can't confirm whether this behaviour has continued with 5VR4 and V6R1 versions of Client Access.

      Cheers

      Comment


      • #4
        Re: Page Up and Down moving Cursor in Subfile...

        welcome to code400 steven....Spent a couple months in Australia...wish to get back someday...

        jamie
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Page Up and Down moving Cursor in Subfile...

          Use the SFLCSRRRN(F02RRN) where F02RRN = the RRN of the subfile where you want your cursor to be.

          I always just set this to 1 and on page-up/down, the system positions the cursor autonagically. If I position the cursor to the third item, when i page-up/down, the cusor stays on the third item of the next/previous page.
          Regards

          Kit
          http://www.ecofitonline.com
          DeskfIT - ChangefIT - XrefIT
          ___________________________________
          There are only 3 kinds of people -
          Those that can count and those that can't.

          Comment

          Working...
          X