Whatever you write in ???? and ??? should include setting result:=.
Beyond that, all I suggest is not to use Variant unless you genuinely need it.
Or if, as a beginner to Pascal, you want to explore how pointers work, do some simple test routines to make sure understand how they work with the usual Types such as String, PChar, Integer (perhaps including ShortInt and Smallint). And I wouldn't use Cardinal, as far as I know that is rarely used.