The relation statement?

Other discussions about CSPro
Forum rules
New release: CSPro 8.0
Post Reply
pierrew
Posts: 47
Joined: August 8th, 2012, 5:20 am
Location: Pohnpei, Federated States of Micronesia

The relation statement?

Post 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
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: The relation statement?

Post 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.
Post Reply