Tips   >   Lists   >   Row Sendall

Row Sendall

You can use $sendall for setting values in columns of a row variable.

A row is composed of a group of columns ($cols), so Row.$cols.$sendall() allows you to loop through the columns in a row applying whatever tricks you can pack between the brackets of the $sendall.

Do Row.$cols.$sendall(Row.[$ref.$ident].$assign(Value),[Criteria]) Returns Count

Splitting the $sendall notation:

Set Row Values

@SAMPLECODE:1

Set Row Nulls to blank

@SAMPLECODE:1

Count Row Nulls

$sendall

returns the number of objects that the $sendall was applied to. We can use this to tell us the number of null values columns in a row.

In this example we leave out the calculation portion of the $sendall, and only include the criteria portion.

; Count the number of nulls in the row.
Do Row.$cols.$sendall(,isnull(Row.[$ref.$ident])) Returns NumNulls


; To do the above in a For loop.
Do Row.$cols.$first() Returns rCol
While rCol
   
   If isnull(Row.[rCol.$ident])
      Calculate NumNulls as NumNulls+1
   End If
   
   Do Row.$cols.$next(rCol) Returns rCol
   
End While

Compare Row Values

We can use $sendall to compare 2 rows and return the number of column values which are different. This might be useful for figuring out if the user has made changes to a new row compared to the old row.

; Compare the new row with the old row to see if there have been any changes.
Do NewRow.$cols.$sendall(,NewRow.[$ref.$ident]<>OldRow.[$ref.$ident]) Returns NumDiff


; To do the above in a For loop.
Do NewRow.$cols.$first() Returns rCol
While rCol
   
   If NewRow.[rCol.$ident]<>OldRow.[$ref.$ident]
      Calculate NumDiff as NumDiff+1
   End If
   
   Do NewRow.$cols.$next(rCol) Returns rCol
   
End While

Warning

This method does not work for null value columns.