A little more info:
Opened file in Firefox, didn't see anything in the problem area that looked strange. Closed without saving.
Apparently it's more a display problem then an editing issue. I can select the item DM[4000], and paste the replacement "ScreenNumOld". Display loses editing line, and numerous blank line appear below after several untouched lines. Hit the "ESC" key, exiting CustFun. Reopen the Custfun, the editing is complete and displayed properly. Trying to edit other instances of the DM[4000] results in the same issue. DM[4000] is the last (or very near) instance of any DM[] that has not been replaced with a label name. But no problem editing anything else in the Custfun. Both DM[4000] and "ScreenNumOld" are in the define table, and the label is accepted, orange color.
Here is troublesome code that appears 8 times in the custfun:
IF ScreenNumOld <> ScreenNumber
ScreenNumOld = ScreenNumber
SETLCD 0,1,CHR$(1)
ENDIF
If I put the cursor at the end of the second line and hit "DEL", the line disappears and the empty lines below appear. Then if hitting "Enter", every thing goes back to before"Del".