"I enjoyed Peter Shufe's question in [COMPUTE!, November, 1981, #18, pg. 16, on Commodore self-modifying programming.] I, too, have the problem of having to list out and amend DATA statements in a grading program that I use quite frequently (I'm a teacher). Unfortunately, your brief answer and program embedded therein did not work. Can you possibly expand upon this answer and give a more complete reply?" Mel Billik
Line 100 was printed incorrectly (see below for correction). The final POKE should be a 13 (carriage return), as our answer to Mr. Shufe's question indicated.
Line 100 is the workhorse here. Whenever you have GOTO 100 within your program, the value of the variable L will print a line number, and Y, and Z will be the data for that DATA line. For example, if your program is keeping a running balance of your checkbook, you might only need to update the current balance. This means that you want the program to change only the one datum, perhaps called CURRENT (variable name).
To accomplish this, when the program is finished with whatever else it does, you could have a line: 700 L = 10: Y = CURRENT: GOTO 100.
Line 100 would not need any additional values so Z could be left out. Also, since you are not going to go on with additional DATA updates, you could make line 500 END. When you saved your program, the value of CURRENT would be in a DATA statement in line 10. When you ran the program next month, the DATA in line 10 would again be updated to reflect any changes.
The purpose of going back into the program (after line 100 does an update) is to allow you to update large amounts of data, not just one datum. You can use a loop to keep increasing the value of L (line number) for the DATA lines until you reach a limit you set. (This is the reason for line 500 in the original answer to Mr. Shafe).
Line 100 is unused until the end, so line one or zero should jump over it to wherever your program actually starts (1 GOTO 200).
100 PRINT"{CLEAR}{03 DOWN}"L"DATA"Y","Z" {DOWN}L="L+2": GOTO 500 {04 UP}" : POKE525, 2:POKE 527, 13: POKE528, 13 : END