The following Cobol code searches a linked list to find the node just prior to the node to which CURR-P points:
SET PREV-P TO FIRST-P.
*
IF PREV-P NOT = NULL
SET ADDRESS OF TN-NODE TO PREV-P
PERFORM UNTIL PREV-P = NULL
OR TN-NEXT-P = CURR-P
SET PREV-P TO TN-NEXT-P
IF PREV-P NOT = NULL
SET ADDRESS OF TN-NODE TO PREV-P
END-IF
END-PERFORM.
This procedure is almost identical to that described elsewhere for
searching the list. The only significant
differences are:
SET ADDRESS OF TN-NODE TO CURR-P.
...because the rest of the program might expect CURR-P to be pointing to
TN-NODE.