For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > How to load text into Curses::UI::TextEditor -> -text?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to load text into Curses::UI::TextEditor -> -text?
Ert Weerr

2006-10-09, 7:59 am

Guys,

I'd like to write a perl-based tool that helps me to
do my regular system monitoring tasks.
It would be running in console mode but using
'windows' to list the command outputs.

Curses::UI::TextEditor would be one of the elements
that I use to present the output in a nice formatted
way.

It appears to me that its -text option is not
accepting strings from a function but only static
texts.

Is there anyone here who already had to struggle with
this module before?

Sorry if it's an off-topic email here, I really don't
know where to ask my question.

Thanks in advance!

Regards,

John

Here's an example:

$w{202}->add(
undef, 'TextEditor',
-title => 'Disk
space',
-y => 0, -padright =>
0, -border => 1,
-padbottom => 0,
-readonly => 1,
-vscrollbar => 1,
-hscrollbar => 1,
-text => $text,
);

The variable $text has only a simple string value
something like "This is a test...", but when I run the
code the TextEditor only present '1'.

If I try to use the function like this

-text => \&fs_check,

The the result is 'CODE(0x972e3c4)'

It only works if I write a static string next to text:

-text => "This is a test..."

________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
D. Bolliger

2006-10-09, 7:59 am

ert weerr am Montag, 9. Oktober 2006 09:24:
> Guys,


Hello

> I'd like to write a perl-based tool that helps me to
> do my regular system monitoring tasks.
> It would be running in console mode but using
> 'windows' to list the command outputs.
>
> Curses::UI::TextEditor would be one of the elements
> that I use to present the output in a nice formatted
> way.
>
> It appears to me that its -text option is not
> accepting strings from a function but only static
> texts.
>
> Is there anyone here who already had to struggle with
> this module before?
>
> Sorry if it's an off-topic email here, I really don't
> know where to ask my question.
>
> Thanks in advance!
>
> Regards,
>
> John
>
> Here's an example:
>
> $w{202}->add(
> undef, 'TextEditor',
> -title => 'Disk space',
> -y => 0, -padright => 0, -border => 1,
> -padbottom => 0,
> -readonly => 1,
> -vscrollbar => 1,
> -hscrollbar => 1,
> -text => $text,
> );
>
> The variable $text has only a simple string value
> something like "This is a test...", but when I run the
> code the TextEditor only present '1'.
>
> If I try to use the function like this
>
> -text => \&fs_check,
>
> The the result is 'CODE(0x972e3c4)'


You assigned a reference to a subroutine, and it's address is correctly shown,
since the value of this attribute is not called by the code but displayed
literally.

You probably want to assign the result string of a call of the subroutine:

-text => fs_check(),


Does this help?

Dani
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com