× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re:Character String help
  • From: Buck Calabro <mcalabro@xxxxxxxxxxxx>
  • Date: Wed, 4 Mar 1998 12:26:30 -0500

>I have a character field used to identify our parts.  The majority of
>these values are numeric in value.  I'm wondering how we can auto-assign
>the "next number" the user should use when adding a new part.

Kevin,
        One means is to keep a data area holding the "last used number"
In your RPG program:

C           *NAMVAR   DEFN           CAL#    70 
C* Next call number                       
C           *LOCK     IN   CAL#           
C                     ADD  1         CAL# 
C                     OUT  CAL#           

This is somewhat primitive, but it gets the job done for an "all numeric"
key.  Beware of rolling the key from 9999999 to 0!

Another way is to SETGT, READP and increment that key to give you
an "available" slot.

For a character key it gets a bit more complicated; I'd CALL an 
external program to implement the algorithm for that.  That algorithm
will depend entirely upon your business' rules for assigning the
letters within the key.

Another way is to have a file of "available" keys.  Each time you
add one to your "live" file, delete it from the "available" pool, and
vice versa

hth
Buck Calabro
Commsoft

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.