$MACRO swcaseg;
  {переключение регистра букв}
  DEF_INT(n,k,dot);
  DEF_CHAR(c);

  k := 0; INSERT_MODE := FALSE; dot := 1;
process:
  if AT_EOF then goto textend; end;
  if AT_EOL  then
     down; home; goto process; end;
  n := ASCII(CUR_CHAR);
  if n = 46  then dot := 1; end;
  if n < 65  then goto nextchar; end;
  if dot = 1 then goto convallow; end;
  if n < 91  then goto lower; end;
  if n < 97  then goto convallow; end;
  if n < 123 then goto upper; end;
  if n < 128 then goto convallow; end;
  if n < 144 then goto lower; end;
  if n < 160 then c := CHAR(n + 80); goto convert; end;
  if n < 176 then goto upper; end;
  if n < 224 then goto convallow; end;
  if n > 239 then goto convallow; end;
  c := CHAR(n - 80); goto convert;
upper:
  c := CHAR(n - 32); goto convert;
lower:
  c := CHAR(N + 32);
convert:
  TEXT(c); k := k + 1;
  goto process;
convallow:
  dot := 0;
nextchar:
  RIGHT; goto process;
textend:
  Make_message(str(k)+' letters converted.');
end_macro;

