When "red" isn't red

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

When "red" isn't red

Post by RossG » Wed Jan 20, 2016 10:08 pm

I've set the backgroundColor of many fields without any problems but
I have one which refuses to change color.

What's even stranger is that putting the backgroundColor in the message
window gives "red" while the backgroundColor displayed definitely isn't.

What gives?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: When "red" isn't red

Post by bn » Wed Jan 20, 2016 10:54 pm

Hi Ross,

is "opaque" set for that field? Check in the Properties Inspector. If not it would be transparent. That could explain it.

Kind regards
Bernd

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: When "red" isn't red

Post by RossG » Thu Jan 21, 2016 1:53 am

Thanks bn - that did it.

An unrelated question. I want a column of AveDev numbers to
be aligned but some have one decimal place and others have none.
I think there's a way to "pad" or "fill" but can't find any reference to
such.

Problem half solved - found numberFormat but using "#.0" means
that 8.1 doesn't line up with 10.1 and using "##.0" makes 8.1 into
08.1.

Help appreciated.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: When "red" isn't red

Post by dunbarx » Thu Jan 21, 2016 2:23 am

Hi.

Not sure I understand. Do you want decimal point align?

Craig Newman

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: When "red" isn't red

Post by bn » Thu Jan 21, 2016 10:06 am

Hi Ross,

Livecode can not do decimal align, but as of 7 and up it can do right align for tabular data (data tab data tab data return and so on)

try this with a button and a field and change to what you need. If you want columnar data it is a bit more involved. You would place your data tab delimited for columns and return delimited for rows into the field.
But for just 1 column this should work.

Code: Select all

on mouseUp
   -- set up formatting
   set the numberformat to "#.00"
   set the tabStops of field 1 to 70 -- change position here
   
   set the tabAlign of field 1 to "right"
   
   -- fill with random numbers
   repeat 10
      put random (12) - 1 + random(3) / 3 / 10  & cr after tCollect
   end repeat
   put tCollect into field 1
end mouseUp
I will be offline the next couple of days, but maybe this gets you started

Kind regards
Bernd

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

Re: When "red" isn't red

Post by Lagi Pittas » Thu Jan 21, 2016 12:40 pm

Hi,

I had the same problem - so I rolled my own to have more control

Code: Select all

Function Currency pnValue, pnDigits, pnDecimals
   Local lcFormat, lnReturnVal
   
   -- Fixes the problem that when subtractions  to zero 
   -- gives -0.0 in livecode, this makes it really zero
   if pnValue is zero then 
      put 0 into pnValue
   end if
   
   If (pnDigits Is Empty) Then 
      Put 7 Into pnDigits
   End If
   
   If (pnDecimals Is Empty) Then 
      Put 2 Into pnDecimals
   End If
   
   Put "%" & pnDigits & "." & pnDecimals & "f" Into lcFormat
   
   put Format(lcFormat, pnValue) into lnReturnVal
   return (lnReturnVal)
   
End Currency
The above function assumes a width of 7 (padded left with spaces) and 2 decimal places so if you pass 0 you will get back
^^^0.00
if you call it with Currency(1.2,5,3) you will get back
^1.23
where the caret signs (^) mean space of course

Hope this helps

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: When "red" isn't red

Post by RossG » Sun May 15, 2016 1:24 am

The problem with the backgoundColor not appearing
correctly was, I think, related to my other problem with
fields after copying.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Post Reply