|
2#
楼主 |
发表于 2006-5-24 10:52:03
|
只看该作者
转贴
下面是论坛中版主发,我想问一下,load("win32api");有什么用?能举例说明吗?谢谢!!
# Function: getRandom
# Purpose: Generate integer random numbers between a range, and place them in an output array/
# Parameters: in Minimum (integer), in Maximum(integer), out RandomArray (array that holds integers)
# Return Values: Numeric Error codes: 0: OK; -1: error
load("win32api");
public function getRandom(in iMin, in iMax, out aRand[]) {
auto iRange, i;
if (iMin < 0 || iMin > iMax || (iMin + iMax)==0)
return -1;
if (int(iMin) != iMin || int(iMax) != iMax)
return -1;
iRange=(iMax-iMin) + 1;
srand(GetTickCount());
for (i=0; i<iRange; i++)
aRand[i] = int(rand()*iRange) + iMin;
return 0;
}
#When used with the following calling code, random output listings were created.
if (getRandom(1,5,aRnd)==E_OK)
{
buf="";
for (i=0; i<10; i++)
buf = buf & " " aRnd[i];
print(buf);
}
texit; |
|