%StructCmp function


Function
The function compares the defined parts of local structures.
Declaration
BOOL %StructCmp(
       in _recA[fromRowA]^fromColA, IN _recA[toRowA]^toColA,
       in  _recB[fromRowB]^fromColB,
   INT in _cmpOptions 
 [,INT in _roundPrec]
 )

Parameters
_recA[fromRowA]^fromColA,
_recA[toRowA]^toColA
Reference to the value of local structured variable field.
_recB[fromRowB]^fromColB Reference to the value of local structured variable field.
_cmpOptions Way of comparison.
_roundPrec Optional parameter. It specifies how many decimal places the compared values (they must be of Real type) are rounded to. The value must be >= 0.

Description
The value of parameter _cmpOptions determines which part of value will be compared as follows:

Value Compare the part of value
1 value
2 time of value formation
4 users flags

The value of parameter _cmpOptions can be obtain by addition of above mentioned values (for example, if user want to compare only the time of value formation and users flags so the value of parameter is 2+4).

The comparison is done as follows:

A=B

where:
Symbol A represents an area of local structured variable values which is given by its left upper corner (field _recA[fromRowA]^fromColA) and right lower corner (field _recA[toRowA]^toColA). The structured variable which is used in the first and second parameter must be the same. The dimensions (number of rows and columns) are also defined by this way. They are used in definition of B area that is defined only by its right upper corner in the parameters.

The comparison is done among the individual appropriate fields of A and B areas. The function gets back the value @TRUE if all fields, that are compared, accomplish a condition of equality.


Note
Two invalid values are considered to be equal during comparison. Valid and invalid value are considered to be different value.
A flag value validity does not influence the comparison of users flags or time of value formation.
Example
In following example there is shown the comparison of two matrixes.
The first one is delimited by fields _A[1]^_firstColNr (where _firstColNr has value =1) and _A[2]^_lastColNr (where _lastColNr is set on consecutive number of the last column of relevant structure).
The second one is defined by the field _B[1]^_firstColNr and consists of two rows and of the same number of columns like matrix in variable _A.
 
 BEGIN
  BOOL _bEqual
  RECORD (SD.BIG) _A
  RECORD (SD.BIG) _B
  REDIM _A[20]
  REDIM _B[20]
 
 INT _firstColNr, _lastColNr 
 
 _firstColNr := 1
 _lastColNr := _A\CNR
 _A[1]^R1 := 1
 _A[2]^R1 := 2
 DELAY 1[s]
 _B[1]^R1 := 1
 _B[2]^R1 := 2
 _bEqual := %StructCmp(_A[1]^_firstColNr,_A[2]^_lastColNr,_B[1]^_firstColNr,1)
 ;result is @TRUE
 
 _bEqual := %StructCmp(_A[1]^_firstColNr,_A[2]^_lastColNr,_B[1]^_firstColNr,2)
 ;result is @FALSE, because the time of values are different
 
 END

Napíšte komentár