If you want to generate many unique strings, you can easily use a zoned numeric subfield in a data structure and add 1 to the zoned field, giving you strings like A000, A001, up to A999.
But you can generate many more unique strings if you use more characters than just 0 to 9. If you add the alphabetic characters A to Z, in a 3-byte field, you can get 46,656 (36 cubed) different values rather than just 1,000 (10 cubed).
The technique is the same as the way you do addition by hand. Given the sequence of characters '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', say you want to "add one" to the string '01B'. You start with the rightmost "digit" ('B') and add one to it ('C'). This gives '01C'. If you start with 'RPZ', since 'Z' is the last character in your sequence, you can't add 1 to it, so you set it to '0' (the first character in the sequence) and move on to the second character ('P'). Adding one to 'P' gives 'Q', so your result is 'RQ0'.
The following program illustrates the technique.
|
Barbara Morris can be reached by email at
Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online