I'm trying to program an *autocomplete* (for medical terms) with an Edit Object (Memo field); its getting tricky.
Any suggestions are appreciated in advance.
Ideally, we'd be able to:
(1) Start typing in a word and it finishes the word, to *stuff* it in the paragraph.
Currently I'm using the keypress event with code like:
Do Case
Case (Between(nKeyCode, 65, 90) Or Between(nKeyCode, 97, 122) Or Between(nKeyCode, 48, 57) )
pSearchstring = pSearchstring + Chr(nKeyCode) &¬ proper for now
OTHERWISE
Release pSearchstring,pStart,pnCharactersReplaced,pNo,pOriginalValue,pReplacementName
Return
Endcase
If !Empty(pSearchstring)
lFound=Indexseek(pSearchstring,.F.,"visit","last_name")
=Indexseek(pSearchstring,lFound,"visit","last_name")
Endif
pReplacementName[pNo]=Iif(lFound,Alltrim(visit.last_name),pSearchstring) &&for now
IF lFound
lnCharsReplaced=lStart-pStart+1+Iif(pNo>1,Len(pReplacementName[pNo-1]),0) &&If pNo>=2 &&must discard the prior pReplacement, 1st
ELSE
lnCharsReplaced=lStart-pStart+1+Iif(pNo>1,Len(pReplacementName[pNo-1]),0) &&If pNo>=2 &&must discard the prior pReplacement, 1st
* return
ENDIF
NODEFAULT
This.Value=Stuff(This.Value,IIF(lfound,pStart,lStart),lnCharsReplaced,pReplacementName[pNo])
This.SelLength = IIF(lFound,Len(pReplacementName[pNo]),0) &&(this.Value)
Any suggestions are appreciated in advance.
Ideally, we'd be able to:
(1) Start typing in a word and it finishes the word, to *stuff* it in the paragraph.
Currently I'm using the keypress event with code like:
Do Case
Case (Between(nKeyCode, 65, 90) Or Between(nKeyCode, 97, 122) Or Between(nKeyCode, 48, 57) )
pSearchstring = pSearchstring + Chr(nKeyCode) &¬ proper for now
OTHERWISE
Release pSearchstring,pStart,pnCharactersReplaced,pNo,pOriginalValue,pReplacementName
Return
Endcase
If !Empty(pSearchstring)
lFound=Indexseek(pSearchstring,.F.,"visit","last_name")
=Indexseek(pSearchstring,lFound,"visit","last_name")
Endif
pReplacementName[pNo]=Iif(lFound,Alltrim(visit.last_name),pSearchstring) &&for now
IF lFound
lnCharsReplaced=lStart-pStart+1+Iif(pNo>1,Len(pReplacementName[pNo-1]),0) &&If pNo>=2 &&must discard the prior pReplacement, 1st
ELSE
lnCharsReplaced=lStart-pStart+1+Iif(pNo>1,Len(pReplacementName[pNo-1]),0) &&If pNo>=2 &&must discard the prior pReplacement, 1st
* return
ENDIF
NODEFAULT
This.Value=Stuff(This.Value,IIF(lfound,pStart,lStart),lnCharsReplaced,pReplacementName[pNo])
This.SelLength = IIF(lFound,Len(pReplacementName[pNo]),0) &&(this.Value)