Newsgroups: comp.lang.pascal Path: utzoo!utgpu!watserv1!maytag!watstat.waterloo.edu!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Subject: Re: Long strings in TP Message-ID: <1991Feb15.205214.28291@maytag.waterloo.edu> Sender: daemon@maytag.waterloo.edu (Admin) Organization: University of Waterloo References: <1991Feb15.162333.24408@cunixf.cc.columbia.edu> Date: Fri, 15 Feb 1991 20:52:14 GMT Lines: 31 In article <1991Feb15.162333.24408@cunixf.cc.columbia.edu> stone@cunixb.cc.columbia.edu (Glenn Stone) writes: >Pardon me if this is a common question, but: > >What's the best way to implement a long string variable, say 600 chars? That depends on what you want to do with it. If you don't need to know the length, and it doesn't change much, and you don't use nulls in the strings, probably C-style null terminated strings are best. Turbo and Object Professional from TurboPower provide units to handle these, but they aren't hard to write yourself. If you want to do a lot of manipulation on the strings, a record with a length word at the start would probably be best, something like type longstring = record length : word; chars : array[1..600] of char; end; Again you'll have to write (or find) routines to do all the usual operations on these, since the TP library doesn't have them. If you allocate these in the heap, you can allocate just as much as you need, and easily deallocate them, using GetMem and FreeMem. Hope this helps. Duncan Murdoch dmurdoch@watstat.waterloo.edu