[inherit('mcv:mcvlib')] program build_example(input,output);
var
   context: tbl_context;
   numLines: array[boolean] of integer := zero;
   which: boolean;
   line: varying[255] of char;
begin
   tbl_open_table(context,'EXAMPLE');
   tbl_set_psect(context,0);
   tbl_set_psect_info(context,tbl_readonly,'EVEN_LINES');
   tbl_define_symbol(context,'EVEN_LINES');
   tbl_set_psect(context,1);
   tbl_set_psect_info(context,tbl_readonly,'ODD_LINES');
   tbl_define_symbol(context,'ODD_LINES');
   which := false;
   writeln(
      'Please enter a number of text lines to be stored in the object file');
   writeln('Type Control-Z to end');
   write('> ');
   while not eof(input) do begin
      readln(line);
      which := not which;
      numlines[which] := numlines[which]+1;
      tbl_set_psect(context,ord(which));
      tbl_store_data(context,line,length(line)+2);
      write('> ');
      end;
   writeln;
   writeln(
   '%EXAM-W-IGNORE, The linker will complain about compilation warnings');
   tbl_set_psect(context,3);
   tbl_define_symbol(context,'NUMEVEN');
   tbl_store_data(context,numlines[false],size(integer));
   tbl_define_symbol(context,'NUMODD');
   tbl_store_data(context,numlines[true],size(integer));
   tbl_close_table(context,tbl_warning);
   end. 
