On 5/30/12 11:11 AM, Andrew Johnson wrote:
> Hi Lewis,
>
> On 2012-05-30 Allison, Stephanie wrote:
>> Could this be a round-off error (long to double)? Does this CALC work:
>>
>> field(CALC, "A>0.5?1:0")
>
> If that works, also try the expression "!!A" which is more efficient than
> using ?: anyway. In general I never assume that a true value is 1, it's
> better to check for non-zero, so use "A!=0?1:0" or just "A?1:0".
Hi, Andrew.
Yes, "!!A" works too.
I'm not actually assuming a true value is 1. I'm simply
comparing the value of A with 1 to see if the bi record value is
1. That should work. The bi record does not indicate true or
false; it indicates two values: 0 or 1. I could just as easily
be using an mbbi record and doing a comparison of A with the 2
to see if the mbbi record value is 2.
My CALC expression shows the problem, but it is not what I would
normally write by hand. The real situation is that I have a
database where the bi value corresponding to the "inserted"
state of a pneumatically controlled backlight is specified as a
macro (in this case named "INSERTED"). So the CALC expression
in the database actually looks like this:
field(CALC, "A=$(INSERTED)?1:0")
This enables the database to work with a pneumatically
controlled backlight where the actual state (i.e. inserted or
retracted) is reported as a high *or* low digital I/O signal.
Maybe I could do something tricky like setting the INSERTED
macro to "!" or the empty string "" depending on how the actual
state is reported to achieve your CALC expression, but that
would be way less readable and therefore a poorer choice to me.
> However I admit I would be very surprised if the integer to double conversion
> is not exact for the value 1.
Right. And I'm sure I'm not the only one writing CALC
expressions like this. There have got to be hundreds of
expressions (probably thousands) out there that would break
under these circumstances.
I also tried "nint(A)=1?1:0". This does not work.
Thanks,
Lewis
- Replies:
- Re: calc VAL field not updating from bi VAL field Tim Mooney
- References:
- calc VAL field not updating from bi VAL field J. Lewis Muir
- RE: calc VAL field not updating from bi VAL field Allison, Stephanie
- Re: calc VAL field not updating from bi VAL field Andrew Johnson
- Navigate by Date:
- Prev:
RE: Proposed change in asyn - request for comments Allison, Stephanie
- Next:
RE: Proposed change in asyn - request for comments Mark Rivers
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: calc VAL field not updating from bi VAL field Andrew Johnson
- Next:
Re: calc VAL field not updating from bi VAL field Tim Mooney
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|