Validation loop?

Kladkul

Member
Hi,

I'm having difficulty deciding the best way to validate several fields in an application window. Here is the scenario:

There are several fields (lets say 4) that have the validation code already written for them. The way I need them to validate is once a button is pressed it does a number of writes to a database but first it hits a validation procedure.

Within this validation procedure is a validation procedure for each of the fields (so 4 procedures). I need the program to halt and wait for the user to fix their issue before continuing. The only way I can think to do this is a loop however it will only be an infinate loop. Any help is greatly appreciated.

Thanks.

Edit: Just got an idea on this... return a variable that has a fields name in it. Return to the calling ON CHOOSE OF btn:

/*all variables are global */
DO WHILE v-flg = NO:
RUN validProc NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
APPLY "ENTRY":U TO var1.
END.
ELSE DO: /* no errors */
ASSIGN v-valid = YES.
END.
END.

My only beef with this is how this can be done where var1 stores the name of the field. Any takers on this approach?
 
You can't do it with var1 containing the name of the field. You will have to use a case statement or other selection to pick the field.

But, you should also consider your user interface. It is good that you aren't trapping the people in the field until they enter a valid value, but you do seem to be trapping them on the screen and putting them back in the field. Suppose they start to enter something and realize that someone has failed to give them all the information or some of the information is wrong?

Better to validate and ask them if they want to fix or discard.
 
I don't believe it will trap them in the screen, as they can still hit a cancel button. I do like your idea of asking whether to discard or fix though.

Would it be possible to instead of using a variable, use a handle, and change what the handle is pointing to in the called procedures?
 
Back
Top