counting CHARs after DIGITS

Jeff Hoffman J.Hoffman@cchs.usyd.edu.au
Sun, 23 Apr 2000 10:36:18 +1000


Friedrich

At 09:40 am 21/04/00 +0200, you wrote:
>Dear lister
>
>We have a problem in running out of numbers in akey item in our DB.
>
>The field RISIKONR is 6 digits long, but has been design as  CHAR*6 field.
>
>I am now looking for an algorithm which does use CHAR afte running out of
>digits, like
>
>999999
>A00000


You could try :


item RISIKONR char*6
redefined by
  item RISIKONR-prefix char*1
  item RISIKONR-no     size 5 zoned unsigned
  end

def  a-i char*27 = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ"
temp d-i int*2

if RISIKONR-no = 99999
then begin
   let d-i             = 64 + index(a-i,RISIKONR-prefeix)
   let RISIKONR-prefix = char(d-i)[1:1]  ; or [2:1] depends upon your platform
   let RISIKONR-no     = 0
   end
else let RISIKONR-no = RISIKONR-no + 1

now if the prefix is "9", then d-i will = 65 = "A"
    if the prefix is "A", then d-i will = 66 = "B" etc 

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ Jeff Hoffman                         + e-mail: J.Hoffman@cchs.usyd.EDU.AU +
+ Director                             +                                    +
+ WoniCon Pty Ltd   (ACN 083 502 630)  +                           ,-_|\    +
+ 21 Prices Circuit                    +  voice: +61 2 9542 1527  /     \   +
+ Woronora    NSW     2141             +    fax: +61 2 9521 3979  \_,-._*   +
+ AUSTRALIA                            +                               v    +
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.