DIM my_file$(500):REM holds current files.Make this as big as you think you will need c%=0 PROClistdirectory(".bbc") REPEAT PRINT my_file$(c%) c%+=1 UNTIL my_file$(c%)="" WAIT 1000 END DEF PROClistdirectory(ext$) LOCAL dir%, sh%, res%,cou% DIM dir% LOCAL 317 SYS "FindFirstFile", "*", dir% TO sh% IF sh% <> -1 THEN REPEAT f$= $$(dir%+44) IF RIGHT$(f$,4)= ext$ THEN my_file$(cou%)=f$:cou%+=1 REM PRINT RIGHT$(f$,4):REM enable this to see the files it hides SYS "FindNextFile", sh%, dir% TO res% UNTIL res% = 0 SYS "FindClose", sh% ENDIF ENDPROC
DIM my_file$(500) : REM Make this as big as you think you will need num% = FNlistdirectory(my_file$(), "*.bbc") IF num% THEN FOR index% = 1 TO num% PRINT my_file$(index%) NEXT index% ENDIF END DEF FNlistdirectory(RETURN name$(), filter$) LOCAL F%, N%, a$ REM Spool *DIR output to a temporary file: WIDTH 20 VDU 21 ON ERROR LOCAL IF FALSE THEN OSCLI "spool """ + @tmp$ + "dir.tmp.txt""" OSCLI "dir " + filter$ ENDIF : RESTORE ERROR *spool VDU 6 WIDTH 0 REM Parse the file to extract the filenames; cope with REM long filenames if they have split between lines: name$() = "" F% = OPENIN(@tmp$ + "dir.tmp.txt") WHILE NOT EOF#F% AND N% < DIM(name$(),1) INPUT #F%,a$ IF ASC(a$)=&A a$ = MID$(a$,2) IF LEFT$(a$,2) = " " OR LEFT$(a$,2)= "* " THEN IF a$ <> STRING$(20, " ") THEN N% += 1 name$(N%) = MID$(a$,3) ENDIF ELSE name$(N%) += a$ ENDIF ENDWHILE CLOSE #F% = N%
REM CREATE a temporary array within a PROC or FN example PROCtest END DEFPROCtest LOCAL items():REM create a variable label and identify it as an array DIM items(45):REM now give it a dimension FOR x=0 TO 45 items(x)=RND(4000) NEXT x FOR x=0 TO 45:REM separating this so it shows a stored example and not realtime assigned example PRINT items(x) NEXT x ENDPROC
REM CREATE a stored array within a PROC or FN example PROCtest(0) WAIT 200 PRINT "******* WHAT? I NEED THOSE RESULTS AGAIN " PROCtest(1):REM should reprint stored info END DEFPROCtest(n%) ON ERROR LOCAL RESTORE LOCAL : ERROR ERR, REPORT$ PRIVATE items():REM create a variable label and identify it as an array DIM items(45):REM now give it a dimension IF n%=0 THEN FOR x=0 TO 45 items(x)=RND(4000) NEXT x ENDIF FOR x=0 TO 45 PRINT items(x) NEXT x ENDPROC