* RE: Escape Sequences in Strings
@ 2000-11-16 0:00 Jean Cohen
0 siblings, 0 replies; 23+ messages in thread
From: Jean Cohen @ 2000-11-16 0:00 UTC (permalink / raw)
>===== Original Message From Marin David Condic <mcondic.nospam@acm.org> =====
>John English wrote:
>
>> Hey guys, I agree completely, but I wanted to give a *short* answer,
>> not a complete package hierarchy with all the trimmings... and I
>> said it wasn't the way to go anyway... Give us a break!
>
>Good point. Sometimes we tend to "over answer" a question, possibly leading
>a newbie to believe that Ada is just too complicated to do what they want.
>With the original question, I thought the best thing was to explain how to
>do what the questioner wanted to do - use escape codes in a string.
>Presumably, if he learns this much, Ada is now useful to him. As he moves
>along with learning the language, it will probably become clear that there
>are better ways of structuring code to manipulate the cursor. Possibly, he
>was already in the process of building such a package and just wanted to
>know how to implement the low-level features? (Even in C++, you'd isolate
>this kind of thing at a low level - or learn rather quickly that you
>*should* have! :-)
>
>Let's keep the life of a newbie comfortable and possibly just suggest that
>there *are* better ways and wait to see if they ask...
Yours and others replies were very helpful regarding my original question.
John English answered my post just as I expected an answer to be like. The
additional comments were nevertheless helpful as well (specifically the
mention of the Latin1 character set and streams), since they illustrate a
little of "The Ada Way" of doing things. So again - thank you all!
Kind regards,
Jean Cohen
^ permalink raw reply [flat|nested] 23+ messages in thread
* Escape Sequences in Strings @ 2000-11-15 0:00 Jean Cohen 2000-11-15 0:00 ` Marin David Condic ` (4 more replies) 0 siblings, 5 replies; 23+ messages in thread From: Jean Cohen @ 2000-11-15 0:00 UTC (permalink / raw) I'm quite new to Ada and consider a transition from C++, therefore I am still evaluating the benefits of the language. There is a minor annoyance (minor in terms of importance) which plagues me ever since: what about ANSI escape sequences in strings? As you all certainly know it is quite easy and straightforward in C++ to set cursor positions, the format (tabulators, newlines etc.) of a string etc. by using escape sequences. (by the way, I like the concept of streams in C++.) My question is then - How is it possible to use escape sequences (or something functionally equivalent) in Ada 95? Thanks for your replies, Jean Cohen ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 Jean Cohen @ 2000-11-15 0:00 ` Marin David Condic 2000-11-15 0:00 ` Preben Randhol ` (3 subsequent siblings) 4 siblings, 0 replies; 23+ messages in thread From: Marin David Condic @ 2000-11-15 0:00 UTC (permalink / raw) Jean Cohen wrote: > (by the way, I like the concept of streams in C++.) > Ada has streams and stream I/O as well. It works pretty well and I think if you get familiar enough with Ada to understand "The Ada Way" of doing it, you'll find it to be a handy feature. > > My question is then - How is it possible to use escape sequences (or > something > functionally equivalent) in Ada 95? Escape sequences are just a series of characters in Ada, pretty much as they are in C/C++. You can include non-printable characters into a string by using the constants defined in the package Ada.Characters.Latin_1. See Appendix A.3.3 of the ARM for the full list. However, you might find it easier to shop around for an existing package to do all your cursor moving for you. Start cruising around http://www.Adapower.com/ for reusable components and links to other Ada sites. I'm sure someone here will point you at more than one package to do this job for you. MDC -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "Giving money and power to Government is like giving whiskey and car keys to teenage boys." -- P. J. O'Rourke ====================================================================== ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 Jean Cohen 2000-11-15 0:00 ` Marin David Condic @ 2000-11-15 0:00 ` Preben Randhol 2000-11-15 0:00 ` John English ` (2 subsequent siblings) 4 siblings, 0 replies; 23+ messages in thread From: Preben Randhol @ 2000-11-15 0:00 UTC (permalink / raw) On Wed, 15 Nov 2000 05:07:12 -0500, Jean Cohen wrote: >I'm quite new to Ada and consider a transition from C++, therefore I am >still >evaluating the benefits of the language. > >There is a minor annoyance (minor in terms of importance) which plagues me >ever since: what about ANSI escape sequences in strings? As you all >certainly >know it is quite easy and straightforward in C++ to set cursor positions, >the >format (tabulators, newlines etc.) of a string etc. by using escape >sequences. Yes, though not necessarily the best solution. I recommend you use ncurses or some other library to do this. >(by the way, I like the concept of streams in C++.) > >My question is then - How is it possible to use escape sequences (or >something >functionally equivalent) in Ada 95? http://www.adapower.com/reuse/Formatted_Output.html -- Preben Randhol -- Ph.D Student -- http://www.pvv.org/~randhol -- Life is a habit ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 Jean Cohen 2000-11-15 0:00 ` Marin David Condic 2000-11-15 0:00 ` Preben Randhol @ 2000-11-15 0:00 ` John English 2000-11-15 0:00 ` Robert Dewar 2001-01-12 13:18 ` Andrew Hately 2001-01-12 19:37 ` tmoran 4 siblings, 1 reply; 23+ messages in thread From: John English @ 2000-11-15 0:00 UTC (permalink / raw) Jean Cohen wrote: > My question is then - How is it possible to use escape sequences (or > something functionally equivalent) in Ada 95? Escape sequences are easy enough: Ada.Text_IO.Put(ASCII.ESC & "[2J"); -- clear the screen (?) However, "something functionally equivalent" is probably a better way to go... ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk ----------------------------------------------------------------- ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 ` John English @ 2000-11-15 0:00 ` Robert Dewar 2000-11-15 0:00 ` Ehud Lamm 0 siblings, 1 reply; 23+ messages in thread From: Robert Dewar @ 2000-11-15 0:00 UTC (permalink / raw) In article <3A1275A2.F2A843E9@bton.ac.uk>, John English <je@bton.ac.uk> wrote: > Escape sequences are easy enough: > Ada.Text_IO.Put(ASCII.ESC & "[2J"); -- clear the screen But we would never want to do that in a program, and indeed Ada here helps us avoid the nasty habit of embedding odd escape sequences in strings in C without any comments, often with a result of making the program non-portable. The proper coding in Ada would be: Clear_Screen : constant String := ASCII.ESC & "[2J"; -- ANSI escape sequence for clearing screen. Modify to -- meet requirements of your system. Put (Clear_Screen); It is almost always wrong to have mysterious constants in code! Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 ` Robert Dewar @ 2000-11-15 0:00 ` Ehud Lamm 2000-11-16 0:00 ` John English 0 siblings, 1 reply; 23+ messages in thread From: Ehud Lamm @ 2000-11-15 0:00 UTC (permalink / raw) Robert Dewar <robert_dewar@my-deja.com> wrote in message news:8uub09$9sr$1@nnrp1.deja.com... > In article <3A1275A2.F2A843E9@bton.ac.uk>, > John English <je@bton.ac.uk> wrote: > > > Escape sequences are easy enough: > > Ada.Text_IO.Put(ASCII.ESC & "[2J"); -- clear the screen > > > But we would never want to do that in a program, and indeed > Ada here helps us avoid the nasty habit of embedding odd > escape sequences in strings in C without any comments, often > with a result of making the program non-portable. The proper > coding in Ada would be: > > Clear_Screen : constant String := ASCII.ESC & "[2J"; > -- ANSI escape sequence for clearing screen. Modify to > -- meet requirements of your system. > > Put (Clear_Screen); > > It is almost always wrong to have mysterious constants in code! > And while you are at it, put the constant in a seperate packge of env. specific control codes. -- Ehud Lamm mslamm@mscc.huji.ac.il http://purl.oclc.org/NET/ehudlamm <== Me! ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 ` Ehud Lamm @ 2000-11-16 0:00 ` John English 2000-11-16 0:00 ` Marin David Condic 2000-11-16 0:00 ` Tarjei T. Jensen 0 siblings, 2 replies; 23+ messages in thread From: John English @ 2000-11-16 0:00 UTC (permalink / raw) Ehud Lamm wrote: > Robert Dewar <robert_dewar@my-deja.com> wrote in message > news:8uub09$9sr$1@nnrp1.deja.com... > > In article <3A1275A2.F2A843E9@bton.ac.uk>, > > John English <je@bton.ac.uk> wrote: > > > > > Escape sequences are easy enough: > > > Ada.Text_IO.Put(ASCII.ESC & "[2J"); -- clear the screen > > > > > > But we would never want to do that in a program, and indeed > > Ada here helps us avoid the nasty habit of embedding odd > > escape sequences in strings in C without any comments, often > > with a result of making the program non-portable. The proper > > coding in Ada would be: > > > > Clear_Screen : constant String := ASCII.ESC & "[2J"; > > -- ANSI escape sequence for clearing screen. Modify to > > -- meet requirements of your system. > > > > Put (Clear_Screen); > > > > It is almost always wrong to have mysterious constants in code! > > > > And while you are at it, put the constant in a seperate packge of env. > specific control codes. > > -- > Ehud Lamm mslamm@mscc.huji.ac.il > http://purl.oclc.org/NET/ehudlamm <== Me! Hey guys, I agree completely, but I wanted to give a *short* answer, not a complete package hierarchy with all the trimmings... and I said it wasn't the way to go anyway... Give us a break! ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk ----------------------------------------------------------------- ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-16 0:00 ` John English @ 2000-11-16 0:00 ` Marin David Condic 2000-11-16 0:00 ` Tarjei T. Jensen 1 sibling, 0 replies; 23+ messages in thread From: Marin David Condic @ 2000-11-16 0:00 UTC (permalink / raw) John English wrote: > Hey guys, I agree completely, but I wanted to give a *short* answer, > not a complete package hierarchy with all the trimmings... and I > said it wasn't the way to go anyway... Give us a break! Good point. Sometimes we tend to "over answer" a question, possibly leading a newbie to believe that Ada is just too complicated to do what they want. With the original question, I thought the best thing was to explain how to do what the questioner wanted to do - use escape codes in a string. Presumably, if he learns this much, Ada is now useful to him. As he moves along with learning the language, it will probably become clear that there are better ways of structuring code to manipulate the cursor. Possibly, he was already in the process of building such a package and just wanted to know how to implement the low-level features? (Even in C++, you'd isolate this kind of thing at a low level - or learn rather quickly that you *should* have! :-) Let's keep the life of a newbie comfortable and possibly just suggest that there *are* better ways and wait to see if they ask... MDC -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "Giving money and power to Government is like giving whiskey and car keys to teenage boys." -- P. J. O'Rourke ====================================================================== ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-16 0:00 ` John English 2000-11-16 0:00 ` Marin David Condic @ 2000-11-16 0:00 ` Tarjei T. Jensen 2000-11-16 0:00 ` Ken Garlington 1 sibling, 1 reply; 23+ messages in thread From: Tarjei T. Jensen @ 2000-11-16 0:00 UTC (permalink / raw) John English >Hey guys, I agree completely, but I wanted to give a *short* answer, >not a complete package hierarchy with all the trimmings... and I >said it wasn't the way to go anyway... Give us a break! Perhaps even worse, it may not be what the person wanted to know. It is more likely that he wanted to know about the equivalent of the C escape characters like \n, \r, \a, \t, \oxXX, etc. Greetings, ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-16 0:00 ` Tarjei T. Jensen @ 2000-11-16 0:00 ` Ken Garlington 2000-11-16 0:00 ` Keith Thompson 2000-11-16 0:00 ` Marin David Condic 0 siblings, 2 replies; 23+ messages in thread From: Ken Garlington @ 2000-11-16 0:00 UTC (permalink / raw) "Tarjei T. Jensen" <tarjei.jensen@kvaerner.com> wrote in message news:8v0m76$1mt1@news.kvaerner.com... : : John English : >Hey guys, I agree completely, but I wanted to give a *short* answer, : >not a complete package hierarchy with all the trimmings... and I : >said it wasn't the way to go anyway... Give us a break! : : Perhaps even worse, it may not be what the person wanted to know. It is more : likely that he wanted to know about the equivalent of the C escape characters : like \n, \r, \a, \t, \oxXX, etc. Character C_Escape_Sequence Ada_Equivalent " \" "" or Ada.Characters.Latin_1.Quotation ' \' ' or Ada.Characters.Latin_1.Apostrophe ? \? ? or Ada.Characters.Latin_1.Question \ \\ \ or Ada.Characters.Latin_1.Reverse_Solidus BEL \a Ada.Characters.Latin_1.BEL BS \b Ada.Characters.Latin_1.BS FF \f Ada.Characters.Latin_1.FF NL \n Ada.Characters.Latin_1.NL CR \r Ada.Characters.Latin_1.CR HT \t Ada.Characters.Latin_1.HT VT \v Ada.Characters.Latin_1.VT octal \ddd Character'Val(8#ddd#) hex \xhh Character'Val(16#hh#) For Ada83 compilers, ASCII can be used in lieu of Ada.Characters.Latin_1 in most cases (with Query for Question and Back_Slash for Reverse_Solidus). ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-16 0:00 ` Ken Garlington @ 2000-11-16 0:00 ` Keith Thompson 2000-11-16 0:00 ` Marin David Condic 1 sibling, 0 replies; 23+ messages in thread From: Keith Thompson @ 2000-11-16 0:00 UTC (permalink / raw) "Ken Garlington" <Ken.Garlington@computer.org> writes: [...] > NL \n Ada.Characters.Latin_1.NL There is no Ada.Characters.Latin_1.NL. The C '\n' character is most commonly LF (linefeed). In general, it's whatever acts as a newline character on the current system. On some systems, the I/O subsystem has to map '\n' to a CR LF sequence on output, and do the reverse mapping on input. -- Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst> Welcome to the last year of the 20th century. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-16 0:00 ` Ken Garlington 2000-11-16 0:00 ` Keith Thompson @ 2000-11-16 0:00 ` Marin David Condic 1 sibling, 0 replies; 23+ messages in thread From: Marin David Condic @ 2000-11-16 0:00 UTC (permalink / raw) Ken Garlington wrote: > Character C_Escape_Sequence Ada_Equivalent > " \" "" or Ada.Characters.Latin_1.Quotation > ' \' ' or Ada.Characters.Latin_1.Apostrophe > ? \? ? or Ada.Characters.Latin_1.Question > \ \\ \ or Ada.Characters.Latin_1.Reverse_Solidus > BEL \a Ada.Characters.Latin_1.BEL > BS \b Ada.Characters.Latin_1.BS > FF \f Ada.Characters.Latin_1.FF > NL \n Ada.Characters.Latin_1.NL > CR \r Ada.Characters.Latin_1.CR > HT \t Ada.Characters.Latin_1.HT > VT \v Ada.Characters.Latin_1.VT > octal \ddd Character'Val(8#ddd#) > hex \xhh Character'Val(16#hh#) And you can even avoid the verbosity (if desired) using a "use" clause as in: with Ada.Characters.Latin_1 ; use Ada.Characters.Latin_1 ; procedure Demo is Some_String : constant String := "Ring the bell: " & BEL & "New Page: " & FF ; begin null ; end Demo ; Its pretty obvious to us Ada Old Timers, but a newbie might see "Ring the bell: " & Ada.Characters.Latin_1.BEL as so needlessly verbose that they'll run off telling everyone that Ada sucks because they can't write "Ring the bell: \a". If it were true, they'd have a point. Just a small thing - but often something we forget. MDC -- ====================================================================== Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m Visit my web site at: http://www.mcondic.com/ "Giving money and power to Government is like giving whiskey and car keys to teenage boys." -- P. J. O'Rourke ====================================================================== ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 Jean Cohen ` (2 preceding siblings ...) 2000-11-15 0:00 ` John English @ 2001-01-12 13:18 ` Andrew Hately 2001-01-12 20:03 ` Keith Thompson 2001-01-12 19:37 ` tmoran 4 siblings, 1 reply; 23+ messages in thread From: Andrew Hately @ 2001-01-12 13:18 UTC (permalink / raw) Jean Cohen wrote: > > I'm quite new to Ada and consider a transition from C++ Welcome. Its very hard to go back. > As you all certainly know it is quite easy and > straightforward in C++ to set cursor positions, > the format (tabulators, newlines etc.) of a string etc. by using escape > sequences. IMHO Ada is easier and more straight forward. See section A.10 of the Ada Reference manual. "Text Input-Output" especially A.10.5 "Operations on Columns, Lines and Pages" Andrew Hately shameless plug: http://www.ada-europe.org/conference2001.html ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-12 13:18 ` Andrew Hately @ 2001-01-12 20:03 ` Keith Thompson 2001-01-18 8:29 ` Lao Xiao Hai 0 siblings, 1 reply; 23+ messages in thread From: Keith Thompson @ 2001-01-12 20:03 UTC (permalink / raw) Andrew Hately <hat@cfmu.eurocontrol.be> writes: > Jean Cohen wrote: [...] > > As you all certainly know it is quite easy and > > straightforward in C++ to set cursor positions, > > the format (tabulators, newlines etc.) of a string etc. by using escape > > sequences. > > IMHO Ada is easier and more straight forward. > See section A.10 of the Ada Reference manual. "Text Input-Output" > especially A.10.5 "Operations on Columns, Lines and Pages" It depends on what you're trying to do. If you want to do things like moving the cursor to a specified position on the screen, neither C++ nor Ada helps you much unless you use a library designed for the purpose (curses, ncurses, terminfo, termcap). Ada's New_Page procedure doesn't necessarily perform any specific action if you're writing to a terminal; the only thing really guaranteed is that if you're writing to a file, it writes something that will be recognized as a page break when the file is read using Ada.Text_IO. -- Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst> MAKE MONEY FAST!! DON'T FEED IT!! ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-12 20:03 ` Keith Thompson @ 2001-01-18 8:29 ` Lao Xiao Hai 2001-01-18 15:22 ` Robert Dewar 0 siblings, 1 reply; 23+ messages in thread From: Lao Xiao Hai @ 2001-01-18 8:29 UTC (permalink / raw) Instead of moving the cursor using Text_IO, I have seen a very interesting Ada program written by a Japanese programmer that used the low-level features of the language to directly reference Address Location Hexadecimal B800 to manipulate the screen mappings. This turns out to be quite easy with Ada. And it is really fast if you are doing high-speed game programming. No ESC sequences required. Richard Riehle ------------------------------------------------------------------------------------- Keith Thompson wrote: > Andrew Hately <hat@cfmu.eurocontrol.be> writes: > > Jean Cohen wrote: > [...] > > > As you all certainly know it is quite easy and > > > straightforward in C++ to set cursor positions, > > > the format (tabulators, newlines etc.) of a string etc. by using escape > > > sequences. > > > > IMHO Ada is easier and more straight forward. > > See section A.10 of the Ada Reference manual. "Text Input-Output" > > especially A.10.5 "Operations on Columns, Lines and Pages" > > It depends on what you're trying to do. If you want to do things like > moving the cursor to a specified position on the screen, neither C++ > nor Ada helps you much unless you use a library designed for the > purpose (curses, ncurses, terminfo, termcap). Ada's New_Page > procedure doesn't necessarily perform any specific action if you're > writing to a terminal; the only thing really guaranteed is that if > you're writing to a file, it writes something that will be recognized > as a page break when the file is read using Ada.Text_IO. > > -- > Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> > San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst> > MAKE MONEY FAST!! DON'T FEED IT!! ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-18 8:29 ` Lao Xiao Hai @ 2001-01-18 15:22 ` Robert Dewar 2001-01-18 22:43 ` Randy Brukardt 2001-01-21 11:54 ` Dale Stanbrough 0 siblings, 2 replies; 23+ messages in thread From: Robert Dewar @ 2001-01-18 15:22 UTC (permalink / raw) In article <3A66A95F.61C03A3B@ix.netcom.com>, Lao Xiao Hai <laoxhai@ix.netcom.com> wrote: > Instead of moving the cursor using Text_IO, I have seen a very interesting > Ada program written by a Japanese programmer that used the low-level > features of the language to directly reference Address Location > Hexadecimal B800 to manipulate the screen mappings. This turns out > to be quite easy with Ada. And it is really fast if you are doing high-speed > game programming. No ESC sequences required. Ummm yes, well if you are running a 16-bit DOS environment, and all you want is super low resolution character output, but this is definitely a gasp-from-the-past (by the way, this is not somehow some secret programming trick known only to obscure Japanese programmers, it was absolutely standard in early DOS days). Of course very few Ada compilers ever operated in this kind of environment (RR and Janus only) Sent via Deja.com http://www.deja.com/ ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-18 15:22 ` Robert Dewar @ 2001-01-18 22:43 ` Randy Brukardt 2001-01-21 11:54 ` Dale Stanbrough 1 sibling, 0 replies; 23+ messages in thread From: Randy Brukardt @ 2001-01-18 22:43 UTC (permalink / raw) Robert Dewar wrote in message <9471mj$8a5$1@nnrp1.deja.com>... >Ummm yes, well if you are running a 16-bit DOS environment, >and all you want is super low resolution character output, >but this is definitely a gasp-from-the-past > >(by the way, this is not somehow some secret programming trick >known only to obscure Japanese programmers, it was absolutely >standard in early DOS days). Of course very few Ada compilers >ever operated in this kind of environment (RR and Janus only) Robert is right: it's hardly an obscure trick. The "Windows" package that someone donated to our public software archive in 1983 worked this way. More recently, the DOS version of the "JWindows" packages also used direct hardware access. ("JWindows" also supported "high resolution" graphics screens (i.e. VGA) with 50-line windows.) But none of that works on Windows NT or 2000, and most of it only works in DOS mode on Windows 95 or 98, making it too obnoxious to use even on those systems. Randy. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-18 15:22 ` Robert Dewar 2001-01-18 22:43 ` Randy Brukardt @ 2001-01-21 11:54 ` Dale Stanbrough 1 sibling, 0 replies; 23+ messages in thread From: Dale Stanbrough @ 2001-01-21 11:54 UTC (permalink / raw) Robert Dewar wrote: > Of course very few Ada compilers > ever operated in this kind of environment (RR and Janus only) The Meridian Ada compiler also did this. I wrote a package that did a similar thing to allow for various screen based output routines using this compiler. Dale ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2000-11-15 0:00 Jean Cohen ` (3 preceding siblings ...) 2001-01-12 13:18 ` Andrew Hately @ 2001-01-12 19:37 ` tmoran 2001-01-13 1:38 ` Robert Dewar 4 siblings, 1 reply; 23+ messages in thread From: tmoran @ 2001-01-12 19:37 UTC (permalink / raw) > straightforward in C++ to set cursor positions, > the format (tabulators, newlines etc.) of a string etc. by using escape > sequences. Ada.Text_IO.Put(ascii.esc & "[0p"); (My memory of these is hazy so that particular example may make no sense.) A better way is to define routines to clear the screen, set position, etc. Check: http://www.seas.gwu.edu/faculty/mfeldman/papers/portable-diners.html ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-12 19:37 ` tmoran @ 2001-01-13 1:38 ` Robert Dewar 2001-01-13 6:48 ` tmoran 0 siblings, 1 reply; 23+ messages in thread From: Robert Dewar @ 2001-01-13 1:38 UTC (permalink / raw) In article <e2J76.118602$A06.3833145@news1.frmt1.sfba.home.com>, tmoran@acm.org wrote: > Ada.Text_IO.Put(ascii.esc & "[0p"); If I saw this in code, I would be unhappy. Mysterious constants have no place appearing like this. Better style is Home_Cursor constant String := Ascii.ESC & "[0p"; -- Sequence for homing cursor Ada.Text_IO.Put (Home_Cursor & "hello there!"); Note that Ada requires that the concatenation be done at compile time, so no inefficiency is involved. Note: I don;t know if this is the home cursor command, I just use this for illustrating the style. Sent via Deja.com http://www.deja.com/ ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-13 1:38 ` Robert Dewar @ 2001-01-13 6:48 ` tmoran 2001-01-13 18:36 ` Robert Dewar 0 siblings, 1 reply; 23+ messages in thread From: tmoran @ 2001-01-13 6:48 UTC (permalink / raw) In article <93objj$guk$1@nnrp1.deja.com>, robert_dewar@my-deja.com wrote: > Ada.Text_IO.Put (Home_Cursor & "hello there!"); If I saw this in real code, I would be unhappy. It assumes a) that cursor positioning is done by sending a special string, b) that this greeting string should always be placed at cursor home position, c) that the string will always be "hello there!". A more thorough application of information hiding would have a low level routine "Home_Cursor" used by a mid-level routine "Move_To_Greeting_Field" which would be followed by output of a Greeting string from a set of message string constants. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Escape Sequences in Strings 2001-01-13 6:48 ` tmoran @ 2001-01-13 18:36 ` Robert Dewar 0 siblings, 0 replies; 23+ messages in thread From: Robert Dewar @ 2001-01-13 18:36 UTC (permalink / raw) In article <ZSS76.120778$A06.3893142@news1.frmt1.sfba.home.com>, tmoran@acm.org wrote: > In article > <93objj$guk$1@nnrp1.deja.com>, > robert_dewar@my-deja.com wrote: > > > Ada.Text_IO.Put (Home_Cursor & "hello there!"); You are completely (perhaps deliberately? :-) misreading what I wrote. I was just reacting to your code that embedded a peculiar constant string, and using the above statement to illustrate that if you do want to send strange strings to Put, they should be sent using named constants, that's all! > If I saw this in real code, I would be unhappy. It assumes: > a) that cursor positioning is done by sending a special > string Yes, indeed it assumes that, and that is true at the lowest level in some systems, so at the lowest level, you will see code like this. > b) that this greeting string should always be placed at > cursor home position Sure, that is the assumption in the example, if it is not true of your case, you have to change the example. > c) that the string will always be "hello there!". Sure, that is the assumption in the example, if it is not true of your case, you have to change the example. Note: for my own taste, I hate to present-by-example, and I hate examples, but my experience is most people like examples. For instance, most people want MORE examples in the RM, I regard them as irritating redundant (well hopefully redundant) non-normative junk :-) > A more thorough application of information hiding would > have a low level routine "Home_Cursor" I was of course just showing the kind of code that might appear in low level routines. > used by a mid-level > routine "Move_To_Greeting_Field" which would be followed by > output of a Greeting string from a set of message string > constants. Well such a structure might be appropriate depending on the application. If the program at hand has the following spec, as a homework assignment might: Print "hello there!" at the home position on your screen, then this amount of structure would be overkill. You do sometimes see students doing this kind of thing (making mountains out of molehills :-) But Tom, the real point that I was making is that REGARDLESS of the structure or requirements of your program, NEVER EVER put junk constants in the code, that was the ONLY point I was making, I was not writing a treatise on how to do the abstract top down structure of a program that puts information on the screen. I really think it is bad practice to EVER write even example code that has junk constants in it, as your example did. Yes, it is easy to do when we are being lazy, but it sets a bad example (I certainly have done this in examples in the past, if you go through my own posts, but that does not make it right). I find all the time that people put junk constants in code. MINIMAL (the language which I designed solely for the purpose of writing one program, namely MACRO-SPITBOL) is the only language I know that completely forbids constants except in constant declarations. That's a little fierce, because constants like 1 and 0, and perhaps 2 can reasonably appear in that form, and it is also OK to use constants which are fudnamental to the problem in some cases e.g. 7 for days of the week, but even there naming the 7 as Days_Per_Week can clarify code. Sent via Deja.com http://www.deja.com/ ^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2001-01-21 11:54 UTC | newest] Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-11-16 0:00 Escape Sequences in Strings Jean Cohen -- strict thread matches above, loose matches on Subject: below -- 2000-11-15 0:00 Jean Cohen 2000-11-15 0:00 ` Marin David Condic 2000-11-15 0:00 ` Preben Randhol 2000-11-15 0:00 ` John English 2000-11-15 0:00 ` Robert Dewar 2000-11-15 0:00 ` Ehud Lamm 2000-11-16 0:00 ` John English 2000-11-16 0:00 ` Marin David Condic 2000-11-16 0:00 ` Tarjei T. Jensen 2000-11-16 0:00 ` Ken Garlington 2000-11-16 0:00 ` Keith Thompson 2000-11-16 0:00 ` Marin David Condic 2001-01-12 13:18 ` Andrew Hately 2001-01-12 20:03 ` Keith Thompson 2001-01-18 8:29 ` Lao Xiao Hai 2001-01-18 15:22 ` Robert Dewar 2001-01-18 22:43 ` Randy Brukardt 2001-01-21 11:54 ` Dale Stanbrough 2001-01-12 19:37 ` tmoran 2001-01-13 1:38 ` Robert Dewar 2001-01-13 6:48 ` tmoran 2001-01-13 18:36 ` Robert Dewar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox