Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading plaintext?
Message
De
25/11/2008 09:08:40
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Divers
Thread ID:
01363610
Message ID:
01363959
Vues:
16
>>I was asked for help with a toy project - read in a plaintext file and return a random line from the file. I could do this easily with a table, but don't know enough about low level file functions to do that job easily. Can I get a kick in the right direction, please?
>>
>>Chris.
>
>Just a quick thought (ie not completly thought through)
>
>How about this:
>
>RAND()
>lcText = FILETOSTR("myFile.txt")
>ALINES(myText, lcText)
>?myText[RAND()*ALEN(myText)]

Almost there - except that it may hit the zero line in a one-based array, so I'd rather put the last line as

?myText[int(RAND()*ALEN(myText))+1]

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform