🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4948

Re: Clever way to deal with this?

#4948
From: R.X. Getter
Date: Thu, 15 Feb 1990 18:14
38 lines
1742 bytes
In article <1294@sys.uea.ac.uk> cmp8118@sys.uea.ac.uk (D.S. Cartwright) writes:
>MARK@UCF1VM.BITNET (Mark Woodruff) writes:
>
>Well, how about some sort of RECORD structure thus :
>
>	TYPE
>		VarString : POINTER TO CHAR ;
>
>		DataStructure : RECORD
>				 NoOfChars : CARDINAL ;
>				 Chars     : VarString ;
>				END (* RECORD *) ;
>
>	You could then knock up some little routine to handle the creation
>and general all-round handling of the linked list of characters without too
>much hassle, and all should [!!!! }:^)] be hunky-dory.
>
>		Dave C, SYS II, UEA, Norwich.
no, this won't work, you need VarString to be a pointer to a record,
sometimes called node which contains a character and a pointer to a new
node. then you can handle this as a linked list. The above will
work in C, but not in modula2.

try this:

TYPE
	VarString = POINTER TO Node;
	Node = RECORD
		char : CHAR;
		next : VarString;
	END; (* node *)

put this in with data structure, then be sure to set the terminating
pointer to NIL and handle this like you would any linked list.
don't forget to allocate memory with NEW() to get new nodes and 
deallocate it with DISPOSE() properly whenever you release a node.

Robert Getter.
Technical Details
Message-ID: <2220@ultb.isc.rit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!iuvax!rutgers!rochester!rit!ultb!rxg3321
References: <90043.054652MARK@UCF1VM.BITNET> <1294@sys.uea.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!iuvax!rutgers!rochester!rit!ultb!rxg3321
From: rxg3321@ultb.isc.rit.edu (R.X. Getter)
Newsgroups: comp.lang.modula2
Subject: Re: Clever way to deal with this?
Message-ID: <2220@ultb.isc.rit.edu>
Date: 15 Feb 90 18:14:57 GMT
References: <90043.054652MARK@UCF1VM.BITNET> <1294@sys.uea.ac.uk>
Reply-To: rxg3321@ultb.isc.rit.edu (R.X. Getter )
Organization: Information Systems and Computing @ RIT, Rochester, New York
Lines: 38