Program JustifyStyle;
{ Linquistic High School # 20    }
{ SetTextJustify Sample program  }
uses
  Crt,Graph;
var
  {A loop variable}
  i: Integer;
  {Y coordinate}
  y: Integer;
begin
  { Set graphics mode at 256 colours}
  SetSVGAMode(640,480,8,LfbOrBanked);
  { Sets Y coordinate at first}
  y:=50;
  { Repeat for each combinations of the styles }
  for i:=1 to 9 do
    begin
      { Shows current CP as LightRed pixel}
      PutPixel( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,LightRed);
      { Increment the Y coordinates }
      inc(y,50);
    end;
  { Sets original Y coordinate }
  y:=50;
  { Sets Left and Bottom Text justification }
  SetTextJustify(LeftText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Bottom Text justification }
  SetTextJustify(CenterText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Bottom Text justification }
  SetTextJustify(RightText, BottomText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Bottom Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Left and Center Text justification }
  SetTextJustify(LeftText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Center Text justification }
  SetTextJustify(CenterText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Center Text justification }
  SetTextJustify(RightText, CenterText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Center Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Left and Top Text justification }
  SetTextJustify(LeftText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Left and Top Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Center and Top Text justification }
  SetTextJustify(CenterText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Center and Top Text');
  { Increment the Y coordinates }
  inc(y,50);
  { Sets Right and Top Text justification }
  SetTextJustify(RightText, TopText);
  OutTextXY( Succ(GetMaxX) div 2, Succ(GetMaxY)- y,'Right and Top Text');
  { Get the key pressed }
  ReadKey;
  { Return to the text mode }
  CloseGraph;
end.