| 
	
		| Subject | Re: ?array |  
		| From | Mervyn Bick <invalid@invalid.invald> |  
		| Date | Tue, 13 Nov 2018 14:07:30 +0200 |  
		| Newsgroups | dbase.getting-started |  
| Attachment(s) | select_file.wfm, list_files.wfm |  | On 2018-11-12 11:10 PM, Charlie wrote:
 > I think this is going to require an array which I have little experience with.  I may be wrong, so if it is possible to do this without an array, please let me know.
 >
 > I am trying to find what tables are located on a flash drive directory.  (Not associated with a database.)   I would like to identify them and display the content of the directory so one or all can be chosen to import.
 >
 > What would be the best way to display them and  how that might work.
 >
 > Thanks for any help.....
 >
 
 As with most things in dBASE there is more than one way to tackle this.
 
 For "quick and dirty" you could use the dBASE function getfile(). See
 the attached select_file.wfm.
 
 A more elegant way is to use some routines from the dUFLP.  See
 list_files.wfm.   If you really want to this could be expanded to use a
 treeview instead of a plain listbox.
 
 The one draw back with list_files.wfm is that it only sees flash drives
 which are plugged in when the form opens.  If you plug another flash
 drive in while the form is open you will need to close the form and then
 reopen it.
 
 Mervyn.
 
 
 
 
 |  | ** END HEADER -- do not remove this line
 //
 // Generated on 2018-11-13
 //
 parameter bModal
 local f
 f = new select_fileForm()
 if (bModal)
 f.mdi = false // ensure not MDI
 f.readModal()
 else
 f.open()
 endif
 
 class select_fileForm of FORM
 with (this)
 height = 16.0
 left = 26.7143
 top = 5.6818
 width = 78.4286
 text = ""
 endwith
 
 this.PUSHBUTTON1 = new PUSHBUTTON(this)
 with (this.PUSHBUTTON1)
 onClick = class::PUSHBUTTON1_ONCLICK
 height = 1.0909
 left = 29.8571
 top = 5.0
 width = 15.2857
 text = "Select File"
 endwith
 
 this.ENTRYFIELD1 = new ENTRYFIELD(this)
 with (this.ENTRYFIELD1)
 height = 1.0
 left = 7.0
 top = 10.0
 width = 61.0
 value = ""
 endwith
 
 this.TEXTLABEL1 = new TEXTLABEL(this)
 with (this.TEXTLABEL1)
 height = 1.0
 left = 32.0
 top = 8.5
 width = 18.0
 text = "Selected file"
 endwith
 
 
 function PUSHBUTTON1_onClick()
 form.entryfield1.value = getfile()
 return
 
 endclass
 
 
 
 |  | ** END HEADER -- do not remove this line
 //
 // Generated on 2018-11-13
 //
 parameter bModal
 local f
 f = new list_filesForm()
 if (bModal)
 f.mdi = false // ensure not MDI
 f.readModal()
 else
 f.open()
 endif
 
 class list_filesForm of FORM
 with (this)
 onSize = class::FORM_ONSIZE
 onOpen = class::FORM_ONOPEN
 height = 22.1364
 left = 35.4286
 top = 2.5
 width = 53.1429
 text = ""
 endwith
 
 this.COMBOBOX1 = new COMBOBOX(this)
 with (this.COMBOBOX1)
 onChange = class::COMBOBOX1_ONCHANGE
 onOpen = class::COMBOBOX1_ONOPEN
 height = 1.0
 left = 5.0
 top = 2.0
 width = 31.0
 style = 1        // DropDown
 endwith
 
 this.LISTBOX1 = new LISTBOX(this)
 with (this.LISTBOX1)
 onSelChange = class::LISTBOX1_ONSELCHANGE
 height = 13.0
 left = 5.0
 top = 6.0
 width = 44.0
 id = 102
 colorHighLight = "HighLightText/HighLight"
 endwith
 
 this.TEXTLABEL1 = new TEXTLABEL(this)
 with (this.TEXTLABEL1)
 height = 1.0
 left = 5.0
 top = 0.5
 width = 18.0
 text = "Removable Drives"
 endwith
 
 this.ENTRYFIELD1 = new ENTRYFIELD(this)
 with (this.ENTRYFIELD1)
 height = 1.0
 left = 5.0
 top = 20.0
 width = 44.0
 value = ""
 endwith
 
 this.TEXTLABEL2 = new TEXTLABEL(this)
 with (this.TEXTLABEL2)
 height = 1.0
 left = 16.0
 top = 4.0
 width = 21.0
 text = "Form can be resized"
 endwith
 
 
 function COMBOBOX1_onChange()
 form.entryfield1.value = ''
 aFiles = new array()
 oFiles = new FileRecurser(substr(this.value,1,at(':',this.value) ))
 oFiles.processFile := {|d,f|; aFiles.Add(d + f)}
 oFiles.search()
 form.listbox1.datasource = 'array aFiles'
 return
 
 function COMBOBOX1_onOpen()
 this.value = 'Select drive'
 return
 
 function LISTBOX1_onSelChange()
 form.entryfield1.value = this.value
 return
 
 function form_onOpen()
 set procedure to :duflp:miscWSH.prg
 set procedure to :dUFLP:FileRecurser.cc
 set procedure to :duflp:miscapi.prg
 aDirs = new array()
 fso = new OleAutoClient("Scripting.FileSystemObject").drives
 a = new array(fso.count,2)
 for n = 0 to fso.count-1
 a[n+1,1] = fso[n].path
 a[n+1,2] = getDriveType(fso[n].driveType)
 next
 for n = 1 to a.size step 2
 if a[n+1] = 'Removable'
 cVol = getlabel(a[n])  // get volume label
 aDirs.add(a[n]+' '+cVol)
 endif
 next
 form.combobox1.dataSource = 'array aDirs'
 return
 
 function form_onSize(nSizeType, nWidth, nHeight)
 form.listbox1.width = this.width - 10
 form.listbox1.height = this.height - 10
 form.entryfield1.width = this.width - 10
 form.entryfield1.top = form.height - 2
 return
 
 endclass
 
 
 
 |  |