Ask a Question related to PERL Beginners, Design and Development.
-
Steve Massey #1
Term:ANSIColor and negative numbers
Hi All
using Term:ANSIColor - does anyone know if it's possible ( or maybe I mean
practical) to print out negative numbers in say RED, at the same time
ensuring the original value is retained.
so if value is -16 the it should print 16 in RED text otherwise leave it
alone.
Thanks in advance
Steve
Steve Massey Guest
-
Pulling only negative numbers from a db
I have a field in my db that stores both negative numbers and positive numbers. I want to sum only the negative numbers. Is there a way to do this.... -
Negative numbers in red
Simple really - here's hoping! I have product prices (both - and +) that work well using the code below. However, I need to have the negative... -
Win32::Console vs Term::ANSIColor
HI, I am trying to print in color to command window in WIN2k, I am running my script on cmd.exe , but when I use Term:ANSIColor I am not able to... -
Term::ANSIColor How can I print the color directly to a printer
I have been using Term::ANSIColor to have printed charaters on my screen, how can I direct the ANSI escaped code to a color printer directly and... -
What is the term for this?
cpliu wrote: Prolonged press to bring up a menu doesn't really have one, as the standard on Mac is generally to control-click or right-click... -
James Edward Gray II #2
Re: Term:ANSIColor and negative numbers
On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:
Sure.> Hi All
>
> using Term:ANSIColor - does anyone know if it's possible ( or maybe I
> mean
> practical) to print out negative numbers in say RED, at the same time
> ensuring the original value is retained.
>
> so if value is -16 the it should print 16 in RED text otherwise leave
> it
> alone.
use Term::ANSIColor;
my $value = -16;
if ($value >= 0) { print "$value\n"; }
else { print colored(abs($value), 'red'), "\n"; }
Hope that helps.
James
James Edward Gray II Guest
-
Steve Massey #3
RE: Term:ANSIColor and negative numbers
Nice one James - that does it ..!!
something more to learn - abs
many thanks..
-----Original Message-----
From: James Edward Gray II [mailto:james@grayproductions.net]
Sent: 17 December 2003 17:35
To: Steve Massey
Cc: [email]beginners@perl.org[/email]
Subject: Re: Term:ANSIColor and negative numbers
On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:
Sure.> Hi All
>
> using Term:ANSIColor - does anyone know if it's possible ( or maybe I
> mean
> practical) to print out negative numbers in say RED, at the same time
> ensuring the original value is retained.
>
> so if value is -16 the it should print 16 in RED text otherwise leave
> it
> alone.
use Term::ANSIColor;
my $value = -16;
if ($value >= 0) { print "$value\n"; }
else { print colored(abs($value), 'red'), "\n"; }
Hope that helps.
James
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Steve Massey Guest
-
James Edward Gray II #4
Re: Term:ANSIColor and negative numbers
On Dec 17, 2003, at 11:42 AM, Steve Massey wrote:
Happy to help.> Nice one James - that does it ..!!
perldoc -f abs> something more to learn - abs
Anytime.> many thanks..
James
James Edward Gray II Guest
-
James Edward Gray II #5
Re: Term:ANSIColor and negative numbers
On Dec 17, 2003, at 11:41 AM, Wagner, David --- Senior Programmer
Analyst --- WGO wrote:
Well, probably the most common problem is that your terminal program> How do you get it to actually do the color? I use both std command(
> w2k) and older version os MKS Korn shell and all I get is numbers.
> Never understood how one actually gets the colors etc.
>
> What does one need to do?
must support colored output. You can probably use something like the
following to see if yours does:
perl -MTerm::ANSIColor -le 'print colored("Christmas!", "red on_green")'
Hope that helps.
James
James Edward Gray II Guest
-
Wiggins D Anconia #6
Re: Term:ANSIColor and negative numbers
> Hi All
Since you asked, I say it isn't practical, but then I am incredibly>
> using Term:ANSIColor - does anyone know if it's possible ( or maybe I mean
> practical) to print out negative numbers in say RED, at the same time
> ensuring the original value is retained.
>
> so if value is -16 the it should print 16 in RED text otherwise leave it
> alone.
>
color deficient and use a dark terminal window. So most shades of red
are lost on me in a terminal window (obviously anyone in the truly color
blind world, we have a support tech here who is, really wouldn't
care).... I would advocate making it optional. Does Term::ANSIColor
understand when a user has chosen a different font-weight for a
particular color, anyone?
[url]http://danconia.org[/url]
--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.
Wiggins D Anconia Guest
-
\ Wenjie Wang #7
RE: Term:ANSIColor and negative numbers
>-----Original Message-----
>From: Wagner, David --- Senior Programmer Analyst --- WGO
>[mailto:David.Wagner@freight.fedex.com]
>Sent: Thursday, 18 December 2003 4:41 AM
>To: James Edward Gray II; Steve Massey
>Cc: [email]beginners@perl.org[/email]
>Subject: RE: Term:ANSIColor and negative numbers
>
>
>James Edward Gray II wrote:> How do you get it to actually do the color? I use both std>> On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:
>>>>> Hi All
>>>
>>> using Term:ANSIColor - does anyone know if it's possible ( or maybe
>>> I mean practical) to print out negative numbers in say RED, at the
>>> same time ensuring the original value is retained.
>>>
>>> so if value is -16 the it should print 16 in RED text otherwise
>>> leave it alone.
>command( w2k) and older version os MKS Korn shell and all I get is
>numbers. Never understood how one actually gets the colors etc.
>
> What does one need to do?
I'm using perl5.08 on Win2k box, and have faced the same problem in my DOS
prompt window. There is no color changes, but some escape sequence was
displayed instead. If I execute the sample code provided by James, I got
"?[31m16?[0m" displayed instead of "16" in red color.
But I do have red colored 16 displayed properly, if execute it from cgywin's
bash shell.
I'm presuming it got something to do with the configuration?
\ Wenjie Wang Guest
-
Andrew Gaffney #8
Re: Term:ANSIColor and negative numbers
(William) Wenjie Wang wrote:
I believe that you need to load ANSI.SYS in your CONFIG.SYS in order to have the escape>>>-----Original Message-----
>>From: Wagner, David --- Senior Programmer Analyst --- WGO
>>[mailto:David.Wagner@freight.fedex.com]
>>Sent: Thursday, 18 December 2003 4:41 AM
>>To: James Edward Gray II; Steve Massey
>>Cc: [email]beginners@perl.org[/email]
>>Subject: RE: Term:ANSIColor and negative numbers
>>
>>
>>James Edward Gray II wrote:
>>>>>>>On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:
>>>
>>>
>>>>Hi All
>>>>
>>>>using Term:ANSIColor - does anyone know if it's possible ( or maybe
>>>>I mean practical) to print out negative numbers in say RED, at the
>>>>same time ensuring the original value is retained.
>>>>
>>>>so if value is -16 the it should print 16 in RED text otherwise
>>>>leave it alone.
>> How do you get it to actually do the color? I use both std
>>command( w2k) and older version os MKS Korn shell and all I get is
>>numbers. Never understood how one actually gets the colors etc.
>>
>> What does one need to do?
>
>
> I'm using perl5.08 on Win2k box, and have faced the same problem in my DOS
> prompt window. There is no color changes, but some escape sequence was
> displayed instead. If I execute the sample code provided by James, I got
> "?[31m16?[0m" displayed instead of "16" in red color.
>
> But I do have red colored 16 displayed properly, if execute it from cgywin's
> bash shell.
>
> I'm presuming it got something to do with the configuration?
sequences interpreted in a DOS session.
--
Andrew Gaffney
Andrew Gaffney Guest
-
Andrew Gaffney #9
Re: Term:ANSIColor and negative numbers
Wagner, David --- Senior Programmer Analyst --- WGO wrote:
Well, in Windows 98 and below, you could add the line:> Andrew Gaffney wrote:
>>>>(William) Wenjie Wang wrote:
>>>>>>>>-----Original Message-----
>>>>From: Wagner, David --- Senior Programmer Analyst --- WGO
>>>>[mailto:David.Wagner@freight.fedex.com]
>>>>Sent: Thursday, 18 December 2003 4:41 AM
>>>>To: James Edward Gray II; Steve Massey
>>>>Cc: [email]beginners@perl.org[/email]
>>>>Subject: RE: Term:ANSIColor and negative numbers
>>>>
>>>>
>>>>James Edward Gray II wrote:
>>>>
>>>>
>>>>>On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Hi All
>>>>>>
>>>>>>using Term:ANSIColor - does anyone know if it's possible ( or
>>>>>>maybe I mean practical) to print out negative numbers in say RED,
>>>>>>at the same time ensuring the original value is retained.
>>>>>>
>>>>>>so if value is -16 the it should print 16 in RED text otherwise
>>>>>>leave it alone.
>>>>
>>>> How do you get it to actually do the color? I use both std
>>>>command( w2k) and older version os MKS Korn shell and all I get is
>>>>numbers. Never understood how one actually gets the colors etc.
>>>>
>>>> What does one need to do?
>>>
>>>
>>>
>>>I'm using perl5.08 on Win2k box, and have faced the same problem in
>>>my DOS prompt window. There is no color changes, but some escape
>>>sequence was displayed instead. If I execute the sample code
>>>provided by James, I got "?[31m16?[0m" displayed instead of "16" in
>>>red color.
>>>
>>>But I do have red colored 16 displayed properly, if execute it from
>>>cgywin's bash shell.
>>>
>>>I'm presuming it got something to do with the configuration?
>>I believe that you need to load ANSI.SYS in your CONFIG.SYS in order
>>to have the escape sequences interpreted in a DOS session.
> Sorry, but when you say load, what do you mean? Sorry but unsure what is necessary and I would like to see this work.
>
> Thanks for any input.
DEVICE=ANSI.SYS
to your C:\CONFIG.SYS and it would allow the command prompt to interpret ANSI escape
sequences. Unfortunately, I do not know the equivelant for Windows NT/2K/XP.
--
Andrew Gaffney
Andrew Gaffney Guest
-
Randy W. Sims #10
Re: Term:ANSIColor and negative numbers
On 12/18/2003 9:15 PM, Andrew Gaffney wrote:
There is no equivelant for 2K/XP. I think there is way in NT, but don't> Wagner, David --- Senior Programmer Analyst --- WGO wrote:
>>>> Andrew Gaffney wrote:
>>>>>>> (William) Wenjie Wang wrote:
>>>
>>>
>>> I believe that you need to load ANSI.SYS in your CONFIG.SYS in order
>>> to have the escape sequences interpreted in a DOS session.
>>
>> Sorry, but when you say load, what do you mean? Sorry but unsure
>> what is necessary and I would like to see this work.
>>
>> Thanks for any input.
>
> Well, in Windows 98 and below, you could add the line:
>
> DEVICE=ANSI.SYS
>
> to your C:\CONFIG.SYS and it would allow the command prompt to interpret
> ANSI escape sequences. Unfortunately, I do not know the equivelant for
> Windows NT/2K/XP.
>
recall the specifics.
Randy.
Randy W. Sims Guest
-
Chuck Fox #11
Re: Term:ANSIColor and negative numbers
[email]agaffney@skylineaero.com[/email] wrote:
Ahh, A Golden Oldie for sure!> Well, in Windows 98 and below, you could add the line:
>
> DEVICE=ANSI.SYS
>
> to your C:\CONFIG.SYS and it would allow the command prompt to
> interpret ANSI escape sequences. Unfortunately, I do not know the
> equivelant for Windows NT/2K/XP.
Your Friendly Neighborhood DBA,
Chuck
Chuck Fox Guest



Reply With Quote

