FindValue return values

Ed Kleban Ed at Kleban.com
Tue Dec 20 21:08:14 CST 2005


 

On 12/20/05 2:35 AM, "Ruslan Zasukhin" <sunshine at public.kherson.ua> wrote:

> On 12/20/05 7:18 AM, "Ed Kleban" <Ed at Kleban.com> wrote:
> 
>> 
>> If FindValue or FindValueAsArraySet fails to find any matching values will
>> then:
>> 
>> Always return a non-nil VSet  with VSet.count = 0?
>> 
>> Always return nil?
> 
> yes
>  
>> May return either of the above so you always have to test for both?
> 
> No. only nil. To avoid creation of object.


Well, the code check I put in to validate this just produced a counter
example proving that this is not in fact the case.

So... what should I conclude?  Is this a bug in Valentina?

====

The code may be found below.

The debugger shows that at the point in time when the following line
raises an alert:

    return EmptyVArraySetCheck( here, result )

that:
    aVBitSet.count = 35
    itemRids.count = 35
    result is non-nil VArraySet
    result.count = 0
    result.empty = True


========

Function FindAllItemRidsForFormRid(aFormRid as Integer, itemRids as
VArraySet) As VArraySet
  // FindAllItemRidsForFormRid
  
  // Return a VArraySet with the rids of all the Item records listed in
  // itemRids  having an fItmFormRid  field value equal to aFormRid.
  
  // This method is a special case of super.FindValueFromArraySet which
  // is a temporary patch method until Valentina fixes the bug that
  // prevents FindValueAsArraySet from working properly with a
  // VArraySet inSelection argument.
  
  const here = "FindAllItemRidsForFormRid"
  
  dim aVBitSet as VBitSet
  
  aVBitSet = new VBitSet( self.RecordCount, itemRids )
  
  #if DebugBuild then
    if aVBitSet.count <> itemRids.count then
      fail( here, "Count mismatch" )
    end
  #endif
   
  #if DebugBuild then
    dim result as VArraySet
    result = fItmFormRid.FindValueAsArraySet( aFormRid, aVBitSet )
    return EmptyVArraySetCheck( here, result )
  #else
    return fItmFormRid.FindValueAsArraySet( aFormRid, aVBitSet )
  #endif
  
  // @Fix  Remove call to VBitSet from this patch when Valentina gets fixed.
End Function

========

Function EmptyVArraySetCheck(where as String, resultVArraySet as VArraySet)
As VArraySet
  // EmptyVArraySetCheck
  
  // Generate an alert declared at <where> if resultVArraySet is a non-nil
  // VSet with a count of 0.
  
  // Return nil if resultVArraySet has a count of 0 otherwise
  // return resultVSet
  
  if resultVArraySet <> nil and resultVArraySet.count = 0 then
    alert( where, "Return non-nil ArraySet with count = 0" )
    return nil
  else
    return resultVArraySet
  end
   
End Function





More information about the Valentina mailing list