Consultor Eletrônico



Kbase 17407: How to call MS Visual C Runtime Library function: rand
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to call MS Visual C Runtime Library function: rand

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the rand function
available in the Microsoft Visual C Runtime DLL.
The rand function generates a pseudorandom number based on a seed.

IMPORTANT: If your application does not require seed-based random
numbers you can use the PROGRESS 4GL RANDOM function.

PROCEDURE rand EXTERNAL "MSVCRT.DLL" CDECL:
DEFINE RETURN PARAMETER ret AS LONG.
END.

PROCEDURE srand EXTERNAL "MSVCRT.DLL" CDECL:
DEFINE RETURN PARAMETER seed AS LONG.
END.

DEF VAR seed AS INT.
DEF VAR r AS INT.

UPDATE seed.
RUN srand(seed).
REPEAT:
RUN rand(OUTPUT r).
DISPLAY r.
END.

Progress Software Technical Support Note # 17407