# Porting from Mac Pascal

Although FPC today supports many Mac Pascal constructs, there are a few of issues one has to be aware of. Tips to make the code work with GPC are also welcome.

## Missing CW Functions

CodeWarrior provided built in functions for stripping the Hi and Lo words from a longint. Although most uses of this have been deprecated over the years (like menu commands,) you may still need the functions for old code. Here are substitutions:

 function HiWrd(aLong: cardinal): word;

begin
HiWrd:= hi(aLong);
end;  { HiWrd }

 function LoWrd(aLong: cardinal): word;

begin
LoWrd:= lo(aLong);
end;  { LoWrd }


## UPP differences

In Codewarrior Pascal, one declared a UPP generically with an "@functionName" parameter. With Carbon, Apple introduced specific UPP creator functions, and with the change to FPC, you simply pass the functionName without the "@" symbol.

Thus,

 theRoutine:= NewAEEventHandlerUPP(@HandleODOC); // CW Apple Event Handler


becomes:

 theRoutine:= NewAEEventHandlerUPP(HandleODOC);  // FPC Apple Event Handler


## Four Character Codes (FCCs)

While FPC supports implicitly converting FCCs to integer constants to some extent, it does not do so in all cases. You can however always add an explicit typecast to OSType/Cardinal/LongWord around an FCC to ensure it is interpreted as an integer constant. This construct is endian-safe. For example: Cardinal('APPL').

## Result function result alias

FPC adds an implicit alias for the function result called result. This means that you cannot use local variables with the same name, as they will conflict with this identifier. The main reason is that using the function name itself is ambiguous in some situations (e.g., when passing it as a parameter to another routine it usually refers to the function result, but it can also mean the function itself as procedural variable).