Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sequential Search - FPW 2.6 -> VFP 5.0
Message
De
06/06/1997 12:10:46
 
 
À
06/06/1997 11:49:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00035412
Message ID:
00035424
Vues:
33
>>>I have a sequential search routine that worked very well for me in my FPW 2.6 applications. I recently started using VFP 5.0 and would like to convert the code for use in my VFP development. I've been trying to do this but have been unsuccessful. Below is the code:
>>>
>>>I place this in the WHEN procedure of the text box property:
>>>
>>>FDValue="txtValue" && Text Box Value
>>>DBValue="name" && Table Search Field ID
>>>SELECT &TBValue && Select Table
>>>ThisForm.seqsearch(FDValue,DBValue) && Call Form Procedure
>>>SET ORDER TO && Reset Order Value
>>>ThisForm.Refresh && Refresh Form
>>>
>>>I place this in a self defined procedure called "seqsearch" in the form property:
>>>
>>>*************************
>>>* SEQSEARCH - Sequential Search
>>>* I modified this code from a program called "FastFind.prg".
>>>* I'm not sure who the author is, it's been so long I forget.
>>>*
>>>* As values are typed in the FDValue (txtValue) a large table
>>>* is searched on the indexed field and the first record matching
>>>* the string is echoed to a wait window. When the desired match
>>>* is found a RETURN will place the value into the txtValue Field.
>>>*************************
>>>LPARAMETERS FDValue, DBValue
>>>
>>>SET ORDER TO TAG &DBValue && Index must be uppercase
>>>
>>>WAIT WINDOW "Entering SEQSEARCH for "+UPPER(FDValue) NOWAIT
>>>
>>>IF NOT EMPTY(&FDValue)
>>> SEEK UPPER(&FDValue)
>>> ThisForm.Refresh
>>> WAIT WINDOW TRIM(&FDValue) NOWAIT
>>> SKValue=&FDValue
>>>ELSE
>>> SKValue=''
>>>ENDIF
>>>
>>>DO WHILE .T.
>>> skey = INKEY(0,"M")
>>> DO CASE
>>> CASE skey = 13 or skey=27 or skey=151 && RETURN/ESC/MOUSE Key
>>> IF skey=27 or EMPTY(SKValue)
>>> WAIT WINDOW &SKValue
>>> &FDValue=''
>>> SKValue='*** ACTION ABORTED ***'
>>> ELSE
>>> &FDValue=TRIM(&DBValue)
>>> ENDIF
>>> ThisForm.Refresh
>>> EXIT
>>> CASE skey=24 or skey=3 && DOWNARROW/PGDN Key pressed
>>> SKIP 1
>>> IF EOF()
>>> GO BOTTOM
>>> ENDIF
>>> &FDValue=UPPER(&DBValue)
>>> SKValue=TRIM(&DBValue)
>>> ThisForm.Refresh
>>> CASE skey=5 or skey=18 && UPARROW/PGUP Key pressed
>>> SKIP -1
>>> IF BOF()
>>> GO TOP
>>> ENDIF
>>> &FDValue=UPPER(&DBValue)
>>> SKValue=TRIM(&DBValue)
>>> ThisForm.Refresh
>>> CASE skey=6 && END Key pressed
>>> GO BOTTOM
>>> &FDValue=UPPER(&DBValue)
>>> SKValue=TRIM(&DBValue)
>>> ThisForm.Refresh
>>> CASE skey=1 && HOME Key
>>> GO TOP
>>> &FDValue=''
>>> SKValue=''
>>> ThisForm.Refresh
>>> CASE skey=127 && BACKSPACE Key pressed
>>> SKValue = SUBSTR(SKValue,1,LEN(SKValue)-1)
>>> WAIT WINDOW UPPER(SKValue) NOWAIT
>>> SET NEAR ON
>>> SEEK UPPER(SKValue)
>>> SET NEAR OFF
>>> &FDValue=UPPER(SKValue)
>>> ThisForm.Refresh
>>> CASE skey >= 48 AND skey <= 58 OR;
>>> skey >= 65 AND skey <= 90 OR;
>>> skey >= 97 AND skey <= 122 OR;
>>> skey = 32 OR skey = 44 OR skey = 46 && 0-9, A-Z, a-z, or Spacebar
>>> SKValue = SKValue+CHR(skey)
>>> WAIT WINDOW UPPER(SKValue) NOWAIT
>>> SET NEAR ON
>>> SEEK UPPER(SKValue)
>>> SET NEAR OFF
>>> &FDValue=UPPER(SKValue)
>>> ThisForm.Refresh
>>> OTHERWISE && Do nothing, no character to process
>>> ENDCASE
>>> WAIT WINDOW TRIM(&DBValue) NOWAIT
>>>ENDDO
>>>
>>>* End Procedure
>>>
>>>Any refinements or help that can be offered would be greatly appreciated.
>>>
>>>TIA
>>>
>>>/chris
>>>close1@rtto.psu.edu
>
>Firstly, excuse me for previous empty reply (wrong click: Friday). Could you briefly describe what is the purpose of this routine. If you want to type something in a textbox and perform search after each character entry you don't need in this bulky 2.6 construction. Use InteractiveChange event.


I'm very new to OOP programming, most of my programming background is procedural. I'm not familiar with what the InteractiveChange event offers me. I have a couple of reference tables that have several thousand records (and growing). I need a quick way for users to identify a record. i.e.: My system holds all the proposals submitted to private, federal, and state agencies. We need to keep a record of every proposal that has been submitted. One agency could have about 50 proposals or more sent to them within a year. In my old FPW system it was easy for my users to lookup the agencies, using the above procedure, by just typing in the name (National Science Foundation or NSF), when they saw the agency name in the wait window a return would record the agency ID code (transparent to them). The routine worked very well and was extremely fast and I didn't have to worry about invalid agency names.

I hope this explanation is clear. Thanks for responding.

/chris
close1@rtto.psu.edu
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform