Listing 2. Hello World

#include "./resid.h"
#include <Common.h>
#include <System/SysAll.h>
#include <UI/UIAll.h>
static Word StartApplication(void);
static void EventLoop(void);
static Boolean MainFrmHandler(EventPtr p);
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchflags)
{
   Word error;
   if (cmd == sysAppLaunchCmdNormalLaunch)
   {
      error = StartApplication();
      if  (error) return error;
        EventLoop();
   }
   return 0;
}

static Word StartApplication(void)
{
   FrmGotoForm(MainFormId);
   return 0;
}
void EventLoop(void)
{
 short err;
 int   formID;
 FormPtr form;
 EventType event;
 do
 {
   EvtGetEvent(&event, 200);
   if (SysHandleEvent(&event)) continue;
   if (MenuHandleEvent((void *)0,&event, &err)) \
         continue;
   if (event.eType == frmLoadEvent)
      {
      formID = event.data.frmLoad.formID;
      form = FrmInitForm(formID);
      FrmSetActiveForm(form);
      switch (formID)
      {
        case MainFormId:
        FrmSetEventHandler(form, &MainFrmHandler);
        break;
      }
      }
  FrmDispatchEvent(&event);
  } while(event.eType != appStopEvent);
}
static Boolean MainFrmHandler(EventPtr event)
{
  int handled = 0;
  FormPtr form;
  int i;
  switch (event->eType)
  {
  case  frmOpenEvent:
   form = FrmGetActiveForm();
   FrmDrawForm(form);
   handled = 1;
   WinDrawChars((char *) "Hello World",11,100,50);
   break;

  case menuEvent:
     FrmAlert(alertID_about);
        handled = 1;
        break;
     }
   return handled;
}