sometimes works sometimes doesn't, building an open file screen for android

Previous topic - Next topic

goldbaby777

some directories crash the program some don't..... either on android or in windows....... can you figure it out? i don't get it....


ok = SETCURRENTDIR("/") // One up
SYSTEMPOINTER TRUE
reload:
lin=0
change=0
//fdl1=BOUNDS(files$[],0)-1
//FOR lin=1 TO fdl1
//files$[lin]=""
//NEXT
REDIM files$[50000]
lin=0
fdl1=0
cur$ = GETCURRENTDIR$()
num = GETFILELIST("*.*", files$[])
// ..num_dir  = INTEGER(num / 0x10000) // Hi-Word
// num_file = MOD(num, 0x10000)      // Lo-Word
// //num=num_dir+num_file
//PRINT "ok? " + ok+ " num: " + num + " -> nDir: "+num_dir+" nFile: "+num_file, 0, font_y
//FOR i=0 TO BOUNDS(files$[], 0)-1 // BOUNDS(files$[], 0)-1 = num = num_dir+num_file
// PRINT files$, 50, (i+3)*font_y
//NEXT

start:
CLEARSCREEN
PRINT cur$, 0, 0
IF lin<0 THEN
lin=0
fdl1=fdl1-1

IF lin>9 THEN
lin=9
fdl1=fdl1+1

IF fdl1=0 THEN fdl1=1
IF fdl1+10>BOUNDS(files$[],0) THEN fdl1=fdl1-1
//..IF fdl1+9>blounds
DRAWLINE 60,50+font_y+(lin*font_y),60+300,50+font_y+(lin*font_y),RGB(255,255,255)
//DRAWLINE 60,50+font_y+(lin*font_y),60+300,50+font_y+(lin*font_y),RGB(0,0,0)
DRAWRECT 0,50,50,50,RGB(0,255,0)
DRAWRECT 0,300,50,50,RGB(0,255,0)
DRAWLINE 0,100,25,50,RGB(0,0,0)
DRAWLINE 25,50,50,100,RGB(0,0,0)
DRAWLINE 0,300,25,350,RGB(0,0,0)
DRAWLINE 25,350,50,300,RGB(0,0,0)
FOR cnt1=1 TO 10
IF files$[cnt1+fdl1-1]<>"" THEN
PRINT files$[cnt1+fdl1-1],50,50-font_y+(cnt1*font_y)
NEXT
DRAWRECT 0,400,200,100,RGB(0,0,255)

PRINT "SELECT",0,400+font_y
DRAWRECT 250,400,200,100,RGB(0,0,255)
PRINT "UP DIR",250,400+font_y
MOUSESTATE mx, my, b1, b2
IF mx>0 AND mx<51 AND my>299 AND my<351 AND b1=1 THEN lin=lin+1
IF mx>0 AND mx<51 AND my>49 AND my<101 AND b1=1 THEN lin=lin-1
IF mx>0 AND mx<51 AND my>299 AND my<351 AND b1=1 AND lin>8 THEN fdl1=fdl1+1
IF mx>0 AND mx<51 AND my>49 AND my<101 AND b1=1 AND lin<=1 THEN fdl1=fdl1-1
IF mx>0 AND mx<201 AND my>399 AND my<501 AND b1=1 AND  DOESDIREXIST(cur$+files$[fdl1+lin])=TRUE
// IF DOESDIREXIST(cur$+files$[fdl1+lin])
ok = SETCURRENTDIR(cur$+files$[fdl1+lin])
// 'cur$ = GETCURRENTDIR$()
// CLEARSCREEN
// PRINT cur$,0,0
// SHOWSCREEN
// MOUSEWAIT
change=1
ENDIF
//ENDIF
// IF mx>249 AND mx<451 AND my>399 AND my<501 AND b1=1

// ok = SETCURRENTDIR("..")
// change=1
// ENDIF

SHOWSCREEN
//MOUSEWAIT
SLEEP 100
IF change=0 THEN GOTO start
GOTO reload



MrTAToad

I suspect you have the problem when there is nothing present.  If you can't use the appropriate function in DDgui, you will need to make sure that when there is nothing to select, the program doesn't crash.

Darmakwolf

"SETCURRENTDIR("/")"

Not sure if this is the issue, I always use SETCURRENTDIR("..")

MrTAToad


Darmakwolf

This is just nitpicking, but I used to code the same way back in the Visual Basic days. "lin=lin+1" can be inc(lin) to save space and confusion. all this "mx>0 AND mx<51 AND my>299 AND my<351 AND b1=1..." stuff can be replaced with BOXCOLL... just stuff like that. To further assist you, turn on debug mode and see what error it throws when it crashes. It's likely an array out of bounds.