Warfy has asked for the wisdom of the Perl Monks concerning the following question:

I have some problem(s) with my curses::widgets script. I have maked a textfield and that was pritty easy but I want to read the value from that textfield. I don't know if I'm to locked up in the problem to see the solution, therefor I seek other knowledge to help me out. According to the manual I should get that value with "getField('VALUE')" but I'm maybe out of line, because it still isnt working and I've tried other methods too.

This is how I thought it should be:

use Curses; use Curses::Widgets; use Curses::Widgets::TextField; # Initialise the environment $mwh = new Curses; noecho(); halfdelay(5); $mwh->keypad(0); curs_set(0); $tf = Curses::Widgets::TextField->new({ CAPTION => 'login', CAPTIONCOL => 'yellow', COLUMNS => 10, MAXLENGTH => 255, #MASK => undef, VALUE => '', INPUTFUNC => \&scankey, FOREGROUND => 'black', BACKGROUND => 'green', BORDER => 1, BORDERCOL => 'red', FOCUSSWITCH => "\t\n", CURSORPOS => 0, TEXTSTART => 0, PASSWORD => 0, X => 1, Y => 1, READONLY => 0, }); $tf->draw($mwh, 0); $tf->execute($mwh); $login = $tf->getField('VALUE'); { END { endwin(); } exit 0; sub login { if ($login = ~ /test\b/) { # Do something } }


Any sugestions would be very helpfull because I'm stuck and as you can see I'm quite new into perl programming.
Thank you for your time reading it.

edited by ybiC: Replace <pre> tags with <code>, as per Monastery convention

Title edit by tye

Replies are listed 'Best First'.
Re: curses::widgets
by Zaxo (Archbishop) on Aug 25, 2003 at 23:09 UTC

    Your code works after deleting the extra left curly in line 35. I added print $login, $/; at the tail of the END() routine, just to show what you get. What I typed is dutifully printed on shutdown.

    After Compline,
    Zaxo