6.4 Selecting a Record from the Subfile

Now you need to add the logic that reads the record selected by you when you double-click on a subfile record. When you double-click on the subfile part, an ENTER event is signalled. Therefore, you need to create an Action Subroutine for the subfiles ENTER event.

Follow these steps:

  1. From the subfiles pop-up menu, create an action subroutine for the ENTER event. In this action subroutine you use the READS operation code to retrieve the selected record from the subfile. The READS operation code moves the value for the customer number into the program variable CUSTNO. The READS operation code requires the subfile part name in factor 2 (without the quotes).
  2. You want to make this subfile window disappear when a selection is made. Add the logic required to make this window invisible to the action subroutine. This is the logic needed for this action subroutine. Your logic should look something like this:
  3. 
    *...1....+....2....+....3....+....4....+....5....+....6....+....7....+.
    CSRN01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq
     *
     * Read selected record
    C                   ReadS     SFL1                                   99
     *
     * Hide the window
    C     'CUSTLIST'    Setatr    0             'Visible'
     *
    
  4. To complete the program, you need to add logic to move the value in the CUSTNO field to the Entry field. To do so, add the following statement after the READS operation code:
  5. 
    *...1....+....2....+....3....+....4....+....5....+....6....+....7....+.
    CSRN01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq
     *
    C     'EF2'         Setatr    CustNo        'Text'
     *
    

The entry field will be created in the next lesson. Remember to save the source in the Editor.

Click on to indicate that you've done all the steps.