Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random
Message
From
30/07/2009 11:02:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Random
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01415429
Message ID:
01415517
Views:
57
Christof,

I notice that you don't seed the Rand() function, but I guess you take care of that elsewhere in your applications?

>>I need to generate random character expressions
>
>Here's a program I use to generate random VFP names:
>
>*========================================================================================
>* Returns a random name that is a valid variable name
>* in Visual FoxPro and 20 to 64 characters long.
>*========================================================================================
>Procedure GetRandomName
>
>	Local lnLength, lcName, lnChar
>	
>	lnLength = Int(Rand()*44)+20
>	lcName = GetChar("A_")
>	For m.lnChar = 2 to m.lnLength
>		lcName = m.lcName + GetChar("A_D")
>	EndFor 
>
>Return m.lcName
>
>
>*========================================================================================
>* Returns a random character.
>*========================================================================================
>Procedure GetChar
>LParameter tcTypes
>
>	Local lnChar
>
>	Do while .T.
>		lnChar = Int(Rand()*256)
>		Do case
>		Case IsAlpha(Chr(m.lnChar)) and "A" $ m.tcTypes
>			Exit
>		Case IsDigit(Chr(m.lnChar)) and "D" $ m.tcTypes
>			Exit
>		Case Chr(m.lnChar) == "_" and "_" $ m.tcTypes
>			Exit
>		EndCase
>	EndDo 
>
>Return Chr(m.lnChar)
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform