with Text_io; use Text_io; with iio; separate(REPORT) task body TELEGRAMS is tgm_nbr:integer:=0; nwords:INTEGER:=0; noswords:INTEGER:=0; EOTGM:BOOLEAN:=false; w:WORD; function ZZZZ(W:WORD) return boolean is begin return W.LENGTH =4 and W.S(1..4)="ZZZZ"; end; begin accept Put(W:in WORD; DONE:out boolean) do TELEGRAMS.W:=Put.W; EOTGM:=ZZZZ(Put.W); DONE:=EOTGM; -- if EOTGM at start then NULL input file end Put; Put(" "); put_line("TGRAM NBR No. Words Oversize WOrds"); NON_NULL_TELEGRAMS:while not EOTGM loop -- if first word in Telegram is ZZZZ then NULL TGM nwords:=0; noswords:=0; TELEGRAM:while not EOTGM Loop --start a word inside a telegram if W.LENGTH > 13 then noswords:=noswords+1; end if; nwords:=nwords+1; accept Put(W:in WORD; DONE:out boolean) do TELEGRAMS.W:=Put.W; EOTGM:=ZZZZ(Put.W); DONE:=false; -- End of THIS telegram is not end of input. end Put; end loop TELEGRAM; tgm_nbr:=tgm_nbr+1; Put(" "); iio.Put(tgm_nbr, width=>7); iio.Put(nwords,width=>12); iio.put(noswords,width=>12); new_line; accept Put(W:in WORD; DONE:out boolean) do TELEGRAMS.W:=Put.W; EOTGM:=ZZZZ(Put.W); DONE:=EOTGM; --next telegram is the NULL telegram! end Put; end loop NON_NULL_TELEGRAMS; --NULL_TELEGRAM Put(" "); put_line("====================================="); end;