` Auto-complete a field (Jim Gambon ) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Par2: Auto-complete a field
1999-03-23 -- Jim Gambon
 
Try this out: 1) You will need a local variable called "FieldPosition" to store where you are in the entry field. 2) Make sure the "Immediate" attribute is switched on for the entry field. This is so your program receives a "NewSelection" message for every keystroke. 3) Here's the tricky part (and cries out for a template I have not had the chance/time to write): Note: In this example I have used an Entry field named "Glo:LoginName", a Database file named "Users", a UserName Key named "USE:KeyUserName", and a UserName field in the database named "USE:UserName". You should be able to change this code for your own use. In the NewSelection Event handler for the Field Control ! Test for Valid Data Entry Keys Only. IF (KEYCODE() >= AKey AND KEYCODE() <= SlashKey) | OR (KEYCODE() >= Shift0 AND KEYCODE() <= ShiftZ) ! Get the data from the Screen UPDATE(?Glo:LoginName) ! Find out where we are in the Field FieldPosition = ?glo:LoginName{PROP:SelStart} ! If The Field is not blank IF LEN(glo:LoginName) > 0 ! Clear the Key and Lookup the User ! If a User is Found in the database, ! and it matches the data Entry, ! Fill the field with the new data. ACCESS:Users.ClearKey(USE:KeyUserName) USE:UserName = UPPER(glo:LoginName) SET(USE:KeyUserName,USE:KeyUserName) IF ACCESS:Users.Next() = Level:Benign IF CLIP(UPPER(glo:LoginName)) = UPPER(USE:UserName[1 : LEN(CLIP(glo:LoginName))]) glo:LoginName = USE:UserName DISPLAY(?Glo:LoginName) ! Next: select the entry field, but ! position the highlights to the part of the ! Field that we "guessed" at. SELECT(?glo:LoginName,FieldPosition, | FieldPosition+LEN(CLIPUse:UserName))) END !IF END !IF END !IF END !IF I hope this helps out. I hope I haven't forgotten anything in the code.


Today is November 21, 2024, 8:22 am
This article has been viewed 35198 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: