Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loopin a variable length array
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00189697
Message ID:
00189933
Views:
13
>Howdy,
>
>I have an array used to store references to controls on a multi-page form whose values may need to be recalculated.
>
>The form contains controls whose values may be dependent on the value of another control. The controls are linked though a form mediator. A control whose value is dependent on the value of another control sends a message during its Init() requesting notification when the first control's value changes.
>
>If the first control's value then changes, a reference to the requesting control is added to an array of controls to be recalculated.
>
>When it comes time to recalculate all of the dependent control values, the mediator loops through the recalculation array, calculating each control in turn.
>
>Here's the rub. As the mediator is processing the controls in the array, more than likely at least one of the controls processed has a dependency so that as that control's value is calculated, the dependent control adds itself to the end of the array so that it will then be recalculated in its turn.
>
>This means that the number of elements in the array is changing as the array is being processed.
>
>I have tried all combinations of FOR/ENFOR and FOR EACH/ENDFOR I can thing of, but have gone back to the tried and true DO/ENDDO loop to ensure that the entire array is processed.
>
>I am looking for a faster solution.
>
>Any thoughts would be appreciated.
>
>regards,

Hi James,

I'm not quite sure I understand all the nuances of this. What I understand is that if the value of a control changes one or more other controls will be impacted by the change. So basically what you have is a logical yes/no situation. If there are less than 33 controls involved, have you thought of using VFP's bitwise operators to track the changes. Assign each control a value based on a power of 2 (1, 2, 4, 8, etc.). When the value one of these controls is changed simply BITOR() its value with a custom property (ie ThisForm.flags = BITOR(ThisForm.flags, This.BitValue)). For an impacted control to find out if a change has been made, use BITAND(ThisForm.flags, This.ControlValue) # 0, where the ControlValue property contains the combined (ORed) values of the control(s) that affect it. Of course, I may not fully understand the nature of the problem, so it could be possible that this might not be a viable solution.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform