Complete code listing:
PROGRAM HelloWorldGS;
USES
Globals,
Dialog,
Font,
Paint,
Window,
Print,
Menu,
Event;
FUNCTION StartUpTools : boolean;
const
DPForQuickDraw = $000;
DPForEventMgr = $300;
DPForCtlMgr = $400;
DPForLineEdit = $500;
DPForMenuMgr = $600;
DPForStdFile = $700;
DPForFontMgr = $800;
DPForPrintMgr = $900;
TotalDP = $B00;
var
toolRec : ToolTable;
paramBlock : FileRec;
baseDP : integer;
begin {StartUpTools}
StartUpTools := true;
TLStartUp;
CheckToolError($1);
MyMemoryID := MMStartUp;
MTStartUp;
CheckToolError($2);
{Allocate zero page memory for tools}
ToolsZeroPage := NewHandle(TotalDP, MyMemoryID, attrBank + attrFixed + attrLocked + attrPage, Ptr(0));
CheckToolError($3);
baseDP := LoWord(ToolsZeroPage^);
QDStartUp(baseDP + DPForQuickDraw, ScreenMode, MaxScan, MyMemoryID);
CheckToolError($4);
EMStartUp(baseDP + DPForEventMgr, 20, 0, MaxX, 0, 200, MyMemoryID);
CheckToolError($5);
MoveTo(20,20);
SetBackColor(0);
SetForeColor(15);
DrawString('One Moment Please...');
ShowCursor;
toolRec.NumTools := 14;
toolRec.Tools[1].TSNum := 4;
toolRec.Tools[1].MinVersion := 0;
toolRec.Tools[2].TSNum := 5;
toolRec.Tools[2].MinVersion := 0;
toolRec.Tools[3].TSNum := 6;
toolRec.Tools[3].MinVersion := 0;
toolRec.Tools[4].TSNum := 14;
toolRec.Tools[4].MinVersion := 0;
toolRec.Tools[5].TSNum := 15;
toolRec.Tools[5].MinVersion := 0;
toolRec.Tools[6].TSNum := 16;
toolRec.Tools[6].MinVersion := 0;
toolRec.Tools[7].TSNum := 18;
toolRec.Tools[7].MinVersion := 0;
toolRec.Tools[8].TSNum := 19;
toolRec.Tools[8].MinVersion := 0;
toolRec.Tools[9].TSNum := 20;
toolRec.Tools[9].MinVersion := 0;
toolRec.Tools[10].TSNum := 21;
toolRec.Tools[10].MinVersion := 0;
toolRec.Tools[11].TSNum := 22;
toolRec.Tools[11].MinVersion := 0;
toolRec.Tools[12].TSNum := 23;
toolRec.Tools[12].MinVersion := 0;
toolRec.Tools[13].TSNum := 27;
toolRec.Tools[13].MinVersion := 0;
toolRec.Tools[14].TSNum := 28;
toolRec.Tools[14].MinVersion := 0;
REPEAT
paramBlock.pathname := @'*/SYSTEM/TOOLS';
GET_FILE_INFO(paramBlock);
if toolErr <> 0 AND MountBootDisk = 1 then begin
StartUpTools := false;
Exit;
end;
UNTIL toolErr = 0;
LoadTools(toolRec);
CheckToolError($6);
WindStartUp(MyMemoryID);
CheckToolError($7);
RefreshDesktop(nil);
CtlStartUp(MyMemoryID, baseDP + DPForCtlMgr);
CheckToolError($8);
LEStartUp(baseDP + DPForLineEdit, MyMemoryID);
CheckToolError($9);
DialogStartUp(MyMemoryID);
CheckToolError($A);
MenuStartUp(MyMemoryID, baseDP + DPForMenuMgr);
CheckToolError($B)
DeskStartUp;
CheckToolError($C);
ShowPleaseWait;
SFStartUp(MyMemoryID, baseDP + DPForStdFile);
CheckToolError($D);
SFAllCaps(true);
QDAuxStartUp;
CheckToolError($E);
ListStartUp;
CheckToolError($10);
ScrapStartUp;
CheckToolError($11);
PMStartUp(MyMemoryID, baseDP + DPForPrintMgr);
CheckToolError($12);
HidePleaseWait;
InitCursor;
end; {StartUpTools}
PROCEDURE ShutDownTools;
begin
DeskShutDown;
if WindStatus <> 0 then
HideAllWindows;
ListShutDown;
FMShutDown;
ScrapShutDown;
PMShutDown;
QDAuxShutDown;
SFShutDown;
MenuShutDown;
DialogShutDown;
LEShutDown;
CtlShutDown;
WindShutDown;
EMShutDown;
QDShutDown;
MTShutDown;
if MMStatus <> 0 then begin
DisposeHandle(ToolsZeroPage);
MMShutDown(MyMemoryID);
end;
TLShutDown;
end;
PROCEDURE SetUpMenus;
var height : integer; {TODO: is this needed?}
begin
SetMTitleStart(10);
InsertMenu(NewMenu(@FontMenuStr[1]), 0);
InsertMenu(NewMenu(@WindowMenuStr[1]), 0);
InsertMenu(NewMenu(@EditMenuStr[1]), 0);
InsertMenu(NewMenu(@FileMenuStr[1]), 0);
InsertMenu(NewMenu(@AppleMenuStr[1]), 0);
FixAppleMenu(AppleMenuID);
height := FixMenuBar;
DrawMenuBar;
end;
BEGIN
InitGlobals;
if StartUpTools then begin
SetUpDefault;
SetUpMenus;
SetUpWindows;
MainEvent;
end;
ShutDownTools;
END.
Select Compile -> To Memory to run your program. You could also choose Compile -> To Disk to create a application
file that can be run on any IIgs. The program should ask you to type your name, then repeat it back to you after
you press enter. Pressing enter again will return you to Complete Pascal.