The following program, for the BBC, will retrieve programs that have had loading problems and so have finished with 'Bad Program'.
First, set the PAGE to about 30000 as soon as the 'Bad Program' appears, then type NEW followed by the program below.
10 LK%=6400
20 REPEAT
30 LK%=LK%+1
40 UNTIL (?LK%<&1F AND ?*LK%-1)<>13 AND ?LK%<>13 AND ?(LK%-2)<>13)
50 REPEAT
60 LK%=LK%-1
70 UNTIL ?LK%=13
80 ?(LK%+1)=255
90 PRINT"RETRIEVED"
Note that it will only retrieve Basic programs and it does depend on what is causing the 'Bad Program' error message. As soon as the program displays its message, put PAGE back to &E00, type OLD and LIST or RUN.