Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing the results returned by the _filer class.
Message
 
 
À
29/07/2002 13:30:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00683615
Message ID:
00683626
Vues:
36
Hope this program can help. Note, that Filer is not distributable:
********************************************************************
*  Description.......: FindFileInNetwork - searches for a file in a Network
*  Calling Samples...: FindFileInNetwork("pdfmon.dll","c:\")
*  Parameter List....: tcFileToSearch, tcSearchPath, tlEntireNetwork
*  Created by........: Houston Brennan 06/13/2000
*  Modified by.......: Nadya Nosonovsky 06/16/2000 11:30:52 AM (with assistance of BP and JH)
********************************************************************
lparameters tcFileToSearch, tcSearchPath, tlEntireNetwork
** Check passed parameters
if vartype(m.tcFileToSearch)<>'C' or empty(m.tcFileToSearch)
	return .f. && First parameter is required
endif
#define NoAttributesSet       0
#define readonly              1
#define hidden                2
#define system                4
#define Archived              32
#define DoNotSearchSubFolder  0
#define SearchSubFolder       1

local lcRetPath, lcDrive, lcSearchPath, lnStartTime,;
	lcPrevOnEsc, lcPrevEscape, MsgTail, halt, loFiler

lcRetPath=''
* note clock reading for generating final timing statistics
lnStartTime = seconds()					&& # seconds since midnight

* support user Escapes for interrupting the loop
lcPrevOnEsc = on('escape')				&& save previous Escape handler
lcPrevEscape = set('escape')			&& previous Escape enablement state
set escape on							&& enable escape handling
halt = .f.								&& allow loop to run until this flag is toggled
on escape halt = .t.					&& force immediate termination if user escapes

* assemble fixed portion of status bar message outside of loop, for speed
MsgTail = "...         Wait or press Esc to cancel ..."

wait window nowait 'Searching file '+m.tcFileToSearch+iif(m.tlEntireNetwork,' in the whole network...',' ...')
loFiler = createobject( "Filer.FileUtil" )
loFiler.FileExpression = m.tcFileToSearch
loFiler.SubFolder = SearchSubFolder && Search all tree

if vartype(m.tcSearchPath)<>'C' or (empty(m.tcSearchPath) and !m.tlEntireNetwork)
	lcSearchPath='c:\' && Local drive
else
	lcSearchPath=m.tcSearchPath
endif
if !tlEntireNetwork && Only specified path to search
	loFiler.SearchPath = m.lcSearchPath
	set message to 'Searching in '+m.lcSearchPath + m.MsgTail
	loFiler.find(0) && Perform search
	if m.halt or lastkey()=27 && Escape was pressed
		exit
	endif
	if loFiler.files.count>0 && At least one file was found, pick up the first
		lcRetPath=loFiler.files.item[1].path
	endif
else
	local lni, lcDrive
** Want to search in the whole network
	for lni = 67 to 90
		lcDrive = chr(m.lni)
		if inlist(drivetype(m.lcDrive),3,4)
* Make sure the drive is ready (type 4 is either removeable or a network drive)
			set message to 'Searching drive '+m.lcDrive+m.MsgTail
			loFiler.SearchPath = m.lcDrive+':\'
			loFiler.find(0) && Perform search
			if m.halt or lastkey()=27 && Escape was pressed
				exit
			endif
			if loFiler.files.count>0 && At least one file was found, pick up the first
				lcRetPath=loFiler.files.item[1].path
				exit
			endif
		endif
	endfor
endif
* Restore settings
if m.lcPrevEscape='OFF'
	set escape off
endif
on escape &lcPrevOnEsc
set message to ' '
wait clear
=messagebox("File "+iif(!empty(m.lcRetPath),m.lcRetPath+m.tcFileToSearch,"not")+" found in "+ ;
           alltrim(str(seconds()-m.lnStartTime,10,3))+" sec.")
return m.lcRetPath && Path to the first found file
>Category: File Utilities
>Default Catalog: Visual FoxPro Catalog\Foundation Classes\Utilities
>Class: _filer
>Base Class: Custom
>Class Library: _utility.vcx
>Parent Class: _custom
>
>Find method
>Searches for files that meet the criteria specified by the properties.
>Syntax: Find( )
>Return: none
>Arguments: none
>
>oFiles property
>Specifies a collection of files returned by the Find search.
>Default: .F.
>
>I am trying to use the _filer foundation class to do an external search for files with certain textual expressions in them. I have added it to my form and have executed it with thisform._filer1.find. However, I can't figure out how to get the results back into a VFP array or file . The documentation says the results should be in thisform._filer1.ofiles.
>
>I am looking for the snippet of code that that I can attach to a command button that executes the search command and accepts the results back into either an array or a file.
>
>Yes, this is my first time here so excuse my ignorance!.. :-)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform