comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel T. Harris" <s_harris@hso.link.com>
Subject: Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
Date: 1997/09/12
Date: 1997-09-12T00:00:00+00:00	[thread overview]
Message-ID: <34198B19.6A91CDDB@hso.link.com> (raw)
In-Reply-To: 34193D99.423914E7@elca-matrix.ch


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!"




  reply	other threads:[~1997-09-12  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-10  0:00 How do I insert a carriage return into a multi-line text box (ObjectAda)? Meyer Jeffrey D
1997-09-11  0:00 ` John Cupak {73739}
1997-09-12  0:00   ` Anonymous
1997-09-12  0:00   ` Mats Weber
1997-09-12  0:00     ` Samuel T. Harris [this message]
     [not found]       ` <34202BB9.1FE0@gsg.eds.com>
1997-09-18  0:00         ` Samuel T. Harris
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox