>lcRandNum = ALLTRIM( STR( INT( RAND() * 1000))) >lcDateStr = ALLTRIM( DTOC( DATE())) >lcDateStr = STRTRAN( lcDateStr, "-", "_") + lcRandNum >lcFilePath = PUTFILE("Export Results", "S" + lcDateStr, "XLS") >>
RandTest(1000) && Zoom level 1000 which is what you are using RandTest(10000) RandTest(100000) RandTest(1000000) FUNCTION RandTest LPARAMETERS lpnZoom as Integer CLOSE TABLES ALL *Make it as random as VFP gets RAND(-1) * Generate one thousand number CREATE CURSOR ccc (nr I) FOR i = 1 TO 1000 INSERT INTO ccc VALUES (INT(RAND()*m.lpnZoom)) NEXT SELECT distinct nr FROM ccc INTO CURSOR ddd MESSAGEBOX("Zoom Level: " + TRANSFORM(m.lpnZoom,"999,999,999") + CHR(13) ; + "Count of generated number: " + TRANSFORM(RECCOUNT("ccc"),"999,999,999") + CHR(13) ; + "Count of distinct number: " + TRANSFORM(RECCOUNT("ddd"),"999,999,999")) ENDFUNC && RandTestAs the test shows that if you are going to use rand()*1000, you're better off using a bigger number to multiply the result of rand() to increase the distinctiveness among the generated numbers.
FUNCTION GetVFPUID(lpcPrefix as String) IF VARTYPE(m.lpcPrefix) = "C" AND ; NOT EMPTY(m.lpcPrefix) ; THEN RETURN ALLTRIM(m.lpcPrefix) + Substr(SYS(3),5,4) + Substr(SYS(2015),7,4) ELSE RETURN Substr(SYS(3),5,4) + Substr(SYS(2015),7,4) ENDIF ENDFUNC && GetVFPUIDHTH
"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."
- Ephesians 4:29-30 NIV
Dare to Question -- Care to Answer
Time is like water in a sponge, as long as you are willing you can always squeeze some.
--Lu Xun, Father of Modern Chinese Literature