Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need to make a Pick() statement, where the order of the expressions is random every time you reload.
Example:
Load
RecNo() as DoorNo,
Pick(RecNo(),'Car','Goat','Goat') as DoorPrize,
AutoGenerate 3,
DoorNo & '|' & DoorPrize as Door;
should sometimes result in 1|Car 2|Goat 3|Goat, sometimes in 1|Goat 2|Car 3|Goat, and sometimes in 1|Goat 2|Goat 3|Car
Thanks for your help in advance,
Lucas
My actual script:
Load *,
DoorNo & '|' & DoorPrize as Door;
Load
RecNo() as DoorNo,
Pick(RecNo(),'Car','Goat','Goat') as DoorPrize
AutoGenerate 3;
Hi Lucas,
probably this works (if I understand it right):
StartValue:
Load
Ceil(Rand()*3) as Random
AutoGenerate 1;
Shuffle:
Load *,
DoorNo & '|' & DoorPrize as Door;
Load
RecNo() as DoorNo,
Pick(Mod(Peek('Random', 0, 'StartValue')+RecNo(),3)+1,'Car','Goat','Goat') as DoorPrize
AutoGenerate 3;
- Ralf
Hi,
This works! So it's pretty much like Pick((Ceil(Rand()*3)+RecNo())*3,'Car','Goat','Goat') as DoorPrize ?
Thanks for your time!
Lucas
It works! Could you explain to me what exactly the SubField function does?
Thanks for helping me!
Lucas
subfield(s, 'delimiter' [ , index ] )
In its three-parameter version, this script function returns a given substring from a larger string s with delimiter 'delimiter'. index is an optional integer denoting which of the substrings should be returned.
No, you cannot be sure to catch all if you call rand() more than once..