Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcso!bigelow From: bigelow@hpfcso.HP.COM (Jim Bigelow) Newsgroups: comp.lang.pascal Subject: Re: initialization of a string Message-ID: <9110015@hpfcso.HP.COM> Date: 9 Apr 90 15:33:55 GMT References: <7198@uhccux.uhcc.hawaii.edu> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 40 To write a string (either a packed array of char or the String data type) to a file that is not of type text, may require you to use a variant record. For instance, writing to a file of bytes can be done as follows: const sizeofstring := ; type varRec = packed record case boolean of true: (str : string); false: (byte : packed array[1..sizeofstring] of char); end; { for this to work the variants *MUST* have same size and alignment } var strng : varRec i: integer; f : file of char; . . . begin . . . strng.str := 'string less than or equal to '; for i := 1 to sizeofstring do write(f,string.byte[i]); . . . Hope this is helpful. Jim Bigelow HP9000/S300 Pascal Colorado Language Lab. HP Ft. Collins, CO