[fpc-pascal] Using Pointer : In Free pascal

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon Jul 7 10:06:07 CEST 2014

mokashe.ram wrote:
> Hi Guys,
>         I am using a pointer as shown below
>         Locat_Pointer= ^ Locate
>         Locate= Record
>                  next:locat_pointer;
>                   Code:word;
>        How to assign USer input to pointer variable run time in free pascal
> Like Below
>        Locate_Pointer^.code:=.....?

Yes, that's about right, use something like

         Locate_Pointer^.code:= w;

where w is a word read in using something like the example code Marco 
pointed you at a couple of days ago (if there's something you don't 
understand in that I suggest raising it in that thread, rather than 
starting another one).

Remember that you'll need to allocate each record with the next pointer 
set to nil, and will also need to deallocate each one precisely once 
when it's no longer needed. In practice most people would use a more 
recent structure such as a TList, TStringList etc., what you've got 
there is rather 1970s code and since then there's been consensus that 
programs don't have to be written by reimplementing Lisp.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list