Ok, here is the way I would do it:
 Code:
Break ON

$fso = CreateObject("Scripting.FileSystemObject")
$txt = $fso.OpenTextFile("C:\data\file.txt",Not 0)
$Array=Split($txt.ReadAll,@CRLF)
$txt.Close

$=SRND(@MSECS)
$=RND(0)

$Pick=2

For $Output=1 to $Pick
	$Array=Split(udfSqueeze(Join($Array,@CRLF),@CRLF),@CRLF)
	$iChose=IIf(UBound($Array)>0,RND(UBound($Array)),0)
	"Selection "+$Output+": "+$Array[$iChose]+@CRLF
	$Array[$iChose]=""
Next

Function udfSqueeze($s,$q)
	$udfSqueeze=$q+$s+$q
	While InStr($udfSqueeze,$q+$q)
		$udfSqueeze=Join(Split($udfSqueeze,$q+$q),$q)
	Loop
	$udfSqueeze=Split($q+$udfSqueeze+$q,$q+$q)[1]
EndFunction


The method strips array elements out once they have been selected, meaning that you won't hit a blank element and you won't need to retry.

Retrying is not a huge problem when your select set is a small proportion of the entire set, but as the proportion grows you will get more and more hits on an empty array element.

Of course you need to balance this against the work needed by all the split/joins.

In this example if you have 4 lines in the file and you attempt to pick 10 lines then the script will not fail, it will report null values for picks 5-10.


Edited by Richard H. (2008-12-15 03:18 PM)
Edit Reason: Removed debugging code