Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random record selection
Message
From
07/07/2023 07:45:09
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
06/07/2023 18:43:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686799
Message ID:
01686801
Views:
63
>>I have a table that contains file names for images. I am looking for a way or code that would randomly select the record in the table and from that I would capture the file name and display that particular record.
>>
>>MyImages.dbf
>>image_id (num) primary key
>>image_path (memo)
>>
>>Image_path: contains where the image is located. for example: F:\devserver\app\myimage27.jpg
>>
>>Is there a way to scan and randomly select a record, capture the image_path and then display that image on a form.
>>
>>I am using vfp 9.0
>>
>>thanks in advance
>Look at the Help for RAND(). The second example shows how to do a random number from 1-10.
>Instead of 1-10 yours would be 1 - number of records in your table then GO TO random number.

...which may not necessarily work in each case, as the target record may be deleted, or out of current index or something like that. There's a safer and not much slower option, locate for recno()>=nRandomNumber, then just check for eof().

Or, take the existing app and do something with it: https://www.levelextreme.com/Home/ShowHeader?Activator=17&ID=40436

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform