Is it possible to use ui_get_file() to filter out file types? I do NOT want to include .dbf files. I could just filter by PDF|TXT|DOC, - but I'm afraid I'd leave a file type out.
Thanks ~ Tom
Thanks ~ Tom
Alpha Software Mobile Development Tools: Alpha Anywhere | Alpha TransForm | ![]() ![]() ![]() ![]() |
FUNCTION getaFile AS C ( ) DIM SHARED response as c DIM SHARED varC_result as C texttospeech("Choose a file.") ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Choose a file.",<<%dlg% {region} What file?:| [%p=ui_get_file("","Text(*.txt)|SpreadSheet(*.xls)|FudgeSheet(*.xlsx)|BingySheet(*.slk)",response,"X");I=$a5_smart_file%.40response]; {endregion}; {line=1,0}; {region} <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL> {endregion}; %dlg%) '''debug(1) select case varC_result = "OK" .and. len(alltrim(remspecial(response)))>0 getaFile=response case varC_result = "OK" .and. len(alltrim(remspecial(response)))=0 getaFile = "No File Selected" case else getaFile = "Aborted" end select END FUNCTION
dim vfldr as C="E:\URSA"+chr(92) ' <<<< change this to your folder address dim vLexclude as C=comma_to_crlf(".alb,.alm,.alx,.dbf,.ddd,.cdx,.abd,.ddm,.ddx,.fpt,.sem,.set,.sex") dim vprobe as C=vfldr+"*.*" dim vname_now as C="" dim vext_now as C dim vLext_name_a as C dim vLname_ext_a as C dim vLext_name_d as C dim vLname_ext_d as C dim vLfiles_show as C dim vn_sort_code as N=1 dim vn_chr46 as N vfiles=filefind.get(vprobe,FILE_FIND_NOT_DIRECTORY) for each foo in vfiles vext_now=alltrim(file.filename_parse(foo,"E")) vname_now=alltrim(file.filename_parse(foo,"N")) if is_one_of(vext_now,vLexclude)=.f. vLext_name_a=vLext_name_a+vext_now+space(17-len(vext_now))+vname_now+crlf() vLname_ext_a=vLname_ext_a+vname_now+space(33-len(vname_now))+vext_now+crlf() end if next vLext_name_a=sortsubstr(vLext_name_a,crlf(),"A") vLext_name_d=sortsubstr(vLext_name_a,crlf(),"D") vLname_ext_a=sortsubstr(vLname_ext_a,crlf(),"A") vLname_ext_d=sortsubstr(vLname_ext_a,crlf(),"D") vLfiles_show=vLext_name_a 'SHOW DIALOG 'DIALOG STRUCTURE dim dlg_title as C dlg_title = "FILES" dim dlg_body as C dim dlg_code as C dim vR as C 'dialog field variables 'build dialog dlg_body = <<%dlg% {startup=init}{xmargin=3,3}{ymargin=1,1} {region1}{background=#210,190,210}{frame=1,1}{sp=63}<%T=File Open;B=T;I=$$file.open%4,1!file_open>{sp=3}<%T=Sort;B=T;I=$$sort%4,1!sort> {sp=3}<%T=Delete;B=T;I=$$edit.delete%4,1!delete>{sp=3}<%T=Close;B=T;I=$$generic.exit%4,1!exit>{text=2}; {endregion1};{background=#243,233,119} {region2}{font=arial,8,bi}{frame=1,1: Frame2 }{font=Arial,10}{background=#243,233,119} {sp=3}{font=courier new,10,b}[.90,31vfile_pick^#vLfiles_show!evfk_*]{text=3}; {endregion};{lf}; %dlg% dlg_code=<<%code% 'INIT IF a_dlg_button="init" sys_send_keys("{HOME}") a_dlg_button="" END IF 'FILE PICK IF left(a_dlg_button,5)="evfk_" if a_dlg_button="evfk_change" if vn_sort_code=1 .or. vn_sort_code=2 vext_now=alltrim(substr(vfile_pick,1,16)) vname_now=alltrim(substr(vfile_pick,17,50)) else vn_chr46=occurs(chr(46),vfile_pick) vname_now=alltrim(word(vfile_pick,1,chr(46),vn_chr46)) vext_now=chr(46)+alltrim(word(vfile_pick,vn_chr46+1,chr(46))) end if end if a_dlg_button="" END IF 'FILE OPEN IF a_dlg_button="file_open" sys_open(vfldr+vname_now+vext_now) a_dlg_button="" END IF 'SORT IF a_dlg_button= "sort" dim vpstyle as C=comma_to_crlf("menu.v_item_min_leftx=0,color.menu_v_background=#250+240+152,color.menu_v_left=#200+85+85,color.menu_v_right=white,font.menu=Arial,10,b,color.font=menu_v_font") dim vpur as C dim vLway as C=comma_to_crlf("File Type Ascending,File Type Descending,Filename Ascending,Filename Descending") vpur=ui_popup_styled_menu(vLway,vpstyle) if vpur="File Type Ascending" vLfiles_show=vLext_name_a vn_sort_code=1 else if vpur="File Type Descending" vLfiles_show=vLext_name_d vn_sort_code=2 else if vpur="Filename Ascending" vLfiles_show=vLname_ext_a vn_sort_code=3 else if vpur="Filename Descending" vLfiles_show=vLname_ext_d vn_sort_code=4 end if ui_modeless_dlg_refresh("Files") a_dlg_button="" END IF 'DELETE IF a_dlg_button="DELETE" if vfile_pick="" msgbox("A FILE SELECTION IS REQUIRED") GOTO ENDDELETE end if vconf=ui_msg_box("CONFIRM","Delete "+vname_now+vext_now+" now?",33) if vconf=1 if file.exists(vfldr+vname_now+vext_now) file.remove(vfldr+vname_now+vext_now) if vn_sort_code=1 vLext_name_a=word_subtract(vLext_name_a,vfile_pick,crlf()) else if vn_sort_code=2 vLext_name_d=word_subtract(vLext_name_d,vfile_pick,crlf()) else if vn_sort_code=3 vLname_ext_d=word_subtract(vLname_ext_a,vfile_pick,crlf()) else if vn_sort_code=4 vLname_ext_d=word_subtract(vLname_ext_d,vfile_pick,crlf()) end if vLfiles_show=word_subtract(vLfiles_show,vfile_pick,crlf()) else msgbox("The file "+vname_now+vext_now+" does not exists") end if end if ENDDELETE: a_dlg_button="" END IF 'EXIT if a_dlg_button="exit" ui_modeless_dlg_close(dlg_title) end if %code% 'GENERATE DIALOG vR=ui_dlg_box(dlg_title,dlg_body,dlg_code) if vR="Cancel" vproceed="no" end end if
Comment