[futurebasic] Re: [FB] anyone remember ... (looking for the source code)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2001 : Group Archive : Group : All Groups

From: Ian Mann <i.mann@...>
Date: Fri, 02 Nov 2001 08:06:51 +0000
Hi,

this is how I sort a playlist, where I don't want elements to occur more/less
often than they do in the original Array.

FN NewSortFindHandle& is just NewHandle with a bit of checking.
RandomPlayList& is an xref @ array

This could probably be faster but it's not in a speed critical area for me.

clear local
dim Count as unsigned short
dim RandomCount as unsigned short
local fn RandomisePlayList
RandomPlayList& = FN NewSortFindHandle&(RandomPlayList&,SIZEOF(unsigned
Short),gNumInPlayList)
for Count = 1 to gNumInPlayList
RandomPlayList(Count) = 0
next
Count = 0
do
RandomCount = rnd(gNumInPlayList)
long if RandomPlayList(RandomCount) = 0
inc(Count)
RandomPlayList(RandomCount) = PlayList(Count)
end if
until Count = gNumInPlayList
for Count = 1 to gNumInPlayList
PlayList(Count) = RandomPlayList(Count)
next
def disposeh (RandomPlayList&)
end fn

Regards

Ian