SoloCodigo

Programación General => Power Builder => Mensaje iniciado por: Zuzunaga en Viernes 24 de Noviembre de 2006, 22:51

Título: Generar Numeros Aleatorios De Un Valor Min A Un Ma
Publicado por: Zuzunaga en Viernes 24 de Noviembre de 2006, 22:51
Hola ,alguien sabe como generar numeros aleatorios de un valor minimo a un valor maximo.
Título: Re: Generar Numeros Aleatorios De Un Valor Min A Un Ma
Publicado por: leoandres en Viernes 24 de Noviembre de 2006, 23:19
Saludos..

Documentación de PB.... lee primero...

Description

Obtains a random whole number between 1 and a specified upper limit.

Syntax

Rand ( n )
Argument   Description
n    The upper limit of the range of random numbers you want returned. The lower limit is always 1. The upper limit is 32,767
Return value
A numeric data type, the data type of n. Returns a random whole number between 1 and n inclusive. If n is NULL, Rand returns NULL.
Usage
The sequence of numbers generated by repeated calls to the Rand function is a pseudorandom sequence. You can control whether the sequence is different each time your application runs by calling the Randomize function to initialize the random number generator.


ej:

integer il_numero

il_numero=ran(1000)

Te genera un numero entre 1 y 1000

también...

Description

Initializes the random number generator so that the Rand function begins a new series of pseudorandom numbers.

Syntax

Randomize ( n )
Argument   Description
n    The starting value (seed) for the random number generator. When n is 0, PowerBuilder takes the seed from the system clock and begins a nonrepeatable sequence. A nonzero number generates a different but repeatable sequence for each seed value. n cannot exceed 32,767
Return value
Integer. If n is NULL, Randomize returns NULL. The return value is never used.
Usage
The sequence of numbers generated by repeated calls to the Rand function is a computer-generated pseudorandom sequence. You can use the Randomize function to initialize the random number generator with a value from the system clock, or some other changing value, so that the sequence is always different. For testing purposes, you can select a specific seed value, which you can reuse to make the pseudorandom sequence repeatable each time you run the application.

Include Randomize in the script for the Open event in the application.
Título: Re: Generar Numeros Aleatorios De Un Valor Min A Un Ma
Publicado por: leoandres en Viernes 24 de Noviembre de 2006, 23:20
Disculpa...

ej:

integer il_numero

il_numero=rand(1000)

Te genera un numero entre 1 y 1000