[comp.lang.modula2] beginner's stupid question

don@vax1.acs.udel.EDU (Donald R Lloyd) (05/12/89)

        I'm a freshman EE major here at the U of Delaware, taking my first      course in Modula 2.  It seems to be a decent language (of course, my only       previous language experience was in BASIC on a c-128 & a little LISP last       semester, so ANY language seems decent to me at this point).
	I generally have no problem doing the programming assignments we're     given (although I do spend a heckuvalotta time removing parsing errors), most ofwhich just consist of reading in & manipulating records in various ways.        Anyway, one thing I've been trying to do all semester, just to 'spruce up' the  screen output, is to CLEAR the %^&$%$%^ SCREEN from modula!!!  
	So far, I've had no luck.  I've tried messing around with IMPORT        @EXTERNAL (like in the unix.def file) clear, but really had no idea how IMPORT  @EXT works, so I had no luck.
	Is there some way to print a control character or ASCII code that will  clear the screen?  Can somebody come up with a relatively simple, short method  of clearing the screen and explain it to me (mail it)?  I absolutely despise    programs that don't clear the screen when I run them (for the most part).

	By the way, I'm using the 'mod' compiler on a vax under unix 4.3.


	Thanks,


------------------      Don Lloyd
|  Gibberish is  |      El Campeador
|     spoken     |      don@vax1.acs.udel.edu
|      here.     |      I'd give out my phone number, but it's always 
------------------         busy anyway. 
DISCLAIMER:  My employers wouldn't understand my babbling even if they did know                how to read it.

don@vax1.acs.udel.EDU (Donald R Lloyd) (05/12/89)

In article <3610@udccvax1.acs.udel.EDU> don@vax1.acs.udel.EDU (Donald R Lloyd) writes:
>	Is there some way to print a control character or ASCII code that will  clear the screen?  Can somebody come up with a relatively simple, short method  of clearing the screen and explain it to me (etc....)
>

      I probably should have also said that I'd like to bring the cursor back   to the 'home' position (top right).  It's easy enough to print 26 lines on the  screen, but I'd like to be able to simulate 'clear'.
      Thanks to those who responded.

------------------      Don Lloyd
|  Gibberish is  |      El Campeador
|     spoken     |      don@vax1.acs.udel.edu
|      here.     |      I'd give out my phone number, but it's always 
------------------         busy anyway. 
DISCLAIMER:  My employers wouldn't understand my babbling even if they did know                how to read it.

CBWP8008@IRUCCVAX.UCC.IE (Ian Murphy) (05/12/89)

        in various ways.        Anyway, one thing I've been trying to do all
        semester, just to 'spruce up' the  screen output, is to CLEAR the
        %^&$%$%^ SCREEN from modula!!!

        By the way, I'm using the 'mod' compiler on a vax under unix 4.3.


I don't think it's provided in standard modula, not to matter, what you have to
do is to write an esc sequence (i.e <esc>something) the something will depend
on the terminal type you're using. I'd guess you're using vt100s so the best
thing would be to simply ask your computer center if you could have a look at
the ref. manual for the type of terminals you use there.

you'll have to write somethin like;

writechar (chr(27));
writechar (chr(aa));

Can't remember the exact esc sequence.

As a matter of interest, do DEC provide anything like VMS's SMG screen handling
routines for Ultrix?????

+-----------------------------------------------------------------------------+
|Ian Murphy (^v^)               | Internet   : IAN@VAX1.UCC.IE                |
|Dept. Computer Science         | ARPA       : IAN@IRUCCVAX.BITNET            |
|University College Cork,       | janet      : EARN%IRL.HEA.UCC.IRUCCVAX::IAN |
|Ireland.                       | Voice      : "IAN!!!"                       |
+-----------------------------------------------------------------------------+

JAGROGAN@VAX1.TCD.IE (05/18/89)

X-VMS-News: vax1 comp.lang.modula2:568

> From: CBWP8008@IRUCCVAX.UCC.IE (Ian Murphy)
> Subject:RE: beginner's stupid question
> Date: 12 May 89 14:58:00 GMT
> Message-ID:<INFO-M2%89051211453398@UCF1VM>

> I don't think it's provided in standard modula, not to matter, what you have t
   o
> do is to write an esc sequence (i.e <esc>something) the something will depend
> on the terminal type you're using. I'd guess you're using vt100s so the best
> thing would be to simply ask your computer center if you could have a look at
> the ref. manual for the type of terminals you use there.

Ian, We use modula-2 here in Trinity and we too tried to find a way to clear the
    screen and return the cursor to the top of the
screen. It apparently cannot be done. We use VT320 terminals and went to the com
   p. lab. to get the manuels for the terminals.
Having got them we frantically searched through it to find some sort of escape s
   equence or ascii character to do it.
The result is that it cannot be done!!!
However if you use VMS on a Vax then typing the following will do it for you...
        $ SET TERM/WIDTH=132
        $ SET TERM/WIDTH=80
This then clears the screen and returns the cursor to the top of the screen. I h
   ope that might be of some help.
              Cheers,
                        John Grogan, Computer Lab., Trinity College Dublin.

C136ERH@UTARLG.BITNET (Ray Howard) (05/18/89)

> > From: CBWP8008@IRUCCVAX.UCC.IE (Ian Murphy)
> > Subject:RE: beginner's stupid question
> > Date: 12 May 89 14:58:00 GMT
> > Message-ID:<INFO-M2%89051211453398@UCF1VM>

> > I don't think it's provided in standard modula, not to matter, what you have
 t
> >   o
> > do is to write an esc sequence (i.e <esc>something) the something will depen
d
> > on the terminal type you're using. I'd guess you're using vt100s so the best
> > thing would be to simply ask your computer center if you could have a look a
t
> > the ref. manual for the type of terminals you use there.
>

    Escape sequences are a kludge, one cannot depend on the users using a
    supported terminal, leave it the the operating system or a termcap
    type database to support terminal functions.  However, if you
    accept the fact that escape sequences will not work in all
    cases or the system does not have any type of terminal support
    then you might have to use escape sequences.

> Ian, We use modula-2 here in Trinity and we too tried to find a way to clear t
he
>     screen and return the cursor to the top of the
> screen. It apparently cannot be done. We use VT320 terminals and went to the c
om
>    p. lab. to get the manuels for the terminals.
> Having got them we frantically searched through it to find some sort of escape
 s
>    equence or ascii character to do it.
> The result is that it cannot be done!!!
> However if you use VMS on a Vax then typing the following will do it for you..
.
>         $ SET TERM/WIDTH=132
>         $ SET TERM/WIDTH=80

    I think the original poster wants to do this as part of a larger
    program??  Invoking DCL from a program is very slow when compared
    to directly calling a function.

> This then clears the screen and returns the cursor to the top of the screen. I
 h
>    ope that might be of some help.
>               Cheers,
>                         John Grogan, Computer Lab., Trinity College Dublin.


    There are terminal independent ways to clear the screen under
    VAX/VMS.  I do not know if your Modula-2 compiler has support to
    call the VMS RTL functions.  I do not have M-2 on our Vax so the
    code below is in VMS Pascal and VMS C (VAX-11).  The pascal
    version seems to be faster, probably due to the difference in
    making one function call instead of the 2 calls in the C version.
    The C version uses the curses package so should work on any system
    that has curses (some don't ???). maybe M-2 has something similiar
    to C curses?  The Pascal version depends on a VMS Run-Time Library
    function so will not work on a non-VMS system. If you are running
    M-2 on a VMS system you should be able to call the RTL functions
    or get a new compilier:-).

    Hope this gives you some leads on the problem.

    Pascal version:

    program clear(input,output);
    type        word_int = [word]0..65535;
    var         i:integer;
    [external] function lib$erase_page
                (line_no : word_int;
                 col_no  : word_int): INTEGER;
                EXTERNAL;
    BEGIN
      i := lib$erase_page(line_no:=1,col_no:=1);
    END.


    C version:

    #include stdio
    #include curses
    main()
    {
        initscr();
        endwin();
    }




                        Good Luck.


                                              ///
Ray 'StarSailer' Howard                      ///  #include <std.disclaimers>
Bitnet:   c136erh@utarlg                \\\ ///
Internet: c136erh@utarlg.arl.utexas.edu  \\X//
UUCP:   ...!{ames,sun,texbell,<vertebra>}!utarlg.arl.utexas.edu!c136erh

diamond@diamond.csl.sony.junet (Norman Diamond) (05/20/89)

From: CBWP8008@IRUCCVAX.UCC.IE (Ian Murphy)

>> I don't think it's provided in standard modula, not to matter, what you have
>> to
>> do is to write an esc sequence (i.e <esc>something) the something will depend
>> on the terminal type you're using. I'd guess you're using vt100s so the best

In article <8905180953.AA13531@jade.berkeley.edu> Modula2 List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes:

>Ian, We use modula-2 here in Trinity and we too tried to find a way to clear
>    the screen and return the cursor to the top of the
>screen. It apparently cannot be done. We use VT320 terminals and went to the
>   comp. lab. to get the manuels for the terminals.
>Having got them we frantically searched through it to find some sort of escape
>   sequence or ascii character to do it.
>The result is that it cannot be done!!!

You have to put the cursor at the top of the screen and then clear the
screen.  The reason is that the VT100's "clear" function only operates
from the current cursor position to the end of the screen.  The escape
codes are something like the following:

<ESC> [ 0 ; 0 H
<ESC> [ 2 J

>However if you use VMS on a Vax then typing the following will do it for you...
>        $ SET TERM/WIDTH=132
>        $ SET TERM/WIDTH=80

If you want to do it that way, there are escape codes for this too.  But
beware, some future generations of DEC terminals might not lose their
memory during such operations.

Meanwhile, it looks like you posted your news article with your terminal
set to 132, and some processor split them at 80.  I edited the excerpts
quoted above, to make them more readable.  Most of us use width-80
windows (or width-80 whatevers) to read news.  Please use it when
posting, too.

--
Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-implementing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?

CBWP8008@IRUCCVAX.UCC.IE (Ian Murphy) (05/22/89)

>Ian, We use modula-2 here in Trinity and we too tried to find a way to clear
>the screen and return the cursor to the top of the
>screen. It apparently cannot be done. We use VT320 terminals and went to the
>comp. lab. to get the manuels for the terminals.
>Having got them we frantically searched through it to find some sort of
>escape sequence or ascii character to do it.
>The result is that it cannot be done!!!
>

There are esc sequences to do this, they are

cursor home : esc[f
cursor to (r,c): esc[Pr;Pcf
Clr Scr : esc[2J

BUT, if you just write out these characters it will not work!!!!!
VMS is doing work behind the scenes and the terminal drivers catch esc
sequences and some are altered, SO before running the program to write out
these sequences say

$ set term/passthru

once you're finished say

$ set term/nopassthru

this forces VMS to ignore everything that is written to the term. Alternativly
you could just put the sequences into a string and write it out using SYS$QIO,
though your version may not support the system services, with the passthru flag
set. This problem doesn't occur(i think) for the guy who first asked the
question as he's running ultrix, which is brain-dead anyway and does nothing at
all for you.

If you want to find out more of the esc sequences for the vt320 then the
easiest way, other than wading through the ref manual is to write a program in
pascal/fortran/c/whatever which uses the smg$ calls, set your terminal (in
setup) so it displays esc sequences rather than interpreting them, then run
your program which does something like smg$clear_screen (or whatever) and
simply read the esc sequence on the screen.

Not that this has anything to do with modula-2.


+-----------------------------------------------------------------------------+
|Ian Murphy (^v^)               | Internet   : IAN@VAX1.UCC.IE                |
|Dept. Computer Science         | ARPA       : IAN@IRUCCVAX.BITNET            |
|University College Cork,       | janet      : EARN%IRL.HEA.UCC.IRUCCVAX::IAN |
|Ireland.                       | Voice      : "IAN!!!"                       |
+-----------------------------------------------------------------------------+

dag@per2.UUCP (Daniel A. Glasser) (05/23/89)

In article <10265@socslgw.csl.sony.JUNET>, diamond@diamond.csl.sony.junet (Norman Diamond) writes:
> You have to put the cursor at the top of the screen and then clear the
> screen.  The reason is that the VT100's "clear" function only operates
> from the current cursor position to the end of the screen.  The escape
> codes are something like the following:
> 
> <ESC> [ 0 ; 0 H
> <ESC> [ 2 J

No, VT100 terminals clear the entire screen no matter where the cursor is
if you use "<ESC> [ 2 J"...  The control sequence is "<CSI> Pn J", where
<CSI> is represented as <ESC> followed by [, Pn is a decmial digit
representing the type of screen clear to do, and J is the final character
in the sequence.   Possible values for Pn --
	"0" -- Clear from cursor to end of page (default)
	"1" -- Clear from beginning of page through cursor
	"2" -- Clear entire page
If Pn is omitted, the default is performed.  To move the cursor to the
home position, the sequence "<ESC> [ H" does just fine.  It is a special
case of the sequence "<ESC> [ Pr ; Pc H", where Pr is the row number
(1 and up) and Pc is the column number, represented as ASCII decimal
strings.  In both cases, the default is 1.

If you are dealing with VT52 style terminals, the sequences are different.
I think that they are "<ESC> H" to home the cursor and "<ESC> J" to clear
from the cursor through the end of the page.

Some other terminals use other sequences.  If you are sure of your
collection of terminals, you can write code that will send the correct
sequences to each terminal type.  If you are not sure what terminals
will be used to access your application, you might consider a micro-"TERMCAP"
module which accesses terminal descriptions from a file.  You may only
need functions to home the cursor and clear the screen, or you may
wish to add cursor addressing, line clearing and highlighting
(bold/underscore/reverse/blink/etc.)

Good luck.

					Daniel A. Glasser

PS:	"<ESC>" in the above text refers to the C0 escape character
(hex 1B, octal 33, decimal 27).  "<CSI>" is an 8-bit C1 control (hex 9B,
octal 233, decmial 155) which is represented in a 7-bit environment as
<ESC> followed by '['.  Real VT100s do not understand 8-bit control
characters, thus must use <ESC>[.  VT200s and VT300s understand both
when the communications channel is set to 8 bits.
-- 
 _____________________________________________________________________________
    Daniel A. Glasser                           One of those things that goes
    uwvax!per2!dag                              "BUMP!!!(ouch)" in the night. 
 ---Persoft, Inc.---------465 Science Drive-------Madison, WI 53711-----------