(********************)
PROGRAM TP4EXC4 ;

USES crt ;

VAR S : string[75] ;
choix, souligne, marge : integer ;
cadre : char ;
i, j : integer ;

BEGIN
Clrscr ;
repeat
(* saisir la chaine *)
S:='' ;
writeln('CHAINE d''au plus 75 caracteres (vide pour terminer) ? ') ;
readln(S) ;
if S<>'' then repeat
(* choisir l'affichage *)
writeln ;
writeln('MENU : ') ;
writeln('1 pour afficher la chaine (et la souligner n fois)') ;
writeln('2 pour afficher la chaine dans un cadre') ;
writeln('3 pour afficher la chaine au milieu d''une ligne') ;
writeln('0 pour changer de chaine') ;
repeat readln(choix) until (choix>=0) and (choix<=3) ;
writeln ;
(* choisir les options et afficher *)
case choix of
1 : begin
write('combien de soulignement (0 … 20) ? ') ;
repeat readln(souligne) until (souligne<=20) and (souligne>=0) ;
writeln ;
writeln(S) ;
for i:=1 to souligne do
begin
for j:=1 to length(s) do write('-') ;
writeln ;
end ;
end ;
2 : begin
write('quel sera le caractere d''encadrement ? ') ;
readln(cadre) ;
for i:=1 to length(S)+4 do write(cadre) ; writeln ;
writeln(cadre,' ',S,' ',cadre) ;
for i:=1 to length(S)+4 do write(cadre) ; writeln ;
end ;
3 : begin
marge:=(80-length(S)) div 2 ;
writeln(S:marge+length(S)) ;
end ;
end ;
until choix=0 ;
until S='' ;
END.

(********************)