Page 1 of 2

How Can I cause Express to Validate Fields When I Click SAVE

Posted: Sat Oct 13, 2012 4:12 am
by unixkd
Hello Roger

I have a SAVE button in my main Dialog. If I open a dialog (MDI) and enter some GETs, I want all the VALID clauses of my GETs to be executed, before a successful save. Similar to EXITVALIDATE clause of DCGETOPTIONS, but my dialog is not closed.

Thanks.

Joseph.

Re: How Can I cause Express to Validate Fields When I Click

Posted: Sat Oct 13, 2012 2:40 pm
by Cliff Wiernik
I put the items I want to have validated, usually only a subset of the valids on the gets, in a CheckValid(aApp,aMainGetlist) function call. This validates the array of codeblocks I put here and if it fails, it returns focus to the get object specified.

The call is in my save button codeblock. I like it better as it gives me the control I need. No every valid needs to be revalidated. Some of the field level valid items are sufficient themselves and do not need to be validated when the save button is called.

Cliff.

Re: How Can I cause Express to Validate Fields When I Click

Posted: Sun Oct 14, 2012 12:17 am
by Tom
Traverse the getlist array, evaluate the VALID clauses if there are some:

Code: Select all

FUNCTION ValidateAll(aGetList)
LOCAL i, bValidBlock, lWhatToDo
FOR i := 1 to Len(aGetList)
  bValidBlock := aGetList[i,bGETLIST_VALID]
  lWhatToDo := Eval(bValidBlock) // evaluate VALIDs
  * do something - or nothing
NEXT
...

Re: How Can I cause Express to Validate Fields When I Click

Posted: Sun Oct 14, 2012 7:50 am
by rdonnay
You could also use the function DC_GetListValidate( GetList ).

Re: How Can I cause Express to Validate Fields When I Click

Posted: Mon Oct 22, 2012 4:27 pm
by MIGUELON
This is fine but if I have a GET with HILDE {. T.} And I also have a VALID validates it.

It is possible to exclude GET HILDE {. T.} :?:

thanks
Miguel

Re: How Can I cause Express to Validate Fields When I Click

Posted: Mon Oct 22, 2012 6:34 pm
by rdonnay
I don't understand why you would have a valid clause on an object that is always hidden.

Re: How Can I cause Express to Validate Fields When I Click

Posted: Mon Oct 22, 2012 9:56 pm
by MIGUELON
Sorry I have not expressed well. I mean I have certain GETS that may or may not depending on a condition HILDE for example:

HIDE {| | nControl> 2}

Thanks for your reply and greetings

Miguel

Re: How Can I cause Express to Validate Fields When I Click

Posted: Tue Oct 23, 2012 6:18 am
by rdonnay
Sorry, DC_GetValidate() has always ignored Gets that are not visible.
I will probably not change that behavior now because it will break other applications.

You can use Tom Liehr's suggestion or you can modify the DC_GetValidate() code in _DCGETBX.PRG.

Re: How Can I cause Express to Validate Fields When I Click

Posted: Tue Oct 23, 2012 7:31 am
by MIGUELON
Roger seems that we still do not understand so I'll start again with the question.

My problem is that when I run "DC_GetListValidate (GetList)" I is validating all including hidden GETS HIDE {| | nControl> 2} and do not want to happen.
I confirm that I GETS only assets and not hidden.

Regards
Miguel

Re: How Can I cause Express to Validate Fields When I Click

Posted: Tue Oct 23, 2012 8:45 am
by reganc
MIGUELON wrote:Roger seems that we still do not understand so I'll start again with the question.

My problem is that when I run "DC_GetListValidate (GetList)" I is validating all including hidden GETS HIDE {| | nControl> 2} and do not want to happen.
I confirm that I GETS only assets and not hidden.
Using Toms code as a starting point, you can use the getlist pointer bGETLIST_HIDE to return the HIDE codeblock. If that codeblock evals as TRUE then don't eval the VALID codeblock for that item.