Hi,
I've written some code that will search a particular directory and load any file within that directory to be prepared as a texture and button:
set dir "Media\Blocks\"
perform checklist for files
for g = 1 to checklist quantity()
`This next line causes files to be loaded in a nonsequential
`manner?
if right$(checklist string$(g),1) <> "."
load image checklist string$(g),g+40
make_panel(20+g,g+40,Panel(10).xpos+92+((g-1)*33),Panel(10).ypos+36,0,10)
scale sprite 20+g,12.5
endif
next g
ltex = 20 + checklist quantity()
`reset to root path
set dir maindir$
with the make_panel() function as follows:
function make_panel(sno,imno,xp,yp,ispar,pno)
array insert at bottom Panel(0)
plarr = array count(Panel(0))
Panel(plarr).no = sno
Panel(plarr).xpos = xp
Panel(plarr).ypos = yp
Panel(plarr).IsParent = ispar
Panel(plarr).parent = pno
Panel(plarr).active = 0
Panel(plarr).stage = 0
sprite Panel(plarr).no,xp,yp,imno
endfunction
At first when I ran this it all seemed to be going very nicely, however, after checking through the Panel() array I found that the Panel(x).no and x itself were not matching. This is causing problems for me as when I go to check if any of these texture buttons are being selected, I use a for-next loop which requires that the Panel(x).no be sequential. Now I'm pretty sure the reason it isn't working as I'd like it to is the information that the checklist quantity() command is returning. In order to load only files and not directories I've put a line in that does not select files with a '.' as their last value. This it seems is causing the g variable to skip a few numbers in the for-next loop.
Does anyone have any suggestions on how to code this so that the sprite numbers which are used are sequential?
Thank you in advance,
Merk.