Page 1 of 1

The relation statement?

Posted: August 21st, 2014, 10:01 pm
by pierrew
Does anybody know how we can use the relation statement to its fullest potential.
I am able to define it but other than that I never know what I can do with it.

Code: Select all

relation relation-name primary to secondary-1 method
[to secondary-2 method] ... [to secondary-n method];

where method is
   parallel | linked by arith-exp | where condition

Re: The relation statement?

Posted: September 25th, 2014, 10:27 am
by Gregory Martin
Relations are most useful for tabulating data. You can also use them in for loops. There is an example of this in the CSPro examples folder under "2 - Edits & Batch Programs\Dictionary Relations."

In that example, the relation is defined in the dictionary, not in the logic. But then you'll see how it's used later:
for idx in relation MOTHER_CHILD do {loop through relation}
In the loop, the variables for the woman and the child are always updated based on the relationship between them. This avoids you needing to use subscripts while going through the loop.

Relations are simply shortcuts ... they don't do anything that you couldn't achieve in another way by writing different logic.