Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting changes in control values
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00057294
Message ID:
00057362
Views:
28
>>>>I have several pages of controls that are NOT bound to a ControlSource. I
>>>>only want to process each page if at least one of the values on that page
>>>>has changed. Is there any way to determine whether a value of a control
>>>>(TextBox or ComboBox) has changed?
>>>>
>>>>Thanks
>>>>Elyse
>>>
>>>Elyse,
>>>
>>>I was about to post almost exactly what "Fast Eddie" posted, but, as usual, he beat me to it.
>>>
>>>There was one point he made I'd take issue with. If I understood him correctly, he suggested a logical for each page to let you know whether or not a value on the page had changed. If that's the case, that's a lot unnecessary overhead. What you can do is create a numeric property on the frame or form, initially set to zero. Then create a method, passing the page number to it, as a numeric parameter to change the value. The code might look something like this:
>>>
>>>LPARAMETER pnpagenum
>>>
>>>This.PageFlags = BITOR(This.PageFlags, 2 ^ (pnpagenum - 1))
>>>
>>>When you need to find out if a value on any page has been changed, loop through the PageFlags and test using BITTEST(), like this:
>>>
>>>FOR lni = 0 TO 31
>>> IF BITTEST(This.PageFlags, lni)
>>> * Something was changed.
>>> ENDIF
>>>ENDFOR
>>>
>>>Of course, if there are more than 32 pages, you'll have to create a second set of flags.
>>>
>>>George
>>
>>Ok, now having time I would extend on topic, trying to beat you again :)
>>IMHO, the nice solution is to have form property-array declared in Form.Init:
>>Dimension This.Pageflags(This.Pageframe1.PageCount)
>>Then in any ControlX.InteractiveChange event I would issue:
>>Thisform.Resetpageflags[This.Parent.PageOrder]=.t.
>>So, when it's going to refresh, you just scan the array for .t. elements and refresh particular page using Pages property.
>>Thisform.Pageframe1.Pages(n)
>
>Ah, a debate ;-) There are things to be said for both methods. However, at least from an abstract point, it's actually the same solution. My "array" is limited to 32 elements, but uses memory more efficiently. Your point about refreshing is quite valid, and might be faster if the number of elements is quite large. Yet I could implement almost exactly the same solution using one variable. Further, when it comes to setting multiple "trues", my method is easier and would generate less code overhead.
>
>Of course, this is just IMHO, I could be wrong...
>
>George

You were right, and there are so many ways to implement the same thing, especially moving OO...:)
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform