Information générale
Catégorie:
Codage, syntaxe et commandes
OK, I feel like I'm looking at a repeating # problem on an IQ test. I understand the concept, but why multiply by 25 if rand() is even or by 9 if not?
Thanks
John
>FUNCTION GeneratePwd
>LPARAMETERS pnLen && Length of Password - in your case 6
>
>rand(-1)
>LOCAL lcPwd, lnRnd, lnCnt
>
>lcPwd = ""
>FOR lnCnt = 1 TO pnLen
> IF lnCnt = 1 OR mod(int(rand() * 100), 2) = 0 then
> lnRnd = int(rand() * 25) + 97
> ELSE
> lnRnd = int(rand() * 9) + 48
> ENDIF
> lcPwd = lcPwd + chr(lnRnd)
>ENDFOR
>
>RETURN lcPwd
>ENDFUNC
>
>
>HTH,
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement