comp.lang.ada
 help / color / mirror / Atom feed
* Some general help with ADA
@ 2002-03-09 19:02 Jim
  2002-03-09 19:46 ` Some general help with Ada chris.danx
  2002-03-09 20:13 ` Some general help with ADA Adrian Knoth
  0 siblings, 2 replies; 5+ messages in thread
From: Jim @ 2002-03-09 19:02 UTC (permalink / raw)


how do you create a blank screen like the CLS command in Qbasic/DOS ?

can you do it with text_io ?


also how do i remove 'rows' in an array ?  eg if an array is made up
of 0..100, i add data into say 1, 2 and 3.  How do i then delete 1,2,3
and be left with 4..100 ? is that possible ?



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

* Re: Some general help with Ada
  2002-03-09 19:02 Some general help with ADA Jim
@ 2002-03-09 19:46 ` chris.danx
  2002-03-10  0:57   ` David Starner
  2002-03-09 20:13 ` Some general help with ADA Adrian Knoth
  1 sibling, 1 reply; 5+ messages in thread
From: chris.danx @ 2002-03-09 19:46 UTC (permalink / raw)



"Jim" <genx54321@hotmail.com> wrote in message
news:ab6237e2.0203091102.103d54e9@posting.google.com...
> how do you create a blank screen like the CLS command in Qbasic/DOS ?
>
> can you do it with text_io ?

ada.text_io.new_line (26); is quick and easy.

> also how do i remove 'rows' in an array ?  eg if an array is made up
> of 0..100, i add data into say 1, 2 and 3.  How do i then delete 1,2,3
> and be left with 4..100 ? is that possible ?

You want to slice the array something like this?

WARNING: uncompiled code following

type my_array is (natural range <>) of some_type;

subtype my_other_array is my_array (range 0..100);

function get_relevant_data (a : in my_other_array) return my_array is
begin
   return a(4..a'last);
end get_relevant_data;

the line return a(4..a'last) will return the elements between 4 and the end
of the array (100 in this case).  It is important that my_other_array is a
subtype of my_array since otherwise they'd be of different types and Ada
doesn't allow mixing types in an arbitary fashion.  John English covers
arrays in his (now online and free) book available at
www.it.bton.ac.uk/staff/je/adacraft/ in case your interested.

HTH,
Chris





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

* Re: Some general help with ADA
  2002-03-09 19:02 Some general help with ADA Jim
  2002-03-09 19:46 ` Some general help with Ada chris.danx
@ 2002-03-09 20:13 ` Adrian Knoth
  1 sibling, 0 replies; 5+ messages in thread
From: Adrian Knoth @ 2002-03-09 20:13 UTC (permalink / raw)


Jim <genx54321@hotmail.com> wrote:

> how do you create a blank screen like the CLS command in Qbasic/DOS ?
> can you do it with text_io ?

Doing it with ASCII:

  procedure ClearScreen is
  begin
    Text_IO.Put (Item => ASCII.ESC);
    Text_IO.Put (Item => "[2J");
  end ClearScreen;

(copied from screen.adb, (C) Michael Feldman) 
 
> also how do i remove 'rows' in an array ?  

You're using a static object. So either copy the needed lines to a
new one or use dynamic handling of your array. This is not something
you can do if you're new to Ada (mixed-cased spelling!).

You should better blank your old data and/or resort your array-data.
Why do you need to shrink an array? This sounds very unusual.


-- 
mail: adi@thur.de  	http://adi.thur.de	PGP: v2-key via keyserver

Die Pille ist blo� fauler Zaubr, nur Ajax h�lt das Becken sauber !



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

* Re: Some general help with Ada
  2002-03-09 19:46 ` Some general help with Ada chris.danx
@ 2002-03-10  0:57   ` David Starner
  2002-04-08  0:43     ` Nick Roberts
  0 siblings, 1 reply; 5+ messages in thread
From: David Starner @ 2002-03-10  0:57 UTC (permalink / raw)


On Sat, 9 Mar 2002 19:46:38 -0000, chris.danx <chris.danx@ntlworld.com> wrote:
> "Jim" <genx54321@hotmail.com> wrote in message
> news:ab6237e2.0203091102.103d54e9@posting.google.com...
>> how do you create a blank screen like the CLS command in Qbasic/DOS ?
>>
>> can you do it with text_io ?
> 
> ada.text_io.new_line (26); is quick and easy.

And wrong. There's no guarentee that the terminal is only 26 lines tall.
I frequently work in terminals 50 lines tall, for example. It will also
look very different from clearing the screen on some terminals.  There
is no way to do this in standard Ada that will always work.
Ada.Text_IO.Put (ASCII.ESC & "[2J"); will work on ANSI terminals,
including ANSI.SYS on DOS. You might want to look at the GNAT examples;
that has a very simple terminal package in it. For bigger stuff, you
probably want to look at the Ada binding to NCurses included in the
package.

-- 
David Starner - starner@okstate.edu
"It's not a habit; it's cool; I feel alive. 
If you don't have it you're on the other side." 
- K's Choice (probably refering to the Internet)



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

* Re: Some general help with Ada
  2002-03-10  0:57   ` David Starner
@ 2002-04-08  0:43     ` Nick Roberts
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Roberts @ 2002-04-08  0:43 UTC (permalink / raw)


On 10 Mar 2002 00:57:30 GMT, David Starner
<dvdeug@x8b4e53cd.dhcp.okstate.edu> strongly typed:

>On Sat, 9 Mar 2002 19:46:38 -0000, chris.danx <chris.danx@ntlworld.com> wrote:
>> "Jim" <genx54321@hotmail.com> wrote in message
>> news:ab6237e2.0203091102.103d54e9@posting.google.com...
>>> how do you create a blank screen like the CLS command in Qbasic/DOS ?
>>>
>>> can you do it with text_io ?
>> 
>> ada.text_io.new_line (26); is quick and easy.
>
>And wrong. There's no guarentee that the terminal is only 26 lines tall.

And I think it's wrong for you to say "wrong". There's 'no guarantee' that
the user will be the slightest bit worried that only part of the screen was
cleared. In fact, I suspect it is almost guaranteed that the user won't be.

-- 
Nick Roberts



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

end of thread, other threads:[~2002-04-08  0:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-09 19:02 Some general help with ADA Jim
2002-03-09 19:46 ` Some general help with Ada chris.danx
2002-03-10  0:57   ` David Starner
2002-04-08  0:43     ` Nick Roberts
2002-03-09 20:13 ` Some general help with ADA Adrian Knoth

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