SIGN( ) example
The following example is a custom next( ) method for a detail rowset that automatically navigates in the master rowset:
function next( nArg )
if not rowset::next( nArg ) // Navigate as far as specified, but
// if end of detail rowset
this.masterRowset.next( sign( nArg ) ) // Move forward or backward in master
if nArg < 0 // If navigating backwards
this.last( ) // Go to last matching detail row
endif
endif
No matter how many records are skipped in the detail rowset, the master rowset is navigated forward one or backward one row only, by using the SIGN( ) function to convert the row count to 1 or -1 (or zero). Without the SIGN( ) function, you would have to use a more cumbersome IIF( ) function or IF block.
When checking to see if the navigation was backwards, it would be redundant to use the SIGN( ) function again, since you would have to compare the result to zero or -1 anyway. Simply using the less than logical operator is all that is needed.