I've more or less rebuilt the whole shebang, it now outputs a string rather than directly writing to a file. This way it's less hardwired, e.g. you can just view this list now, without having to load it back. Also, all the globals are gone. Globals = evil.
The Showtext function is not mandatory, it's just a small self-contained textviewer..
usage: Showtext text$,width,height
when omitted, width and height default to 640,480
when either width or height <1 then the viewer is full-screen.
'ave fun
*update*
Flags added for certain layout thingies.
The Showtext function is not mandatory, it's just a small self-contained textviewer..
usage: Showtext text$,width,height
when omitted, width and height default to 640,480
when either width or height <1 then the viewer is full-screen.
Showtext ListDir$("i:") ; mystring$=ListDir$("c:") End Function ListDir$(dir$) csd=ReadDir(dir$) If Not csd Return Repeat file$=NextFile$(csd) If file$="" Exit If FileType(dir$+file$)=1 out$=out$+dir$+file$+Chr$(13)+Chr$(10) EndIf If FileType(dir$+file$)=2 And file$<>".." And file$<>"." out$=out$+ListDir$(dir$+file$+"") EndIf Forever Return out$ End Function Function Showtext(t$,w=640,h=480) cw=ClientWidth(Desktop()) ch=ClientHeight(Desktop()) If w<1 Or h<1 w=cw:h=ch EndIf If w>cw w=cw If h>ch h=ch window=CreateWindow("Show text",cw/2-w/2,ch/2-h/2,w,h,0,3) textarea=CreateTextArea(0,0,ClientWidth(window),ClientHeight(window),window) SetTextAreaColor textarea,128,192,255 SetTextAreaColor textarea,0,32,64,1 SetTextAreaText textarea,t$ Repeat WaitEvent() If EventSource()=window If EventID()=$803 Exit If EventID()=$802 SetGadgetShape textarea,0,0,ClientWidth(window),ClientHeight(window) EndIf EndIf Forever FreeGadget window End Function
'ave fun
*update*
Flags added for certain layout thingies.
Function ListDir$(dir$,flags=1+4+8+16,d=0) ; flags: ; ; +1 show dir path+name ; +2 show path in filename ; +4 recursive indent ; +8 [] around dirs ; +16 <> around files csd=ReadDir(dir$) If Not csd Return "error" Repeat file$=NextFile$(csd) If file$="" Exit ; recursive indenting: recindent$="" If (flags Shr 2) And 1 recindent$=String$(" ",d*4) ; normal file? If FileType(dir$+file$)=1 out$=out$+recindent$+indent$ If (flags Shr 4) And 1 out$=out$+"<" If (flags Shr 1) And 1 out$=out$+dir$ ; show full path? out$=out$+file$ If (flags Shr 4) And 1 out$=out$+">" out$=out$+Chr$(13)+Chr$(10) EndIf ; dir? If FileType(dir$+file$)=2 And file$<>".." And file$<>"." If (flags Shr 0) And 1 ; show dir path+name? out$=out$+recindent$ If (flags Shr 3) And 1 out$=out$+"[" out$=out$+dir$+file$ If (flags Shr 3) And 1 out$=out$+"]" out$=out$+Chr$(13)+Chr$(10) EndIf out$=out$+ListDir$(dir$+file$+"",flags,d+1) EndIf Forever Return out$ End Function