     H BNDDIR('LRNGSRV') DFTACTGRP(*no) ACTGRP(*caller)                                             
      * File declarations                                                                           
     FEXAM0067D CF   E             WORKSTN                                                          
      * Standard include to bring in the external LRNG support function protypes                    
     D/INCLUDE LRNGSOURCE,LRNGCOMMON                                                                
      * Standard include to bring in the demonstration definitions                                  
     D/INCLUDE SOURCEDEMO,DEMOCOMMON                                                                
      * Compile time array test dataa /INCLUDED from member EXAM0004CT                              
     DEXAM4Entries     C                   100                                                      
     DEXAM4            DS                  Qualified                                                
     D Name                          40A   Dim(EXAM4Entries) CTDATA                                 
     D Address                       40A   Dim(EXAM4Entries) CTDATA                                 
     D Country                       40A   Dim(EXAM4Entries) CTDATA                                 
     D Phone                         10A   Dim(EXAM4Entries) CTDATA                                 
      * Localized variables                                                                         
     D                 DS                                                                           
     DIndex                          10I00                                                          
     DTableLoaded                      N   Inz(False)                                               
     DTouchRowName                   40A   Varying                                                  
     DTouchRowIndex                  10I00                                                          
     DTouchAction                    10A   Varying                                                  
     DColumnName                     10A                                                            
      * Standard parameter list declaration                                                         
     D/INCLUDE SOURCEDEMO,STDPARAMS                                                                 
      /free                                                                                         
                                                                                                    
         // Indicator 01 conditions what table is shown, the table shown                            
         // for small devices has smaller fonts and the first column has a                          
         // fixed width                                                                             
         If (SystemInfo.DeviceSizeCategory = 'LARGE');                                              
           *IN01 = *ON;                                                                             
         else;                                                                                      
           *IN01 = *OFF;                                                                            
         ENDIF;                                                                                     
         // Loop for as long as this program is handling the requested  action                      
         DoU (RequestPROGRAM <> ProgramINFO.Name);                                                  
                                                                                                    
            // Handle the currently requested action                                                
                                                                                                    
            Exsr HandleRequestedAction;                                                             
                                                                                                    
            // Display this programs FormView(s)                                                    
                                                                                                    
            Exsr DisplayFormView;                                                                   
                                                                                                    
         Enddo; // DoW (RequestedPROGRAM = ThisPROGRAM);                                            
                                                                                                    
         // Finished. Note that since RequestedPROGRAM/RequestedACTION are parameter                
         // their values are passed back to the driver so                                           
         // that it can decide what to do next.                                                     
         *InLR = *ON;                                                                               
         Return;                                                                                    
                                                                                                    
       // ---------------------------------------------------------------------                     
       // Display this program's Form View(s)                                                       
       // ---------------------------------------------------------------------                     
                                                                                                    
       Begsr DisplayFormView;                                                                       
                                                                                                    
          if (NOT IsNewForm);                                                                       
             LRNG_SetSendChangesOnly();                                                             
          endif;                                                                                    
                                                                                                    
          LRNG_Send();                                                                              
          Exfmt FormView;                                                                           
          LRNG_Receive();                                                                           
          LRNG_GetRequestedAction(RequestPROGRAM:RequestACTION);                                    
                                                                                                    
       Endsr;                                                                                       
                                                                                                    
       // ---------------------------------------------------------------------                     
       // Handle the requested action                                                               
       // ---------------------------------------------------------------------                     
                                                                                                    
       Begsr HandleRequestedAction;                                                                 
                                                                                                    
         // Initially assume that the form view will not be changed                                 
                                                                                                    
         IsNewForm = False;                                                                         
                                                                                                    
         // Now act on the request that the user has made                                           
                                                                                                    
         Select;                                                                                    
                                                                                                    
            // A click on a table row                                                               
                                                                                                    
            When (RequestACTION = 'ROWCLICK');                                                      
                 Exsr HandleAction_Menu;                                                            
                                                                                                    
            // The user has requested to see RPG or DDS Code                                        
            // NOTE: This code would not be in a real application of course!                        
                                                                                                    
            When ((RequestACTION = 'SHOWRPG') or (RequestACTION = 'SHOWDDS'));                      
                 Exsr HandleAction_SHOWRPGorDDS;                                                    
                                                                                                    
            // A click on a popover table row                                                       
                                                                                                    
            When (RequestACTION = 'POPROWCLICK');                                                   
                 Exsr HandleAction_PopOverClick;                                                    
                                                                                                    
            // Otherwise perform the default action                                                 
                                                                                                    
            Other;                                                                                  
                 Exsr HandleAction_DEFAULT;                                                         
                                                                                                    
         EndSl;                                                                                     
                                                                                                    
       Endsr;                                                                                       
                                                                                                    
       // ---------------------------------------------------------------------                     
       // Handle the DEFAULT action                                                                 
       // ---------------------------------------------------------------------                     
                                                                                                    
       Begsr HandleAction_DEFAULT;                                                                  
                                                                                                    
          if  ( TableLoaded = False);                                                               
                                                                                                    
             IsNewForm = True;                                                                      
                                                                                                    
             // Load up TABLE1 with example data                                                    
                                                                                                    
             Exsr LoadTABLE1;                                                                       
                                                                                                    
             // Set and standardize the INSTRUCTION line                                            
                                                                                                    
             DemoStdLabel(SystemINFO : 'INSTRUCTION'                                                
                        : 'Touch a row icon to select an action to take...' );                      
                                                                                                    
          endif;                                                                                    
                                                                                                    
       Endsr;                                                                                       
                                                                                                    
       // ---------------------------------------------------------------------                     
       // Handle a request that has come from the Context up menu                                   
       // ---------------------------------------------------------------------                     
                                                                                                    
       Begsr HandleAction_Menu;                                                                     
                                                                                                    
          // Get the row ID%1 (the row number) and ID%2 (the value of the clicked name)             
          // of the table associated with the selected menu item.                                   
          LRNG_Using('/Form.Fields.TABLE1');                                                        
            TouchRowIndex = LRNG_GetPropAsNum('CurrentRowID%1');                                    
            TouchRowName = LRNG_GetPropAsStr('CurrentRowID%2');                                     
          LRNG_EndUsing();                                                                          
                                                                                                    
         // Build a Table PopOver associating it to the Name column NAMECOL                         
         // The popover table has two rows: column one is an image and column two                   
         // a label.                                                                                
         // When a row is clicked a POPROWCLICK action is sent to the program                       
         // which is handled by HandleAction_PopOverClick                                           
         LRNG_Using('/Form.Fields.TABLE1.Row#'+%char(TouchRowIndex)+'.NAMECOL');                    
           LRNG_AssignBoolToProp(*ON : 'ShowPopOver');                                              
           LRNG_Using('PopOver');                                                                   
            LRNG_SetProperty('Type':'Table');                                                       
            LRNG_SetProperty('Col%1.Name':'IMG');                                                   
            LRNG_SetProperty('Col%1.Type':'Image');                                                 
            LRNG_SetProperty('Col%2.Name':'TEXT');                                                  
            LRNG_SetProperty('Col%2.Type':'Label');                                                 
            LRNG_SetProperty('Row%1.IMG.Resource':'vf_ic3611.gif');                                 
            LRNG_SetProperty('Row%1.ID%1':'EDIT');                                                  
            LRNG_SetProperty('Row%1.ID%2':TouchRowName);                                            
            LRNG_SetProperty('Row%1.TEXT.Text':'Edit ' + %trim(TouchRowName));                      
            LRNG_SetProperty('Row%2.ID%1':'DELETE');                                                
            LRNG_SetProperty('Row%2.ID%2':TouchRowName);                                            
            LRNG_SetProperty('Row%2.IMG.Resource':'vf_ic3621.gif');                                 
            LRNG_SetProperty('Row%2.TEXT.Text':'Delete ' + %trim(TouchRowName));                    
            LRNG_SetProperty('OnRowClicked':'POPROWCLICK');                                         
          LRNG_EndUsing();                                                                          
         LRNG_EndUsing();                                                                           
                                                                                                    
          // This is just normal defensive coding on array indicies                                 
          if ((TouchRowIndex < 1) or (TouchRowIndex > EXAM4Entries));                               
             TouchRowName = 'Not available';                                                        
          else;                                                                                     
             TouchRowName = %trim( EXAM4.Name(TouchRowIndex) );                                     
          endif;                                                                                    
                                                                                                    
       Endsr;                                                                                       
                                                                                                    
       // Handle a click on the popover row                                                         
       Begsr HandleAction_PopOverClick;                                                             
                                                                                                    
         // The row number and value of the NAMECOL were stored as the row ID%1 and ID%2            
         // respectively. Get them and show the values at the top of the screen                     
         LRNG_Using('/Form.Fields.TABLE1.Row%'+%char(TouchRowIndex)+'.NAMECOL');                    
            TouchAction = LRNG_GetPropAsStr('PopOver.CurrentRowID%1');                              
            TouchRowName = LRNG_GetPropAsStr('PopOver.CurrentRowID%2');                             
            LRNG_AssignBoolToProp(*OFF : 'ShowPopOver');                                            
         LRNG_EndUsing();                                                                           
          DemoStdLabel(SystemINFO : 'INSTRUCTION'                                                   
                   : 'You touched Row ' + %char(TouchRowIndex)                                      
                   + ' ("' + TouchRowName                                                           
                   + '") and requested to "' + TouchAction + '"');                                  
       ENDSR;                                                                                       
                                                                                                    
       // ---------------------------------------------------------------------                     
       // Load TABLE1 up with demonstration data                                                    
       // ---------------------------------------------------------------------                     
                                                                                                    
       Begsr LoadTABLE1;                                                                            
                                                                                                    
         // Loop through the test data set in the compiel time arrays                               
                                                                                                    
         for Index = 1 to 50;                                                                       
                                                                                                    
            // Set up to use TABLE1.ROW%n where "n" is the loop index                               
                                                                                                    
            LRNG_Using('/Form.Fields.TABLE1.ROW' : Idx(Index) );                                    
                                                                                                    
            // Set the TABLE1.ROW%n.NAMECOL.Value and font size                                     
                                                                                                    
            LRNG_AssignStrToProp(EXAM4.Name(Index) : 'NAMECOL.Value' );                             
                                                                                                    
            // Set the TABLE1.ROW%n.ADDRESSCOL.Value and font size                                  
                                                                                                    
            LRNG_AssignStrToProp(                                                                   
                             %trim(EXAM4.Address(Index))                                            
                             + ' ' + %trim(EXAM4.Country(Index))                                    
                             : 'ADDRESSCOL.Value');                                                 
                                                                                                    
            // Set the row ID%1 to the array index value. This is important                         
            // so that when a user actions a row we can tell which row.                             
            // In this case the array index is being set as row ID%1                                
            // but equally a product or customer number could have been                             
            // used. Also additional values in ID%2, ID%3, etc are possible.                        
                                                                                                    
            LRNG_AssignNumToProp(Index : 'ID%1');                                                   
            LRNG_AssignStrToProp(EXAM4.Name(Index) : 'ID%2');                                       
         endfor;                                                                                    
                                                                                                    
         // Standardize the look of TABLE1                                                          
                                                                                                    
         DemoStdTable(SystemINFO:'TABLE1');                                                         
                                                                                                    
         // Table has been loaded                                                                   
                                                                                                    
         TableLoaded = True;                                                                        
                                                                                                    
       EndSr;                                                                                       
                                                                                                    
       // ----------------------------------------------------------------------                    
       // Handle a SHOWRPG or SHOWDDS request.                                                      
       // NOTE: This subroutine would not be in a real application of course!                       
       // ----------------------------------------------------------------------                    
                                                                                                    
       Begsr HandleAction_SHOWRPGorDDS;                                                             
                                                                                                    
          DemoShowMember( SystemInfo : RequestACTION                                                
                         : ProgramINFO.Name : RequestWasHandled);                                   
                                                                                                    
       Endsr;                                                                                       
                                                                                                    
      /end-free                                                                                     
      * Include the example set of compile time array names and phone numbers                       
      * and then the Context up menu action descriptions and request codes                          
     C/INCLUDE SOURCEEXAM,EXAM0004CT                                                                 