Hi Peter,
Sergey offered the RETURN command, which in this instance would be used in several locations in the example you offer.
Personally, I prefer to have one and ONLY one exit point from code. Additionally, to be *really* structured, the procedure should probably only return whether the validation was successful -- the *CALLING MODULE* should determine how to handle the result (close the form, display an error message, whatever).
There are several ways to handle this. Here's one way I might:
LOCAL lcMsg
lcMsg = ""
DO CASE
CASE -field data NOT valid-
lcMsg = "Field data is invalid"
CASE -file doesn't exist-
lcMsg = "File does not exist"
CASE -processed info NOT created-
lcMsg = "Process info missing"
CASE -any other failure-
lcMsg = "Other failure"
ENDCASE
RETURN ( lcMsg )
Then, the calling program can check the returned value. If it's blank, life is good. If it's not, the return value tells you WHY things are off kilter.
This helps not only in determining why something's not working, but also allows you to call this code from various places without being dependent on a particular form or object being active.
HTH.
>I am writing a procedure that requires a certain set of criteria to happen before the end of the code can process. I need to know, other than a huge set of nested IF ENDIF calls, is there away to jump out of the code.
>
>Here is an example.
>
>In the CLICK method for a button that is labeled NEXT... when the user clicks on the NEXT button, it needs to process some information. If any of it fails it needs to remain on the current form after displaying an error msg. Writing this with IF's would look something like this.
>
>IF - verify proper field data is ok
> ** data OK
> IF - verify file exists
> ** file exists
> IF - processed info created
> ** processed complete
> IF - remaining criteria met
> ** all done
> ** thisform.release
> ELSE
> ** display error
> ENDIF
> ELSE
> ** display error
> ENDIF
> ELSE
> ** display error
> ENDIF
>ELSE
> ** display error
>ENDIF
>
>
>This is true structured programming because it doesn't release the form until all the criteria is met.... BUT... and I know this is wrong for true programmers... but for a large chunk of code, it's easy to lose track of which loop you are in and what needs to happen. I was wondering if there was something like an EXIT call that get you out of the button code and return to the form input.
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN
If a vegetarian eats vegetables, what does a humanitarian eat?