<?xml version="1.0" encoding="UTF-8"?>
<!--
  FILE:        ch05fig03.xml
  BASENAME:    ch05fig03
  GRAPHIC:     https://www.magec.com/DOC/ch05fig03.gif
  DIAGRAM DOC: https://www.magec.com/DOC/diags_main.htm  (Figure 03 - NXT Function)
  CHAPTER:     05 - Logic Diagrams
  FUNCTION(S): NXT  (xxxNXT)
  GENERATED:   2026-06-13
  SOURCE:      Derived from live MAGEC RAD documentation at https://magec.com/DOC/
  AUTHORITY:   Al Lee & Associates, Inc.  © 2001-present, all rights reserved.

  NOTES ON PRIOR XML VERSION:
    The prior ch05fig03.xml at https://magec.com/DOC/ch05fig03.xml could not be
    retrieved due to server bot-protection (aiMAGEC hiccup). No prior content
    could be extracted. This file is freshly generated from the live documentation.

  OPTIMIZED FOR:
    1. Regenerating a human-readable graphic diagram with live MAGEC doc links.
    2. AI consumption and reasoning about NXT function logic flow.
    3. AI narration / text-to-speech rendering of the diagram.
-->

<magec_diagram
    xmlns:xlink="http://www.w3.org/1999/xlink"
    diagram_id    = "ch05fig03"
    function_code = "NXT"
    function_label= "xxxNXT"
    title         = "NXT Function — Logic Flow Diagram"
    chapter       = "05"
    figure        = "03"
    graphic_url   = "https://www.magec.com/DOC/ch05fig03.gif"
    diagram_page  = "https://www.magec.com/DOC/diags_main.htm"
    insert_ref    = "https://www.magec.com/DOC/insert_main.htm"
    generated     = "2026-06-13"
>

  <!-- ═══════════════════════════════════════════════════════════════════
       DIAGRAM NOTES  (from the on-diagram annotation and MAGEC docs)
       ═══════════════════════════════════════════════════════════════════ -->
  <diagram_notes>
    <note id="N1">
      The SEE function has no CONTINUATION-MODE. It is a display-only function;
      however, it can serve as the NEW-TRANSACTION-MODE for various other
      functions, such as NXT, DUP, CHG, or DEL functions.
    </note>
    <note id="N2">
      The NXT function has no NEW-TRANSACTION-MODE of its own. It is to be used
      after a successful SEE function or CHG function. If, however, it is not
      preceded by one of those functions, it will attempt to start a browse as
      if it had been preceded by a SEE function.
    </note>
  </diagram_notes>

  <!-- ═══════════════════════════════════════════════════════════════════
       FUNCTION CODES COVERED BY THIS DIAGRAM
       ═══════════════════════════════════════════════════════════════════ -->
  <function_codes>
    <function code="NXT" full_name="xxxNXT" category="MAINT_BROWSE"
              description="Next — reads the next (or previous) record sequentially from the primary file, displaying it on the maintenance screen. Requires a prior SEE or CHG to establish context. Has no NEW-TRANSACTION-MODE of its own." />
  </function_codes>

  <!-- ═══════════════════════════════════════════════════════════════════
       LEGEND
       ═══════════════════════════════════════════════════════════════════ -->
  <legend>
    <symbol shape="rectangle"       meaning="COBOL paragraph (generated code block)" />
    <symbol shape="diamond"         meaning="Decision / branch point" />
    <symbol shape="rounded_rect"    meaning="Terminal / entry point (e.g. NXT Function icon)" />
    <symbol shape="prefix_percent"  meaning="Insertion Point — developer-customizable hook" />
    <symbol shape="label_above"     meaning="COBOL paragraph name (e.g. AA100-CHECK-FUNCTION)" />
    <symbol shape="arrow_label_red" meaning="Condition or transition label on a flow path" />
  </legend>

  <!-- ═══════════════════════════════════════════════════════════════════
       FLOW NODES
       Each node is either an insertion_point or a paragraph.
       Many nodes combine both; a separate <url> element is given for each.
       Sequence follows the diagram top-to-bottom, left-to-right.
       ═══════════════════════════════════════════════════════════════════ -->
  <flow_nodes>

    <!-- ── ENTRY ─────────────────────────────────────────────────────── -->
    <node id="ENTRY" type="terminal" label="NXT Function"
          shape="rounded_rectangle_with_monitor_icon"
          position="top_center">
      <description>
        Entry point for the xxxNXT function. Because NXT has no
        NEW-TRANSACTION-MODE, control always arrives here from a prior
        SEE or CHG transaction context held in the TWA (Task Work Area).
      </description>
      <narration>
        The NXT function begins. Because NXT has no new-transaction mode
        of its own, it relies on context saved from a previous SEE or CHG.
      </narration>
    </node>

    <!-- ── BLOCK 1: PREINIT ──────────────────────────────────────────── -->
    <node id="PREINIT" type="combined" shape="rectangle">
      <paragraph name="AA100-CHECK-FUNCTION"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%PREINIT"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25PREINIT" />
      <description>
        The very first executable logic for all functions, both MAINT and
        BROWSE. AA100-CHECK-FUNCTION validates the function code. %PREINIT
        fires before VARIABLE-STORAGE is initialized, before TEST-KEY and
        TEST-FUNCT are set. No screen fields should be referenced here
        (except SFUNCT, SKEY, SCOMPL, SERRMSG) unless the mask is verified.
        Useful for DB binding (DL/1 PCB scheduling, SQL CONNECT), or to
        change D-LIMITER or WINDOW-COLOR.
      </description>
      <narration>
        First, the program runs the pre-initialization step — paragraph
        A-A-100 CHECK FUNCTION — which includes the percent-PREINIT
        insertion point. This is where a developer can intercept execution
        at the very beginning, before any working storage is set up.
      </narration>
    </node>

    <!-- ── BLOCK 2: INIT ─────────────────────────────────────────────── -->
    <node id="INIT" type="combined" shape="rectangle">
      <paragraph name="BA100-INIT-STORAGE"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%INIT"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25INIT" />
      <description>
        Initialization for all MAINT-FUNCTIONs. VARIABLE-STORAGE is set to
        LOW-VALUES just before %INIT executes. Use %INIT to initialize custom
        work fields defined in %VARSTOR or %DATADEF, especially COMP-3 fields
        that need to be zeroed. Do not reference screen fields (other than the
        four standard MAGEC fields) since the proper mask may not yet be
        active.
      </description>
      <narration>
        Next is the initialization block — B-A-100 INIT STORAGE — containing
        the percent-INIT insertion point, where variable storage is cleared
        and custom fields can be initialized.
      </narration>
    </node>

    <!-- ── BLOCK 3: PFKEYM ───────────────────────────────────────────── -->
    <node id="PFKEYM" type="combined" shape="rectangle">
      <paragraph name="AAM200-MAINTENANCE-MAINLINE"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%PFKEYM"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25PFKEYM" />
      <description>
        Executed at the very top of the MAINT mainline for every transaction
        (NEW or CONTINUATION mode). Default logic handles PF7/PF8 (backward/
        forward browse → transfers to xxxNXT), PF4 (transfer to xxxLOC), PF1/
        PF2/PF11 (help), PF16/PF17 (copy/paste), and cursor-movement detection
        for implicit CHG. Developer can intercept any PF key, alter SKEY/
        TEST-KEY and SFUNCT/TEST-FUNCT, or bypass the entire mainline.
      </description>
      <narration>
        Then the maintenance mainline begins — A-A-M-200 MAINTENANCE MAINLINE
        — which includes the percent-PFKEYM insertion point. This handles
        P-F keys and allows the developer to intercept or redirect processing
        at the top of the mainline.
      </narration>
    </node>

    <!-- ── BLOCK 4: INITATB ──────────────────────────────────────────── -->
    <node id="INITATB" type="combined" shape="rectangle">
      <paragraph name="BA210-MAINT-SCREEN"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%INITATB"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25INITATB" />
      <description>
        Executed only for MAINT functions. Initializes 3270 screen attributes
        (field protection, intensity, color). %INITATB fires at the very end of
        BA210-MAINT-SCREEN immediately before BA299-EXIT. Developer can override
        default attribute values based on function code, operator ID, or any
        other criteria. Do not reference file data items here — I/O has not
        yet been done.
      </description>
      <narration>
        The attribute initialization step follows — B-A-210 MAINT SCREEN —
        with the percent-INITATB insertion point, where screen field attributes
        such as color and protection can be customized.
      </narration>
    </node>

    <!-- ── DECISION 1: KEY = LAST KEY ────────────────────────────────── -->
    <node id="DEC_KEY_LAST" type="decision" shape="diamond">
      <label>KEY = LAST KEY ?</label>
      <description>
        The MMP tests whether the key value currently in SKEY equals the key
        that was saved from the prior SEE or CHG (TWA-LAST-KEY). If yes,
        a READ-NEXT is performed to advance sequentially. If no, the key has
        changed and a different path is followed.
      </description>
      <narration>
        A decision: is the key on the screen equal to the last key from the
        previous transaction? If yes, we proceed to read the next record.
        If no, a different path is taken.
      </narration>
      <transitions>
        <transition condition="YES (KEY = LAST KEY)" target="DEC_PRIOR_READ" />
        <transition condition="NO  (KEY ≠ LAST KEY)" target="DEC_TEST_KEY_SPACES" />
      </transitions>
    </node>

    <!-- ── DECISION 2: PRIOR READ NOT OK ─────────────────────────────── -->
    <node id="DEC_PRIOR_READ" type="decision" shape="diamond">
      <label>PRIOR READ NOT OK ?</label>
      <description>
        Tests whether the prior read (from the previous SEE or CHG context)
        completed successfully. If NOT OK (e.g. end-of-file or error),
        the flow routes to BLNKSCR/SNDSCRN to blank the screen and send it.
        If OK, flow drops down to %REDNX to read the next record.
      </description>
      <narration>
        Another decision: was the prior read successful? If not okay,
        the screen is blanked and sent back. If okay, we continue to
        read the next record.
      </narration>
      <transitions>
        <transition condition="NOT OK" target="BLNKSCR" direction="right" label_color="red" />
        <transition condition="OK"     target="REDNX"   direction="down"  />
      </transitions>
    </node>

    <!-- ── DECISION 3: TEST-KEY = SPACES ─────────────────────────────── -->
    <node id="DEC_TEST_KEY_SPACES" type="decision" shape="diamond">
      <label>TEST-KEY = SPACES ?</label>
      <description>
        When KEY ≠ LAST KEY, the program tests if TEST-KEY is spaces.
        A spaces key is treated as INVALID KEY and routes to BLNKSCR.
        If not spaces, flow continues to %NORMKEY for key normalization.
      </description>
      <narration>
        If the key changed, we check whether the test key is spaces.
        Spaces means an invalid key — the screen is blanked. Otherwise,
        we normalize the key.
      </narration>
      <transitions>
        <transition condition="SPACES (INVALID KEY)" target="BLNKSCR"  direction="right" label_color="red" label="INVALID KEY" />
        <transition condition="NOT SPACES"           target="NORMKEY"  direction="down"  />
      </transitions>
    </node>

    <!-- ── BLOCK 5: NORMKEY ──────────────────────────────────────────── -->
    <node id="NORMKEY" type="combined" shape="rectangle">
      <paragraph name="BA400-NORMALIZE-MAINT-KEY"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%NORMKEY"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25NORMKEY" />
      <description>
        Normalizes the operator-entered key value in SKEY into the internal
        FILE-KEY format used by MAGECIO. Standard logic handles multi-component
        keys, mixed data representations (COMP, COMP-3, alphanumeric, etc.).
        %NORMKEY fires after standard normalization succeeds (no error). The
        developer can add further key edits, massage the key, or add prefix/
        suffix based on terminal/operator/location. On error: GO TO BA480-BAD-KEY.
        FILE-KEY is then MOVE'd to NORMALIZED-KEY automatically.
        Note: this insertion point is for MAINT functions only; %NKLOC handles browse.
      </description>
      <narration>
        The key normalization step — B-A-400 NORMALIZE MAINT KEY — with the
        percent-NORMKEY insertion point, converts the screen key into the
        internal file-key format. On an invalid key, processing branches right
        to blank the screen.
      </narration>
      <transitions>
        <transition condition="INVALID KEY" target="BLNKSCR" direction="right" label_color="red" label="INVALID KEY" />
        <transition condition="valid"        target="REDNX"   direction="down"  />
      </transitions>
    </node>

    <!-- ── BLOCK 6: REDNX ────────────────────────────────────────────── -->
    <node id="REDNX" type="combined" shape="rectangle">
      <paragraph name="AAM430-READ-NEXT-REC"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%REDNX"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25REDNX" />
      <description>
        Reads the next (or previous, if PF7) record pseudo-sequentially from
        the Primary Data Class. Direction is controlled by TWA-BROWSE-DIRECTION
        (F=forward, B=backward). Default logic calls MAGECIO with REDNX command,
        then PERFORMs JA100-LOGICAL-JOIN. %REDNX appears in BOTH the MAINT and
        BROWSE mainlines; if exiting with a GO TO, check which mainline you are
        in (MAINT → AAM440-TEST-RETURN-CODE; BROWSE → AAL440-TEST-RETURN-CODE).
        Do not code paragraph names inside %REDNX (they would be duplicated).
      </description>
      <narration>
        Now the program reads the next record — A-A-M-430 READ NEXT RECORD —
        using the percent-REDNX insertion point, calling MAGEC-I-O to
        sequentially retrieve the next or previous record from the primary file.
      </narration>
      <transitions>
        <transition condition="NOT FOUND" target="BLNKSCR" direction="right" label_color="red" label="NOT FOUND" />
        <transition condition="FOUND"      target="JOIN"    direction="down"  />
      </transitions>
    </node>

    <!-- ── BLOCK 7: JOIN ─────────────────────────────────────────────── -->
    <node id="JOIN" type="combined" shape="rectangle">
      <paragraph name="JA100-LOGICAL-JOIN"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%JOIN"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25JOIN" />
      <description>
        Executed after each standard READ of the Primary Data Class (both MAINT
        and BROWSE functions). Used to READ secondary files or compute "derived
        fields" to form the Logical Record. Automatic Logical Join generates code
        here automatically. Developer can add or modify READs of secondary files.
        TWA-DB-REQUEST is saved/restored by the MMP before PERFORMING JA100.
        To exit: GO TO JA900-RETURN (not JA999-EXIT).
        If referencing screen fields, test IF (MAINT-FUNCTION) or
        IF (BROWS-FUNCTION) first.
      </description>
      <narration>
        After reading the record, the logical join step runs — J-A-100
        LOGICAL JOIN — via the percent-JOIN insertion point. This reads
        secondary files and computes derived fields to build the full
        logical record.
      </narration>
      <transitions>
        <transition condition="NOT FOUND" target="BLNKSCR" direction="right" label_color="red" label="NOT FOUND" />
        <transition condition="found"      target="COMP"    direction="down"  />
      </transitions>
    </node>

    <!-- ── BLOCK 8: COMP ─────────────────────────────────────────────── -->
    <node id="COMP" type="combined" shape="rectangle">
      <paragraph name="BB200-FILL-SCREEN"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%COMP"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25COMP" />
      <description>
        Executed in NEW-TRANSACTION-MODE of MAINT functions (only if REC-FOUND)
        to MOVE data from the Logical Record (TWA-DB-DATA) to the screen fields.
        %COMP is inserted at the end of BB200-FILL-SCREEN, after all generated
        MOVEs from database fields to screen, just before BB299-EXIT. Developer
        can move literals, computed values, or code translations. Can also alter
        3270 attributes (e.g. color) based on data values. SERRMSG can be used
        for extra display capacity. Do not reference MSK652 (Browse Mask) here.
        For numeric screen fields use both S_____-N (numeric equiv.) and
        S_____-ED (edit pattern).
      </description>
      <narration>
        The fill-screen step — B-B-200 FILL SCREEN — with the percent-COMP
        insertion point, moves database field values to the screen for display,
        after all the standard generated moves.
      </narration>
    </node>

    <!-- ── BLOCK 9: SKEYBLD ──────────────────────────────────────────── -->
    <node id="SKEYBLD" type="combined" shape="rectangle">
      <paragraph name="BB200-FILL-SCREEN"
                 url="https://www.magec.com/DOC/diags_main.htm"
                 note="SKEYBLD is PERFORMED from the Maintenance mainline for NXT" />
      <insertion_point name="%SKEYBLD"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25SKEYBLD" />
      <description>
        Constructs the Master (Primary) key in operator-entry format (including
        slashes, etc.) from the record data and MOVEs the result to SKEY and
        TWA-LAST-KEY. This is performed from the NXT maintenance mainline to
        simulate the operator's full key entry for the cursor-selection and
        forward/backward reading features. The default code for %SKEYBLD IS
        the entire CA800-BUILD-SKEY routine (including paragraph names).
        Handles multi-component keys, mixed data representations. For minor
        changes, consider %SNDSCRN instead.
      </description>
      <narration>
        Next, the key-build step — percent-SKEYBLD — reconstructs the screen
        key value from the record just read, placing it into S-KEY so the
        operator can see which record is being displayed.
      </narration>
    </node>

    <!-- ── BLOCK 10: BLNKSCR ─────────────────────────────────────────── -->
    <node id="BLNKSCR" type="combined" shape="rectangle">
      <paragraph name="BB100-BLANK-SCREEN"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%BLNKSCR"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25BLNKSCR" />
      <description>
        Executed on INVALID KEY and on NOT-FOUND conditions (and on NEW-TRANSACTION-
        MODE of xxxADD — not applicable to NXT). Blanks the screen by MOVEing
        underscores to all screen variables. %BLNKSCR fires at the very end of
        BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected
        screen fields to values other than underscores, read a file based on the
        key value, or test for key-edit failures (IF SCOMPLE = E).
        This logic executes only for MAINT functions; MSK652 (Browse Mask) fields
        may not be referenced here.
      </description>
      <narration>
        If no record is found, or the key is invalid, or the prior read failed,
        the blank-screen step runs — B-B-100 BLANK SCREEN — with the
        percent-BLNKSCR insertion point, which clears the screen with
        underscore placeholders.
      </narration>
    </node>

    <!-- ── BLOCK 11: SNDSCRN ─────────────────────────────────────────── -->
    <node id="SNDSCRN" type="combined" shape="rectangle">
      <paragraph name="AA800-SEND-SCREEN"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%SNDSCRN"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25SNDSCRN" />
      <description>
        Executed just before the MMP exits to MAGECCP (which will send the
        screen and terminate the task, or execute a fetch to another function).
        %SNDSCRN fires for both MAINT and BROWSE functions. No default logic.
        Developer can put finishing touches on the screen (blank zero fields,
        set highlight/color based on value thresholds, massage SKEY from
        cursor-select). If referencing non-standard screen fields, test which
        mask is active first (THIS-PGMS-MSK vs. COMMON-LOC-MSK).
        To exit: GO TO AA900-GOBACK.
      </description>
      <narration>
        Just before returning to the MAGEC control program, the send-screen
        step runs — A-A-800 SEND SCREEN — with the percent-SNDSCRN insertion
        point, giving the developer a final chance to adjust screen content.
      </narration>
    </node>

    <!-- ── BLOCK 12: GOBACK ──────────────────────────────────────────── -->
    <node id="GOBACK" type="combined" shape="rectangle">
      <paragraph name="AA900-GOBACK"
                 url="https://www.magec.com/DOC/diags_main.htm" />
      <insertion_point name="%GOBACK"
                       url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25GOBACK" />
      <description>
        Absolutely the last logic point in the online process for all functions.
        %GOBACK fires here, for both MAINT and BROWSE functions. A good place
        for IMS PCB TERMINATE or other end-of-execution cleanup. Screen data
        may be referenced only after interrogating which mask is initialized.
      </description>
      <narration>
        Finally, the program reaches A-A-900 GOBACK — with the percent-GOBACK
        insertion point — the absolute last opportunity to insert code before
        control returns to the MAGEC control program.
      </narration>
    </node>

  </flow_nodes>

  <!-- ═══════════════════════════════════════════════════════════════════
       FLOW EDGES — Complete adjacency list
       ═══════════════════════════════════════════════════════════════════ -->
  <flow_edges>
    <edge from="ENTRY"              to="PREINIT"           condition="" />
    <edge from="PREINIT"            to="INIT"              condition="" />
    <edge from="INIT"               to="PFKEYM"            condition="" />
    <edge from="PFKEYM"             to="INITATB"           condition="" />
    <edge from="INITATB"            to="DEC_KEY_LAST"      condition="" />
    <edge from="DEC_KEY_LAST"       to="DEC_PRIOR_READ"    condition="KEY = LAST KEY" />
    <edge from="DEC_KEY_LAST"       to="DEC_TEST_KEY_SPACES" condition="KEY ≠ LAST KEY" />
    <edge from="DEC_PRIOR_READ"     to="REDNX"             condition="PRIOR READ OK" />
    <edge from="DEC_PRIOR_READ"     to="BLNKSCR"           condition="PRIOR READ NOT OK" />
    <edge from="DEC_TEST_KEY_SPACES" to="NORMKEY"          condition="TEST-KEY NOT SPACES" />
    <edge from="DEC_TEST_KEY_SPACES" to="BLNKSCR"          condition="TEST-KEY = SPACES (INVALID KEY)" />
    <edge from="NORMKEY"            to="REDNX"             condition="KEY VALID" />
    <edge from="NORMKEY"            to="BLNKSCR"           condition="INVALID KEY" />
    <edge from="REDNX"              to="JOIN"              condition="RECORD FOUND" />
    <edge from="REDNX"              to="BLNKSCR"           condition="NOT FOUND" />
    <edge from="JOIN"               to="COMP"              condition="JOIN OK / REC FOUND" />
    <edge from="JOIN"               to="BLNKSCR"           condition="NOT FOUND" />
    <edge from="COMP"               to="SKEYBLD"           condition="" />
    <edge from="SKEYBLD"            to="SNDSCRN"           condition="" />
    <edge from="BLNKSCR"            to="SNDSCRN"           condition="" />
    <edge from="SNDSCRN"            to="GOBACK"            condition="" />
  </flow_edges>

  <!-- ═══════════════════════════════════════════════════════════════════
       INSERTION POINT SUMMARY TABLE
       Cross-reference: which standard functions use each insertion point
       (sourced from insert_main.htm Figure 1 cross-reference table)
       ═══════════════════════════════════════════════════════════════════ -->
  <insertion_point_summary>
    <!--
      Columns applicable to NXT (Maintenance Browse, Continuation Mode):
        NXT column from insert_main.htm cross-reference table
    -->
    <ip name="%PREINIT"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25PREINIT"  />
    <ip name="%INIT"     nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25INIT"     />
    <ip name="%PFKEYM"   nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25PFKEYM"   />
    <ip name="%INITATB"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25INITATB"  />
    <ip name="%NORMKEY"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25NORMKEY"  />
    <ip name="%REDNX"    nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25REDNX"    />
    <ip name="%JOIN"     nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25JOIN"     />
    <ip name="%COMP"     nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25COMP"     />
    <ip name="%SKEYBLD"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25SKEYBLD"  />
    <ip name="%BLNKSCR"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25BLNKSCR"  />
    <ip name="%SNDSCRN"  nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25SNDSCRN"  />
    <ip name="%GOBACK"   nxt="X" url="https://www.magec.com/DOC/insert_main.htm#Online_Insertion_Point_%25GOBACK"   />
  </insertion_point_summary>

  <!-- ═══════════════════════════════════════════════════════════════════
       NARRATIVE — suitable for text-to-speech rendering
       ═══════════════════════════════════════════════════════════════════ -->
  <narrative title="NXT Function — Logic Flow Narrative">
    <paragraph>
      This diagram describes the logic flow of the N-X-T function —
      referred to in code as "x-x-x-N-X-T" — in a MAGEC-generated online
      maintenance program, or M-M-P. The NXT function reads the next (or
      previous) record sequentially from the primary data class and
      displays it on the maintenance screen.
    </paragraph>
    <paragraph>
      An important note: the NXT function has NO new-transaction mode of
      its own. It relies on context stored in the Task Work Area from a
      prior SEE or CHG function. If NXT is invoked without that prior
      context, it will behave as if a SEE had just been done.
    </paragraph>
    <paragraph>
      Processing begins at the very top with the percent-PREINIT insertion
      point inside paragraph A-A-100 CHECK FUNCTION. This fires for every
      function and every mode. The developer can intercept execution here
      before any working storage is initialized.
    </paragraph>
    <paragraph>
      Next is percent-INIT inside B-A-100 INIT STORAGE, where variable
      storage is cleared to low-values and the developer can initialize
      custom work fields.
    </paragraph>
    <paragraph>
      The maintenance mainline then starts with percent-PFKEYM inside
      A-A-M-200 MAINTENANCE MAINLINE, which handles P-F key detection and
      allows early interception of the transaction.
    </paragraph>
    <paragraph>
      Attribute initialization follows — percent-INITATB in B-A-210 MAINT
      SCREEN — where 3270 screen field attributes such as color and
      protection level can be overridden.
    </paragraph>
    <paragraph>
      A decision is then made: is the key on the screen equal to the last
      key saved from the prior SEE or CHG? If yes, a second decision checks
      whether the prior read was successful. If the prior read was not okay,
      processing branches right to blank the screen. If okay, it proceeds
      directly to read the next record.
    </paragraph>
    <paragraph>
      If the key changed (not equal to last key), the program checks whether
      the test key is spaces. Spaces means invalid key, and the screen is
      blanked. Otherwise, the key is normalized by percent-NORMKEY in
      B-A-400 NORMALIZE MAINT KEY. On an invalid key format, processing again
      routes to blank the screen.
    </paragraph>
    <paragraph>
      On a valid key, or directly from a successful prior read, the program
      executes percent-REDNX in A-A-M-430 READ NEXT RECORD. This calls the
      MAGEC I-O module to read the next or previous record based on browse
      direction. If no record is found, processing routes to blank the screen.
    </paragraph>
    <paragraph>
      When a record is found, the percent-JOIN insertion point in J-A-100
      LOGICAL JOIN runs to read secondary files and compute derived fields,
      assembling the complete logical record. Again, a not-found here routes
      to blank the screen.
    </paragraph>
    <paragraph>
      With the logical record assembled, percent-COMP in B-B-200 FILL SCREEN
      moves database field values to screen display fields.
    </paragraph>
    <paragraph>
      Then percent-SKEYBLD rebuilds the screen key in S-KEY from the record
      data, so the operator can see the key of the record now displayed.
    </paragraph>
    <paragraph>
      On both the found and not-found paths, processing converges at
      A-A-800 SEND SCREEN, which contains the percent-SNDSCRN insertion
      point — the developer's last chance to fine-tune the screen before
      it is sent.
    </paragraph>
    <paragraph>
      Finally, A-A-900 GOBACK with percent-GOBACK is the absolute last
      point in the flow, after which control returns to the MAGEC control
      program.
    </paragraph>
  </narrative>

  <!-- ═══════════════════════════════════════════════════════════════════
       REFERENCE LINKS
       ═══════════════════════════════════════════════════════════════════ -->
  <references>
    <ref label="Chapter 05 - Logic Diagrams (NXT Function, Figure 03)"
         url="https://www.magec.com/DOC/diags_main.htm" />
    <ref label="Chapter 04 - Insertion Points (full reference)"
         url="https://www.magec.com/DOC/insert_main.htm" />
    <ref label="Chapter 03 - Analysis of the Generated MMP"
         url="https://www.magec.com/DOC/genmmp_main.htm" />
    <ref label="MAGEC Quick Reference - Insertion Points Table"
         url="https://www.magec.com/DOC/magref_main.htm#MAGREF009001" />
    <ref label="MAGEC RAD Glossary"
         url="https://www.magec.com/DOC/glossary_main.htm" />
    <ref label="Master Table of Contents"
         url="https://www.magec.com/DOC/mastertoc_main.htm" />
    <ref label="AI Assistant Facts"
         url="https://www.magec.com/DOC/ai-assistant-facts.html" />
  </references>

</magec_diagram>