Sign in Join
Wiki copytemporary

Revision 1 of 1, by Trev on 2-21-2020. The page as it is now.

New

Back to Reserved words.

The reserved word new:

Example 1:

pascal
  var
   intI : ^ Integer ;

 begin
   ...
   if assigned ( intI ) then ... // Checks whether an address has been assigned to intI
   ...
   new ( intI ) ;  // Assigns a valid address to intI
   ...
   dispose ( intI ) ;  // Releases the address
   ...

Example 2:

pascal
  grade
   PListItem = ^ TListItem ;
   TListItem = record
     data : string ;
     next : PListItem ;  // reference to the next element
   end ;

 var
   List : PListItem ;

 begin
   ...
   New ( list ^. Next ) ;  // Adds a new item to the list
   List ^.  next ^.  data : = '' ;  // empties the element
   List ^.  next ^.  next : = nil ;  // sets the following pointer to nothing for security
   ...
   dispose ( list ) ;  // Releases the list
   ...

From the Free Pascal wiki, page "New", as it stood on 2020-02-21 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.