Path: utzoo!mnetor!uunet!husc6!bbn!rochester!ur-tut!aisl From: aisl@ur-tut.UUCP (Larry Landry) Newsgroups: comp.sys.mac.hypercard Subject: Re: shuffling cards Message-ID: <778@ur-tut.UUCP> Date: 4 Jan 88 21:35:40 GMT References: <3708@tut.cis.ohio-state.edu> Reply-To: aisl@tut.cc.rochester.edu.UUCP (Larry Landry) Organization: Univ. of Rochester Computing Center Lines: 42 In article <3708@tut.cis.ohio-state.edu> neruda@tut.cis.ohio-state.edu (Steve Neruda) writes: > >What is the fastest way to randomize a stack of quiz cards? I did it by >assigning each card an invisible field, putting a random number into this field >and then sorting by the field. This works fine but i rather slow > I think that you have described the quickest way to do this in HyperCard. I implemented such a routine and it could shuffle 100 cards in less than 10 seconds. That seems quite reasonable for an interpreted system. The script that I use is shown below. on mouseUp set lockscreen to true set editBkgnd to true -- create new field in background doMenu "New Field" put the number of fields into fn -- number of background fields set editBkgnd to false put the number of cards into count repeat for count times put the random of 10000 into field fn go next card end repeat sort by field fn -- do the actual sort set editBkgnd to true -- delete the sorting field click at location of field fn doMenu "Cut Field" choose browse tool -- so the user can look at stack set editBkgnd to false set lockscreen to false end mouseUp It is important to use the index of the field if speed is your biggest concern since it is accessed quicker than the name of the field. The sort command is much faster than anything that you could write in a script If you were not using it, that is probably your problem. Larry Landry University of Rochester