David J Murray
~ Learn and Do - Excel and Share ~

Validation SB Style

Feb 14, 2006

Image by Chaos07 from Pixabay

You're Reading: Validation SB Style

It would be useful to be able to validate data in a subroutine the same way that SB+ does in a field.

The long way is to use the execute routine:

CALL SB.PROCESS("V:CUSTOMER.ID.VAL")
IF RTN.FLAG NE 0 THEN

...error code...
END

Or for a quicker method you can use the routine SB.VALIDATE to do this.

VALUE = 1234567
VALIDATE.TXT = "F:FILE.NAME,DESCRIPTION,Y{}"
CALL SB.VALIDATE(VALIDATE.TXT)
IF RTN.FLAG NE 0 THEN

...error code...
END

Where:

  • VALUE – The value to validate.
  • VALIDATE.TXT param – The validation to perform. The empty string error message {} stops an error being displayed to the user.
  • RTN.FLAG – 0 if validated else 1 if an error.

This becomes most useful when you have a standardized validation process which you may want to use in your own code:

VALUE = 1234567
VALIDATE.TXT = "C:CUSTOMER.ID.VAL"
CALL SB.VALIDATE(VALIDATE.TXT)
IF RTN.FLAG NE 0 THEN

...error code...
END

Which method to use? Calling the SB.PROCESS routine is going to work as it is a documented option. The SB.VALIDATE routine does not seem to be documented, so it could change or disappear over time…

Be weary though, if the validation process has an error message, it will be displayed.

About the Author

<a href="https://davidjmurray.org/author/davidjmurray/" target="_self">djm</a>

djm

I have been in the computer/IT industry for over 35 years. After spending half a life-time in highly proprietary database environments, I have succumbed to the WordPress Eco-system and I'm well down the chasm. I am specializing in AWS hosting, Wordpress CMS, Elegant Themes, in particular Divi and Extra themes.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This