Page 1 of 1

CellIsUpdateable

Posted: Thu Jan 08, 2009 3:24 pm
by Steve Vincent
This could have been made twice as useful as it is had someone thought about it more...

CellIsUpdateable checks if a cell can be written to, but it FAILS if one of the elements doesn't exist. Rather than failing (and dumping things in to the error log) it should also return zero if the element is missing, then it'd be far more useful. Its not hard to code your own way of reporting which part is causing the issue, and this alteration would make it easier and less CPU intensive to check values if it could handle both errors at once.

As it stands, i'm having to do a DIMIX check on every data point first, then report on any issues whereas the ideal would be to filter out issues using CellIsUpdateable then do the DIMIX check to figure out which ones.

Re: CellIsUpdateable

Posted: Thu Jan 08, 2009 9:58 pm
by Alan Kirk
Steve Vincent wrote:This could have been made twice as useful as it is had someone thought about it more...

CellIsUpdateable checks if a cell can be written to, but it FAILS if one of the elements doesn't exist. Rather than failing (and dumping things in to the error log) it should also return zero if the element is missing,
I doez disagree on this one. My belief is that a function return value should always have a specific and unambiguous meaning. Consequently I'd rather that if the element doesn't exist, it returns -1 rather than 0. The test for whether the cell is writeable can still be expressed as

Code: Select all

if (CellIsUpdateable(Blah)=1); 
or alternatively

Code: Select all

if (CellIsUpdateable(Blah)>0) 
so no changes to exisitng code would be needed, but if it returned -1 for a missing element then you'd have the option of using an If/Elseif block and save a little code and a few processing cycles:

Code: Select all

l_Writeable = CellIsUpdateable(Blah);

If ( l_Writeable <0);
    #Insert the element, write a log file, throw a party, whatever
ElseIf ( l_Writeable = 0);
    # Bang user on head with frying pan and tell them to stop trying to write to consolidations or rules elements, or whatever
Else;
    #Write your value and may the gods have mercy on your soul, etc
EndIf;


If you don't care whether it's un-writeable or simply doesn't exist, you could still use "< 1" as the test criterion.

Re: CellIsUpdateable

Posted: Fri Jan 09, 2009 11:15 am
by Steve Vincent
Yep, works for me too. Even a 0 1 2 result would work as long as it had been documented what each result meant. Anything other than creating an error message would be of help :)