Relation(), Target()
These two functions tell you about temporary relations—the kind you set up with SET RELATION. RELATION() tells you the relational expression while TARGET() tells you what alias the relation is pointing at.
Usage |
cRelationalExpr = RELATION( nRelationNumber [, cAlias | nWorkArea ] ) cTargetAlias = TARGET( nRelationNumber [, cAlias | nWorkArea ] ) |
Parameter |
Value |
Meaning |
nRelationNumber |
Numeric |
Which relation of this parent are we interested in? |
cAlias |
Character |
Provide information about relations for which cAlias is the parent. |
Omitted |
If nWorkArea is also omitted, provide information for relations in which the current work area is the parent. |
|
nWorkArea |
Numeric |
Provide information about relations for which the table in nWorkArea is the parent. |
Omitted |
If cAlias is also omitted, provide information about relations in which the current work area is the parent. |
Example |
* Arelns.PRG * Fill an array with all relations from a specified table. * Return the number of relations. * If there's a problem with parameters, return -1. LPARAMETERS aRelations,cAlias * aRelations = array to hold relation info. * cAlias = alias of the parent. If omitted, current work area. LOCAL nParams, nRelCnt, nOldArea nParams = PARAMETERS() IF nParams = 0 OR TYPE('aRelations[1]') = "U" RETURN -1 ENDIF IF nParams = 1 * Use current work area IF EMPTY(ALIAS()) * No table in use RETURN -1 ENDIF ELSE IF TYPE('cAlias') <> "C" OR NOT USED(cAlias) RETURN -1 ENDIF ENDIF nOldArea = SELECT() IF nParams > 1 SELECT (cAlias) ENDIF * Now start processing relation information nRelCnt = 1 DO WHILE NOT EMPTY(RELATION(nRelCnt)) DIMENSION aRelations[nRelCnt, 2] aRelations[nRelCnt, 1] = RELATION(nRelCnt) aRelations[nRelCnt, 2] = TARGET(nRelCnt) nRelCnt = nRelCnt + 1 ENDDO RETURN nRelCnt - 1 |
See Also |