Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.pascal.borland    |    Borland Pascal was actually pretty neat    |    2,978 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,063 of 2,978    |
|    Femme Verbeek to HubbleBubble    |
|    Re: Dem Dar Dastardly Procedural Types    |
|    20 Feb 06 10:28:43    |
   
   From: fv@nospam.tcenl.com   
      
   HubbleBubble schreef:   
   > Finally I've got around to lerning about procedural types... the info I   
   > have is sketchy but I think I should be able to do this -   
   >   
   > program VerySimple;   
   >   
   > type   
   > NoArgPtr = procedure;   
   >   
   > var   
   > proc = procedure;   
   >   
   > procedure Hello;   
   > begin   
   > Writeln('Hello');   
   > end;   
   >   
   > begin   
   > proc := Hello;   
   > proc;   
   > end.   
   >   
   > Now I can't this to compile at all under BP7, TP7 - I get error 143   
   > invalid procedure or function reference at proc := Hello; or if I use   
   > the @operator then I get error 122 Invalid varaible reference.   
   >   
   > The thing is the former compiles and runs perfectly under virtual   
   > pascal. Please what am I doing wrong? I simply don't know enough about   
   > procedural types to know how to fix it.   
   >   
   > :)   
   >   
   You can also put the procedureal types in the header   
      
   {$F+} {Note the FAR compiler directive here}   
      
   type   
    IntFuncType = function (x, y : integer) : integer;   
      
   procedure DoSomething(Func : IntFuncType; x, y : integer);   
   begin   
    Writeln(Func(x, y):5);   
   end;   
      
   function AddEm(x, y : integer) : integer;   
   begin   
    AddEm := x + y;   
   end;   
      
   function SubEm(x, y : integer) : integer;   
   begin   
    SubEm := x - y;   
   end;   
      
   begin   
    DoSomething(AddEm, 1, 2);   
    DoSomething(SubEm, 1, 2);   
   end.   
      
      
   -- Femme   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca