Go to specific row and column

D

don

Hi,

I'm new to Ruby and programming and I know I'm getting a
little ahead of myself, but I'm having trouble finding the
command that sends you to a specific row and column on a
monitor before writing something. Also any related
commands.

I have the pickaxe book if the commands are in there. I
know about printf and sprintf, but I do not think that is
what I am looking for.

Thanks in advance,


Don
 
F

Farrel Lifson

Hi,

I'm new to Ruby and programming and I know I'm getting a
little ahead of myself, but I'm having trouble finding the
command that sends you to a specific row and column on a
monitor before writing something. Also any related
commands.

I have the pickaxe book if the commands are in there. I
know about printf and sprintf, but I do not think that is
what I am looking for.

Thanks in advance,


Don
That kind of functionality is usually provided by an external library
such as ncurses. There is a ruby/ncurses binding available at
http://ncurses-ruby.berlios.de/

Farrel
 
D

don

That kind of functionality is usually provided by an external library
such as ncurses. There is a ruby/ncurses binding available at
http://ncurses-ruby.berlios.de/

Farrel

Farrel, thanks for the fast response.

So, are you saying there is not a "go to col 23, row 19"
type command in Ruby unless I install something else on my
linux system?

Don
 
C

Cliff Cyphers

don said:
Farrel, thanks for the fast response.

So, are you saying there is not a "go to col 23, row 19"
type command in Ruby unless I install something else on my
linux system?

In general this concept of external libs is the de facto and for a good
reason. For common things that can be utilized from many sources it's
good to put in an external libs. In this case you have a C ncurses
library and a ruby wrapper that interfaces with the base library.
 
D

don

In general this concept of external libs is the de facto and for a good
reason. For common things that can be utilized from many sources it's
good to put in an external libs. In this case you have a C ncurses
library and a ruby wrapper that interfaces with the base library.

Hi Cliff.

I wasn't commenting on the goodness or badness. I'd just
hoped there was a command I could use in my beginners
program.

Don
 
G

guillaume.marcais

don said:
Hi Cliff.

I wasn't commenting on the goodness or badness. I'd just
hoped there was a command I could use in my beginners
program.

There is curses in the standard library. So this little script should
work without installing anything extra:

---------------------------------------------
#! /usr/bin/ruby

require 'curses'

Curses.init_screen
s = Curses.stdscr
10.times do |i|
s.setpos(i, i)
s << "toto"
Curses.refresh
sleep(1)
end
Curses.close_screen
--------------------------------------------

The documentation is poor, but it doesn't take a lot of poking around
to figure out how it works. For documentation, see
http://www.ruby-doc.org, in the standard library, curses.

Hope this help,
Guillaume.
 
K

Ken Bloom

don said:
I wasn't commenting on the goodness or badness. I'd just
hoped there was a command I could use in my beginners
program.

Curses is among the standard libraries, (loaded with require 'curses')
but since most types of programs (e.g. web programs, GUI programs,
simple scripts) don't need the functionality of "go to col 23, row
19", it doesn't make sense to put it in as a language primative.

Learn to love libraries.

--Ken
 
D

don

There is curses in the standard library. So this little script should
work without installing anything extra:

---------------------------------------------
#! /usr/bin/ruby

require 'curses'

Curses.init_screen
s = Curses.stdscr
10.times do |i|
s.setpos(i, i)
s << "toto"
Curses.refresh
sleep(1)
end
Curses.close_screen
--------------------------------------------

The documentation is poor, but it doesn't take a lot of poking around
to figure out how it works. For documentation, see
http://www.ruby-doc.org, in the standard library, curses.

Hope this help,
Guillaume.

Thanks Guillaume. That is what I was looking for. I'll
play with your code and check out the curses documentation.

Don
 
D

don

Curses is among the standard libraries, (loaded with require 'curses')
but since most types of programs (e.g. web programs, GUI programs,
simple scripts) don't need the functionality of "go to col 23, row
19", it doesn't make sense to put it in as a language primative.

Learn to love libraries.

I will, Ken, as soon as I understand what they are. Thanks
for the reply.

Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top