Fox Pro 9 Forms Order of Operations

I am still a bit confused as to the over all flow of information through the forms and the order of operations used. I know the basic order is  Load(),Init(),Show(), and Activate.

Yet each tool also has an order that it seems to follow to

If I were to want a caption on a label to change based upon a certain field value in a given table that the form talks to,where would the following code go

if thisform.checkbox1.value=.f.
thisform.label1.caption="NO"
endif

And how would it update as records are being stepped through Using standard buttion groups-Top/bottom/previous Etc?



if thisform.checkbox1.value=.f.
thisform.label1.caption="NO"
endif

Open in new window

MalibucompanyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CaptainCyrilConnect With a Mentor Founder, Software Engineer, Data ScientistCommented:
I would put them in Refresh and call it on record change or bind it to other events that I need.
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
For that aspect you should use an optiongroup with options "YES" and "NO" and bind to (iif(table.logicalfield,1,2)), which translates .T. to option 1 and .F. to option 2.

I would find it rather disturbing, if the caption beside a checkbox would turn from YES to NO when checked or unchecked. Don't you think it will make the user really unsure what to do with that checkbox? The normal semantic is, that checked a checkbox means what it captions says, unchecked it means NOT that. So an uncheckeed NO means YES and a checked YES means YES, then I'd expect this control to be useless ;)

Bye, Olaf.
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
besides that, there is the InterActiveChange Event (and ProgrammaticChange) for that:

In fact this is redundant code for the two events and should ideally be put in yet another method that is called bot by interactive/programmticChange. But then it's only one line...

Bye, Olaf.
* both in interactivechange() and programmaticchange() of a checkbox control put
this.caption = iif(this.value,'YES','NO')

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
pcelbaConnect With a Mentor Commented:
As Captain wrote, the form's refresh should update all controls on the form. If you move the record pointer then you have to call refresh method of the form and it does all the work for included controls. Controls on the form should not comunicate directly but each change must be propagated to other controls via certain form's method. Only form knows about contained controls. This will ensure relative independency of form controls.

In your example both checkbox and label seems to be data dependent, so they don't need to know each other but form knows about them and the form's refresh method should update both of them.

If you would like to update some label caption based on interactive change on some checkbox then the checkbox InteractiveChange method should call THISFORM.CheckBoxChanged() method and the form has to decide what to do and how to update the label caption if necessary (the label will probably be based on some class which is able to recieve some controlling messages from its parent).
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
pcelba, a checkbox has a label/caption itself. I'd use that.

Otherwise your thought on a CheckBoxChanged method is okay, although I'd perhaps use Refresh to propagate all record changes or record pointer movements in a form, that's what it's for. If you want to minimize this kind of "messaging" between checkbox and label, as they are the only ones involved in this boolean field change, but then record pointer movement is not handled by a CheckBoxChanged() method.

Bye, Olaf.
0
 
pcelbaConnect With a Mentor Commented:
My idea was to call CheckBoxChanged() method after its manual state change only. But together with messaging it was a little bit out of this topic...

The record change should refresh the whole form, of course.

And yes, I know the checkbox has its own caption, and hope Malibucompany knows it, also. I suppose the label is not as close to the checkbox as you mean :-).
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
Well, "messaging". If you call a method due to a interactivechange, and that method then does forward this change somewhere else on the form, you could say that it is messaging. Not what you normally would call messaging, but it in fact already has many aspects of it, especially decoupling the manual change of the checkbox from the change of the label via a third party, which in this case is the form, not really messaging.

If you'd introduce a method for each control change, you'd end up with rather much method's tough. You can use the Refresh() method from the interactivechange of any control you know it's change implies a change elsewhere too and then let the refresh propagate to each control, which then in it's refresh() method can adapt to the new data, that is you could also do the label caption change in the label's refresh, and that then should read the boolean field value from the alias bound to the checkbox, not from the checkbox.value, if it's really the case, that the label is not the one within the checkbox.

Bye, Olaf.
0
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
pcelba, you'r eright from the outset, Malibucompany talks of thisform.checkbox1 and thisform.label1, but I assumed Malibucompany didn't realized a checkbox has it's own label and there's no need to use a seerate label control.

Even if, the refresh mechanism would work this way:
in checkbox.interactivechange() do thisform.refresh()
this cascades refresh() to every control on the form, so also lable.refresh() will run
in label.refresh() do this.caption = iif(alias.field,'YES','NO')

Bye, Olaf.
0
All Courses

From novice to tech pro — start learning today.