From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7572f6fc8125b496 X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: How do I insert a carriage return into a multi-line text box (ObjectAda)? Date: 1997/09/12 Message-ID: <34198B19.6A91CDDB@hso.link.com>#1/1 X-Deja-AN: 271942592 References: <3416D21B.3366@cacd.rockwell.com> <341825F3.41C67EA6@swl.msd.ray.com> <34193D99.423914E7@elca-matrix.ch> Organization: Hughes Training Inc. - Houston Operations Newsgroups: comp.lang.ada Date: 1997-09-12T00:00:00+00:00 List-Id: Mats Weber wrote: > > > > [...] I can insert an ASCII code 13 (carriage return character), but > > > instead of performing a CR, a vertical bar (signifying a non-printable > > > character) is inserted into the text box. > > Have you tried using ASCII.LF (12) instead of CR ? LF is the standard line > separotor on most UNIX systems. There's the rub. Just what a compiler uses to delimite line, page, and EOF are not specified by the RM. While ASCII.LF is a pretty safe bet, it still introduces risk. The only way I can think of is to use file oriented text_io facilites and write the stuff to a file, then reopen it and use get ALL the characters back, delimiters and all. This seems like a kludge and may not be worth the extra work to deal with the potential variation of code given there are other, cheaper ways of dealing with code variation across target environment. Of course, one could simply define a package which declares character variables for each of these delimiters. The elaboration of the package could open a text_io file, do a new_line, new_page, and then close the file. Reopen the file and get two characters to fill in the delimiter variables via sequential_io a la (Ada 83) ... package Text_Io_Delimiters is Line_Terminator : Character; Page_Terminator : Character; end Text_Io_Delimiters; with Text_Io; with Sequential_Io; package body Text_Io_Delimiters is package Character_Sequential_Io is new Sequential_Io (Character); Inp_File : Character_Sequential_Io.File_Type; Out_File : Text_Io.File_Type; begin Character_Sequential_Io.Create (Inp_File, Character_Sequential_Io.In_File, ""); declare Name : constant String := Character_Sequential_Io.Name (Inp_File); begin Text_Io.Open (Out_File, Text_Io.Out_File, Name); Text_Io.New_Line (Out_File); Text_Io.New_Page (Out_File); Text_Io.Close (Out_File); end; Character_Sequential_Io.Read (Inp_File, Line_Terminator); Character_Sequential_Io.Read (Inp_File, Page_Terminator); Character_Sequential_Io.Close (Inp_File); end Text_Io_Delimiters; with Text_Io; with Text_Io_Delimiters; procedure Test_Text_Io_Delimiters is File : Text_Io.File_Type; begin Text_Io.Put_Line ("line_terminator => " & Natural'Image (Character'Pos (Text_Io_Delimiters.Line_Terminator))); Text_Io.Put_Line ("page_terminator => " & Natural'Image (Character'Pos (Text_Io_Delimiters.Page_Terminator))); end Test_Text_Io_Delimiters; ... with the above test program providing output ... line_terminator => 10 page_terminator => 12 ... for Apex on SGI IRIX. In Ada 95 you can even declare the package as ada.text_io.delimiters (a child package). -- Samuel T. Harris, Senior Engineer Hughes Training, Inc. - Houston Operations 2224 Bay Area Blvd. Houston, TX 77058-2099 "If you can make it, We can fake it!"