[ Keyboard a_buffer a_table nw i w w2 x1 x2; DisplayStatus(); .FreshInput; ! Save the start of the buffer, in case "oops" needs to restore it ! to the previous time's buffer for (i=0:i<64:i++) oops_workspace->i = a_buffer->i; ! In case of an array entry corruption that shouldn't happen, but would be ! disastrous if it did: a_buffer->0 = 120; a_table->0 = 15; ! Allow to split input into this many words ! Print the prompt, and read in the words and dictionary addresses L__M(##Prompt); AfterPrompt(); #IFV5; DrawStatusLine(); #ENDIF; KeyboardPrimitive(a_buffer, a_table); nw=a_table->1; ! If the line was blank, get a fresh line if (nw == 0) { L__M(##Miscellany,10); jump FreshInput; } ! Unless the opening word was "oops", return w=a_table-->1; if (w == OOPS1__WD or OOPS2__WD or OOPS3__WD) jump DoOops; #IFV5; ! Undo handling if ((w == UNDO1__WD or UNDO2__WD or UNDO3__WD) && (parse->1==1)) { if (turns==1) { L__M(##Miscellany,11); jump FreshInput; } if (undo_flag==0) { L__M(##Miscellany,6); jump FreshInput; } if (undo_flag==1) jump UndoFailed; if (just_undone==1) { L__M(##Miscellany,12); jump FreshInput; } @restore_undo i; if (i==0) { .UndoFailed; L__M(##Miscellany,7); } jump FreshInput; } @save_undo i; just_undone=0; undo_flag=2; if (i==-1) undo_flag=0; if (i==0) undo_flag=1; if (i==2) { style bold; print (name) location, "^"; style roman; L__M(##Miscellany,13); just_undone=1; jump FreshInput; } #ENDIF; return nw; .DoOops; if (oops_from == 0) { L__M(##Miscellany,14); jump FreshInput; } if (nw == 1) { L__M(##Miscellany,15); jump FreshInput; } if (nw > 2) { L__M(##Miscellany,16); jump FreshInput; } ! So now we know: there was a previous mistake, and the player has ! attempted to correct a single word of it. for (i=0:i<=120:i++) buffer2->i = a_buffer->i; x1 = a_table->9; ! Start of word following "oops" x2 = a_table->8; ! Length of word following "oops" ! Repair the buffer to the text that was in it before the "oops" ! was typed: for (i=0:i<64:i++) a_buffer->i = oops_workspace->i; Tokenise__(a_buffer,a_table); ! Work out the position in the buffer of the word to be corrected: w = a_table->(4*oops_from + 1); ! Start of word to go w2 = a_table->(4*oops_from); ! Length of word to go ! Write spaces over the word to be corrected: for (i=0:i(i+w) = ' '; if (w2 < x2) { ! If the replacement is longer than the original, move up... for (i=120:i>=w+x2:i--) a_buffer->i = a_buffer->(i-x2+w2); ! ...increasing buffer size accordingly. a_buffer->1 = (a_buffer->1) + (x2-w2); } ! Write the correction in: for (i=0:i(i+w) = buffer2->(i+x1); Tokenise__(a_buffer,a_table); nw=a_table->1; return nw; ];