>Hi
>
>My current application consists of many rules/validation (ie cannot do A unless B has been done. Cannot to D unless B comes from A - things like that), these rules are becoming very cluttered as they are spread amongst Methods amongst Forms..
>
>What I need to know is how people handle lots of complex rules and how they tie them in. What I am trying to achieve is an effective method that appears more logical than what it actually is, and is easy to maintain/amend.
>
>Any ideas/thoughts.
>
>I know I haven't gone into much detail, but I can if necessary
>
>Thanks
Kev,
One common approach to handling multiple logical conditions is to use the bit manipulation functions. For example, I have a COM object which requires that 14 separate variables be set prior to it executing its main functionality.
What I did was to first create an nFlags property and set or clear the bits in an _assign method for each variable. By assigning constants with values in successive powers of 2, it allows me to easily assign, clear and check for these conditions. For example, here's some actual code.
PROCEDURE nOrderSize_Assign
LPARAMETER vNewVal
This.FlagAssignment(vNewVal, ORDER_SIZE)
This.nOrderSize = m.vNewVal
RETURN
ENDPROC
PROCEDURE FlagAssignment
LPARAMETERS vValue, pnAssignKey
IF NOT EMPTY(vValue)
This.nAssigned = BITOR(This.nAssigned, pnAssignKey)
ELSE
IF BITAND(This.nAssigned, pnAssignKey) # 0
This.nAssigned = BITXOR(This.nAssigned, pnAssignKey)
ENDIF
ENDIF
RETURN
ENDPROC
In order to test this, all I have to do is
IF BITAND(This.nAssigned, ORDER_SIZE) # 0
ENDIF
hth,
George
Ubi caritas et amor, deus ibi est