{ The good old 'Hello World' program made in HighSpeed Pascal }
{ This is a translation of the RKM example and does it the hard
  way of calling the operating system directly }
  
Program HelloWorld;
Uses Exec, Graphics, Intuition;


var
  MyNewWindow: tNewWindow;
  MyNewScreen: tNewScreen;

  FontName: String;
  Title:    String;
  WTitle:   String;
  Message:	String;
  MyFont:   tTextAttr;

  MyScreen: pScreen;
  MyWindow: pWindow;
  L: Longint;

  {$ifdef WORKBENCH_2}
  junk:		boolean;
  {$endif}


begin
  GfxBase:=pGfxBase(OpenLibrary('graphics.library',0));
  IntuitionBase:=pIntuitionBase(OpenLibrary('intuition.library',0));

  FontName := 'topaz.font'#0;
  with MyFont do begin
    ta_Name		:= @FontName[1];
    ta_YSize	:= TOPAZ_SIXTY;
    ta_Style	:= FS_NORMAL;
    ta_Flags	:= FPF_ROMFONT;
  end;

  Title := 'HighSpeed Pascal Screen'#0;
  with MyNewScreen do begin
    LeftEdge:=0;
    TopEdge:=0;
    Width:=320;
    Height:=200;
    Depth:=2;
    DetailPen:=0;
    BlockPen:=1;
    ViewModes:=0;
    Type_:=CUSTOMSCREEN;
    Font:=@MyFont;
    DefaultTitle:=@Title[1];
    Gadgets:=NIL;
    CustomBitMap:=NIL;
  end;
  MyScreen:=OpenScreen(@MyNewScreen);
  if MyScreen=NIL then Halt(1);

  WTitle := 'A Simple Window'#0;
  with MyNewWindow do begin
    LeftEdge:=20;
    TopEdge:=20;
    Width:=300;
    Height:=100;
    DetailPen:=0;
    BlockPen:=1;
    Title:=@WTitle[1];
    Flags:=WINDOWCLOSE or SMART_REFRESH or
           ACTIVATE or WINDOWSIZING or
           WINDOWDRAG or WINDOWDEPTH;
    IDCMPFlags:=CLOSEWINDOW_;
    Type_:=CUSTOMSCREEN;
    FirstGadget:=NIL;
    CheckMark:=NIL;
    Screen:=MyScreen;
    BitMap:=NIL;
    MinWidth:=100;
    MinHeight:=25;
    MaxWidth:=640;
    MaxHeight:=200;
  end;
  MyWindow:=OpenWindow(@MyNewWindow);
  if MyWindow=NIL then begin
	{$ifdef WORKBENCH_2}
	junk := {ignore return code}
	{$endif}
    CloseScreen(MyScreen);          {Remove the screen opened before}
    halt(2);
  end;

  Message := 'Hello World';
  with MyWindow^ do begin
    Move_(RPort,20,20);
    Text_(RPort,@Message[1],Length(Message));
    L:=Wait(BitMask(UserPort^.MP_SIGBIT));
  end;

  CloseWindow(MyWindow);
  {$ifdef WORKBENCH_2}
  junk :=
  {$endif}
  CloseScreen(MyScreen);
  CloseLibrary(Pointer(IntuitionBase));
  CloseLibrary(Pointer(GfxBase));
end.
