examples/test_scanw.rb (593B) - raw
1 #!/usr/bin/env ruby
2
3 # $Id: test_scanw.rb,v 1.1 2003-03-22 22:55:00 t-peters Exp $
4 #
5 # Test of the scanw function. Should really not be used in any serious curses
6 # program. To use it, install scanf for ruby.
7
8 # Copyright (C) 2003 Tobias Peters <t-peters@users.berlios.de>
9 #
10 # No warranties. Share and enjoy.
11
12 require "ncursesw"
13 begin
14 Ncurses.initscr
15 Ncurses.mvaddstr(4, 19, "Give me a number: ")
16 Ncurses.refresh
17 num = []
18 Ncurses.scanw("%d", num)
19
20 Ncurses.mvprintw(6, 19, "You gave: %d", num[0])
21 Ncurses.refresh
22 sleep 1
23 ensure
24 Ncurses.endwin
25 end
26
27 puts("You gave: #{num[0]}")