Path: utzoo!attcan!uunet!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!telfon.enet.dec.com!mailman From: mailman@telfon.enet.dec.com (Steven M. Mailman) Newsgroups: comp.lang.pascal Subject: Re: Defining variable lenght arrays Message-ID: <16401@shlump.nac.dec.com> Date: 16 Oct 90 16:49:59 GMT Sender: newsdaemon@shlump.nac.dec.com Organization: Digital Equipment Corporation Lines: 35 In article <24785@adm.BRL.MIL>, BESKO%MSUNSCL.BITNET@uga.cc.uga.edu writes... > >Does anyone know if it is possible and how to define a variable length char >array in VAX Pascal? Any information would be helpful. > There are multiple ways. The 2nd & 3rd are new in VAX Pascal V4.0. {1} { variable length text; max size of 80 characters } VAR x : VARYING [80] OF Char; x := 'text'; Writeln( x.length ); {prints 4} {2} { regular PACKED ARRAY of Char but length is specified at run-time } TYPE pac( Length:Integer ) = PACKED ARRAY [1..Length] OF Char; VAR x : pac(run-time-expression); x := 'text'; {text is blank padded to correct size} Writeln( x.length ); {prints length captured in declaration} {3} { variable length text with max length specified at run-time } VAR x : String(run-time-expression); x := 'text'; Writeln( x.length ); {prints 4} Writeln( x.capacity ); {prints max-size captured in declaration} Steve Mailman Digital Equipment Corporation mailman@tle.enet.dec.com Disclaimer: The opinions and statements expressed by me are not necessarily those of Digital Equipment Corporation.