× 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.



On 03-Jul-2017 21:30 -0600, Booth Martin wrote:
Random generating a 16-digit number:

Whether the number must be a "counting number" [i.e. positive integer value] or inclusive of zero is unstated; be sure to verify whatever interface gives the desired effect.

An easy task in Rexx. Or so I thought. I can not figure out how to
return that value to the calling program. QREXQ seemed the right way
but I can not make it happen.[…]


Specifically for using REXX; though IMO, not as easy, as compared to using SQL:

If the biggest value requirement were for a smaller number, perhaps merely 15-digits as a whole number, then a *DEC decimal Data Area (DTAARA) could hold the return-value for a caller. Or as an alternative, perhaps storing part of the whole number precision as digits _after_ the decimal point, which, as Packed BCD, the caller can [re]assign an alternative Precision and Scale to the data; i.e. maximum for the DtaAra is DEC(24:9).

Or, a *DTAARA could still be used for the full 16-digits, but having used a *CHAR character Data Area, such that the digits would be stored as character, which, can appear as effective Zoned BCD from the perspective of the caller, again irrespective precision and scale used in the called program; e.g.:

/* REXX_RANNO generates a 16-digit value */
/* stored into *DTAARA QTEMP/REXX_RANNO */
numeric digits 32
"dltdtaara dtaara(QTEMP/REXX_RANNO)"
"crtdtaara dtaara(QTEMP/REXX_RANNO) TYPE(*char) len(16)"
rn=""
do i = 1 to 4 /* four, 4-digit numbers concatenated */
rn = rn || rn4dig()
end
/* cannot use &RN below; value perceived numeric CPD0095 */
/* chgdtaara dtaara(qtemp/rexx_ranno) value(&rn)" //Ugh! */
"chgdtaara dtaara(qtemp/rexx_ranno) value('"rn"')"
debug: "dspdtaara qtemp/rexx_ranno output(*) outfmt(*char)"
exit
/* Function: rn4dig() returns a 4-digit */
/* random number as a 4-character string */
rn4dig: procedure
return right( '0000' || random( 9999 ) , 4 )


In SQL, for a similar [character] effect:

values (digits(dec(rand(), 16, 16)))


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.