Iniciar Sesión

Ver la Versión Completa : [Componente] Rutina Números Aleatorios


Hrmcobol
11 de octubre de 2017, 20:38
Hola Amigos !!!!
Necesito una rutina, ocx, etc que genere números aleatorios de 3, 4 o 5 dígitos
Alguien tiene algo sobre este tema
Saludos !!!!

Fito
11 de octubre de 2017, 22:44
Hola:

Nunca lo probé, pero a lo mejor esta función te sirve.

RANDOM Function
This function returns a pseudo random value from uniform distributions.
Format
FUNCTION RANDOM [(argument-1)]
Argument
1. The type of argument-1 must be integer.
2. The value of argument-1 must be zero or a positive integer. It is used to
generate a pseudo-random string.
3. The RANDOM function with argument-1 will generate a pseudo-random string
using argument-1 as source.
4. If argument-1 is omitted in the RANDOM function first executed in the run unit, a
pseudo-random string is generated using zero as source.
5. When determining a random value from the same pseudo random string after
execution of the RANDOM function, argument-1 may be omitted. The value of
argument-1 is valid until the next RANDOM function having argument-1 appears.
Function Value
1. The function value is any value in the current pseudo-random string.
2. The range of the function value is:
0 ≤ function value < 1
3. If the value of argument-1 (source value) is the same as in a previous execution,
the same pseudo-random string is used.

Saludos.

Fito...

Hrmcobol
15 de octubre de 2017, 01:26
Acá esta la respuesta FITO, me la paso un amigo !!



ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Misc.
05 Pseudo Pic X.
05 Multi-Digit Pic 999999999V9(6).
05 Two-Digit Pic 99999999.
05 Vary Pic 99.
05 hora Pic 99999999.
PROCEDURE DIVISION.

Return-Pseudo.
ACCEPT HORA FROM TIME
Compute Multi-Digit = (Function Random (hora)) * 1
Display Two-Digit " VARY" Vary " -----1--> " Multi-Digit " --------> " hora
Perform Varying Vary from 1 by 1
Until Vary > 50
Compute Multi-Digit = (Function Random) * 1
Move Multi-Digit to Two-Digit
Display Two-Digit " VARY" Vary " --------> " Multi-Digit " --------> " hora
End-Perform