comp.lang.ada
 help / color / mirror / Atom feed
* How do I insert a carriage return into a multi-line text box (ObjectAda)?
@ 1997-09-10  0:00 Meyer Jeffrey D
  1997-09-11  0:00 ` John Cupak {73739}
  0 siblings, 1 reply; 6+ messages in thread
From: Meyer Jeffrey D @ 1997-09-10  0:00 UTC (permalink / raw)



I am writing an application that is using a multi-line text box for a
status/output window.  I cannot, however, insert a carriage return
character to advance the cursor to the next line for a new status
output.  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.

Does anybody know if it possible to use a multi-line tet box in this
fashion, or do I need to wait for a version of ObjectAda that lets me
use OCX controls (such as a Rich Text Box)?

Thanks in advance,
Jeff Meyer




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
  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   ` Mats Weber
  1997-09-12  0:00   ` Anonymous
  0 siblings, 2 replies; 6+ messages in thread
From: John Cupak {73739} @ 1997-09-11  0:00 UTC (permalink / raw)



Meyer Jeffrey D wrote:
> 
> I am writing an application that is using a multi-line text box for a
> status/output window.  I cannot, however, insert a carriage return
> character to advance the cursor to the next line for a new status
> output.  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.
> 
> Does anybody know if it possible to use a multi-line tet box in this
> fashion, or do I need to wait for a version of ObjectAda that lets me
> use OCX controls (such as a Rich Text Box)?
> 
> Thanks in advance,
> Jeff Meyer

Jeff,

You should be able to concatenate the ASCII.NL character, as follows:

   Message : constant String := 
             "Are you REALLY sure you want to delete the file?" &
              ASCII.NL &
             "Select YES or NO button, below.";
          
-- 
----------------------------------------------------------------
-                   John J. Cupak Jr, CCP                      -
- Raytheon Electronic Systems: Software Engineering Laboratory -
- tel: 508-858-1222     email (work): jcj@swl.msd.ray.com      -
- fax: 508-858-4336     email (home): jcupak@aol.com           -
----------------------------------------------------------------




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
  1997-09-12  0:00   ` Mats Weber
@ 1997-09-12  0:00     ` Samuel T. Harris
       [not found]       ` <34202BB9.1FE0@gsg.eds.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Samuel T. Harris @ 1997-09-12  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
  1997-09-11  0:00 ` John Cupak {73739}
@ 1997-09-12  0:00   ` Mats Weber
  1997-09-12  0:00     ` Samuel T. Harris
  1997-09-12  0:00   ` Anonymous
  1 sibling, 1 reply; 6+ messages in thread
From: Mats Weber @ 1997-09-12  0:00 UTC (permalink / raw)



> > [...] 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.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
  1997-09-11  0:00 ` John Cupak {73739}
  1997-09-12  0:00   ` Mats Weber
@ 1997-09-12  0:00   ` Anonymous
  1 sibling, 0 replies; 6+ messages in thread
From: Anonymous @ 1997-09-12  0:00 UTC (permalink / raw)



<3416D21B.3366@cacd.rockwell.com>

On Thu, 11 Sep 1997 13:10:11 -0400, John Cupak {73739}
<jcj@swl.msd.ray.com> wrote:

> Meyer Jeffrey D wrote:
> > 
> > I am writing an application that is using a multi-line text box for a
> > status/output window.  I cannot, however, insert a carriage return
> > character to advance the cursor to the next line for a new status
> > output.  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.
> > 
> > Does anybody know if it possible to use a multi-line tet box in this
> > fashion, or do I need to wait for a version of ObjectAda that lets me
> > use OCX controls (such as a Rich Text Box)?
> > 
> > Thanks in advance,
> > Jeff Meyer
> 
> Jeff,
> 
> You should be able to concatenate the ASCII.NL character, as follows:
> 
>    Message : constant String := 
>              "Are you REALLY sure you want to delete the file?" &
>               ASCII.NL &
>              "Select YES or NO button, below.";

Except that NL is not defined in ASCII nor in Ada.Characters.Latin_1, so
this should not compile.

Jeff Carter  PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"I fart in your general direction."
Monty Python & the Holy Grail

Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/








^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I insert a carriage return into a multi-line text box (ObjectAda)?
       [not found]       ` <34202BB9.1FE0@gsg.eds.com>
@ 1997-09-18  0:00         ` Samuel T. Harris
  0 siblings, 0 replies; 6+ messages in thread
From: Samuel T. Harris @ 1997-09-18  0:00 UTC (permalink / raw)



Shmuel (Seymour J.) Metz wrote:
> 
> Samuel T. Harris wrote:
> >
> > 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.
> 
> It's worse than that; the operating system may not use *any* characters
> as end-of-line or end-of-page delimiters. Mainframes typically have
> record-oriented file systems, and any character can appear anywhere in a
> record.
> 

So true, so true. Shmuel here correctly points out that what a compiler
uses for line and page delimiters may not be used by the operating
system (especially if the OS uses none at all). Getting back to the
original question, we have no guarantee that the the line delimiter
used by the compiler will cause the desired multi-line output in
the dialog box. I have been hit with that one while trying to
put multi-line text in a single line dialog box (by mistake) and
getting annoying <LF> kinds of trash on a single line.

However, it is a pretty safe bet and a good first stab at the problem
in any situation. If it doesn't work for some reason, then find
which delimiters do work an use them instead.

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-09-18  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` Mats Weber
1997-09-12  0:00     ` Samuel T. Harris
     [not found]       ` <34202BB9.1FE0@gsg.eds.com>
1997-09-18  0:00         ` Samuel T. Harris
1997-09-12  0:00   ` Anonymous

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