Hi All - this worked once - I think - but does not anymore. Can anyone see another way to randomly order some items in an array of records. Not the array is global, but I don't know its initial size. This is taken from a very large project that has stopped working :( This is based on Alain's code to do much the same thing (except that was a fixed length array. Thanks David '~'A ' Runtime : RNTM Lite.INCL ' CPU : cpuPPC ' Debugger : On ' DIM'd Vars Only : On ' No Re-DIM'd Vars : On ' CALL Req'd : Off ' Register Vars : On ' MacsBug Labels : On ' Ary Bounds Checking : On ' QB Labels : Off ' Optimize STR# : Off ' Make Line Start Table : Off ' Show Warnings : On '~'B begin globals dim record ObjectList dim selected%'order in list dim fileType&'File Type eg _"sfil" dim 33 fileName$'File Name dim end record .gFileListSz Xref@ gFileInfo.gFileListSz (10000)'global array for sound files end globals LOCAL FN setUpDataArray (noPoints,ptSize) dim memReq& dim memAvail& dim myHndl as handle memReq& = (noPoints+1) * ptSize'calculate memory required memAvail& = SYSTEM(_memAvail)'get available memory LONG IF memReq& < memAvail&'check that there is enough memory myHndl = FN NEWHANDLE _clear (memReq&)'create new handle 'gHndlSize& = memReq&'store the current handle size XELSE'if not enough memory 'FN pGshowErr(16) END IF END FN = myHndl local fn fillData dim as int x for x = 1 to 12 gFileInfo.fileName$(x) = "FileName"+str$(x) gFileInfo.fileType&(x) = _"type" next x end fn LOCAL FN betterRNDfiles (firstItem%,lastItem%) /*This function randomises a global XREF@ array of fileNames and file types -----------------------------------------*/ dim as int K,range dim as int randomIndex dim as STR255 fileN1,fileN2 dim type1&,type2& range = lastItem% - firstItem% FOR K = firstItem% TO lastItem% randomIndex = rnd(range+1)+firstItem%-1 long if randomIndex <= lastItem%'be be sure swap gFileInfo.fileName$(K),gFileInfo.fileName$(randomIndex) swap gFileInfo.fileType&(K),gFileInfo.fileType&(randomIndex) end if NEXT K END FN local fn printData dim as int x for x = 1 to 12 print gFileInfo.fileName$(x) print gFileInfo.fileType&(x) next x end fn gFileInfo.nil& = FN setUpDataArray (13,_gFileListSz) fn filldata FN betterRNDfiles (3,12) fn printData stop