> *-- Returns value, and sets .DataValid to the same value, depending on state of all contained controls. > PROCEDURE isvalid > * Program....: QCNTUI.ISVALID > * Version....: 1.0 > * Author.....: Paul Maskens > * Date.......: June 24, 1997 > * Notice.....: Copyright (c) 1997 FoxWare Ltd, All Rights Reserved. > * Compiler...: Visual FoxPro 03.00.00.0711 for Windows > * > * Abstract...: Loop through controls[] > * For every enabled EditBox and Textbox, call its Valid() > * If any of them return .F., then this returns .F. > * If all if them return .T., then this returns .T. > * The return value is also copied to the .DataValid property > * > * Changes....: > * > > * > * laCTabs[n,1] object pointer form .controls[] > * laCTabs[n,2] object .tabindex property value > * laCTabs[n,3] object index in .controls[] > * > LOCAL ARRAY laCTabs[1,3] > LOCAL llValid, lnControl, luResult, loControl > > WITH THIS > * > * Although there is no code in BasicEdits, this provides a hook > * to add the feature later on. > * Simply add code to BasicEdits in any subclass that requires it. > * > THIS.BasicEdits() > > * Assume it's going to work. > llValid = .T. > > .setall("NavDir","+") > > * only if there are any controls > IF .controlcount > 0 > * ensure first/last are dynamic - clear current properties > IF .FirstControl != 0 > .controls[.FirstControl].FirstControl = .F. > .FirstControl = 0 > ENDIF > IF .LastControl != 0 > .controls[.LastControl].LastControl = .F. > .LastControl = 0 > ENDIF > IF .InvalidControl != 0 > .InvalidControl = 0 > ENDIF > * size array to hold control references > DIMENSION laCTabs[.controlcount,3] > * populate array from controls[] > FOR lnControl = 1 TO .controlcount > loControl = .controls[lnControl] > laCTabs[lnControl,1] = loControl > IF UPPER(loControl.baseclass) $ "TEXTBOX|EDITBOX" > * Store text/edit controls in array > laCTabs[lnControl,2] = loControl.tabindex > ELSE > * if it's not a text/edit box - ignore it > laCTabs[lnControl,2] = 9999 > ENDIF > laCTabs[lnControl,3] = lnControl > ENDFOR > > * sort array > =ASORT(laCTabs,2) > ENDIF > > * > * VFP 3 will not execute this loop if there are no controls > * > FOR lnControl = 1 TO .controlcount > loControl = laCTabs[lnControl,1] > IF loControl.enabled ; > AND UPPER(loControl.baseclass) $ "TEXTBOX|EDITBOX" ; > AND NOT loControl.readonly > IF .InvalidControl = 0 > luResult = loControl.valid() > IF TYPE("luResult") == "N" > .InvalidControl = laCTabs[lnControl,3] > llValid = .F. > ENDIF > ENDIF > * handle last/first > IF .FirstControl = 0 > * if it's first > .FirstControl = laCTabs[lnControl,3] > loControl.FirstControl = .T. > ENDIF > * make it the last > .LastControl = laCTabs[lnControl,3] > ENDIF > ENDFOR > * set last control's property > IF .LastControl != 0 > .controls[.LastControl].LastControl = .T. > ENDIF > > .setall("NavDir","") > > .DataValid = llValid > > ENDWITH > > IF TYPE("THIS.parent") == "O" > THISFORM.cmdSave.refresh() > THISFORM.cmdNext.refresh() > ENDIF > > RETURN llValid > ENDPROC >>