🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.flame.pascal
Article #51

Re: Help !!! Can't save pointer list to file

#51
From: Haruo Toda
Date: Wed, 12 Mar 1997 00:00
72 lines
2763 bytes
In article <01bc2d75$4541e060$LocalHost@host.telepac.pt>, 
"Hugo Palma" <hmpalma@mail.telepac.pt> wrote:

> I'm doing a project,but i'm just not able to save a variable of type LIST
> as shown below.
> I'm only able to save the first segment of the list,and none of the next.
> Can anyone please help me.
> Thanks.
> 
> type
>    list=^no;
>    no=record
>       v:integer;
>       seg:list;
>       end;
> 
> var
>    p:list;
> 
> 
> 
> Please reply to :
> hmpalma@mail.telepac.pt

Hi, Hugo,

  Your code fragment is not enough.  The 'list' type is typical record for
'Linear List' items.  There are some way to build a linear list from this
type.  How do you build it?

  for very easy example, consider the following code;

Program SomeProgram;
type
  list = ^no
  no = record
    v : integer;
    seg : list
  end;
var
  root, p : list;
  f          : file of integer;
begin
(* building up a LIFO linear list *)
  root := nil;
  while {more data} do begin
     new(p);
     p^.v := {data};
     p^.seg := root;
     root := p
  end;
(* save it *)
  {set up f}
  p := root;
  while p<>nil do begin
     write(f, p^.v);
     p := p^.seg
  end;
  {close f}
...
end.

  It is important that saving pointer itself (i.e. saving p or p^.seg )
has no meaning and must be avoided.  Because pointer variables are
carrying addresses of contents and the addresses varies run-to-run
(under many modern OSs).

Haruo.

-- 
Haruo Toda, Niigata Univ.
Technical Details
Message-ID: <toda-1203971053180001@ph1pc3.med.niigata-u.ac.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bc2d75$4541e060$LocalHost@host.telepac.pt>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10261c,e6cf518a5140afcc
X-Google-Attributes: gid10261c,public
X-Google-Thread: 10a7f1,e6cf518a5140afcc
X-Google-Attributes: gid10a7f1,public
X-Google-Thread: 10baee,e6cf518a5140afcc
X-Google-Attributes: gid10baee,public
X-Google-Thread: 1006de,e6cf518a5140afcc
X-Google-Attributes: gid1006de,public
X-Google-Thread: 102601,e6cf518a5140afcc
X-Google-Attributes: gid102601,public
X-Google-Thread: 10eb32,e6cf518a5140afcc
X-Google-Attributes: gid10eb32,public
X-Google-Thread: ff90a,e6cf518a5140afcc
X-Google-Attributes: gidff90a,public
X-Google-Thread: 10c950,e6cf518a5140afcc
X-Google-Attributes: gid10c950,public
From: toda@med.niigata-u.ac.jp (Haruo Toda)
Subject: Re: Help !!! Can't save pointer list to file
Date: 1997/03/12
Message-ID: <toda-1203971053180001@ph1pc3.med.niigata-u.ac.jp>
X-Deja-AN: 224815078
References: <01bc2d75$4541e060$LocalHost@host.telepac.pt>
Organization: Niigata Univ, Med, Physiol.
Newsgroups: alt.flame.pascal,comp.lang.pascal.ansi-iso,comp.lang.pascal.delphi.misc,comp.lang.pascal.misc,ctdl.lang.pascal,de.comp.lang.pascal.delphi,de.comp.lang.pascal.misc,fj.lang.pascal,fr.comp.lang.pascal,maus.lang.tpascal,relcom.comp.lang.pascal,relc