var local &NOTE &LINE &VAR

&NOTE = 0
out $#T\NOTES.TXT over
if #E = -1 ;* demo
  ret
fi

try
  <nextwrite>
  &NOTE = &NOTE+1
  &VAR = form('&NOTE_%.0f' &NOTE)
  pri $&VAR
  jump <nextwrite>
yrt
out

if par(2046) = ''
  shell wait 'NOTEPAD.EXE $#T\NOTES.TXT'
else
  shell wait par(2046) '$#T\NOTES.TXT'
fi

try
  &LINE = read(+$#T\NOTES.TXT 0) ;* open file for subsequent reads
yrt
&NOTE = 0
var undef &NOTE_*

try
  <nextread>
  &LINE = read(+ 1)
  &NOTE = &NOTE+1
  &VAR = form('&NOTE_%.0f' &NOTE)
  var global $&VAR
  $&VAR = &LINE
  jump <nextread>
yrt

if &NOTE > 0 & &LINE = ''
  var undef $&VAR
fi   ;* ignore last line if blank

redisplay
set dirty 1  ;* notes may have been updated - impossible to tell
