Oops, the count-the-digits part is different..my apologies..

For that, Joel Fritz's suggestion seems best to me..

..Alan

----- Original Message -----
From: "Alan Cassidy" <acassidy@pioneermetals.com>
To: <midrange-l@midrange.com>
Sent: Tuesday, July 09, 2002 5:41 PM
Subject: Re: string editing suggestions


>
> And again, my contribution:
>
> I have been working on exactly the same problem. Code follows. Is this too
> complicated? It gives them exactly what's wrong... (Could be different
> requirements sometimes).
>
> INV# is the field.
> I pick up DTATYP, DTLEN(C) from a control file after determining the value
> is required given certain data conditions, then:
>
>
>  * - Check for blank invoice number (make sure it's there)
> C                   when      inv# = blks
> C                   eval      *in56 = *on
> C                   eval      scmsg = 'Inv-# must be entered for this
> vendor'
>
>  * - Left-justified. (I could internally left-0justify, but for xyz
reasons
> did not)
> C                   when      %subst(inv#:01:01) = blk
> C                   eval      scmsg = 'Inv-# must be left-justified.
>
>  * - Length: I check the length after stripping off the leading and
trailing
> blanks
> C                   when      %len(%trimr(inv#)) <> ctlinvlen
> C                   eval      scmsg = 'Inv# for this vendor requires ' +
> DTALENC + ' digits'
>
>  * - Make sure it's numeric.
> C                   when      DTATYP = 'NUM'
> C     digits        check     inv#          xa
>
> This gives the position of the first non-digit, where DIGITS =
'0123456789'.
> The resulting position XA should be zero if the length required is the
same
> as the length of the field, or else it cannot
>
> C                   if        xa <> 0 and xa < %len(%trim(inv#))
>                                or xa = 0 and DTALEN <>  %len(inv#)
> C                   eval      scmsg = 'Inv-# for this vendor -
> C                             requires digits, 0 trhough 9 only'
> C                   endif
> C                   endsl
>




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.