Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP beats out C#, Python, others in challenge
Message
 
À
12/06/2004 08:10:53
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
ActiveVFP
Divers
Thread ID:
00912565
Message ID:
00913016
Vues:
22
Walter,
This is pretty cool. Maybe Calvin will take a look at it and comment...
>Hi claude
>
>Hmmmm, my previous entry had a bug in it. Here is a revised entry with dash seperator
>
>
>CREATE CURSOR Words (Word C(39))
>APPEND FROM text.txt CSV
>INDEX ON LOWER(Word) TAG word
>
>ALINES(aKeyCode,STRTRAN("0 1 2abc 3def 4ghi 5jkl 6mno 7pqrs 8tuv 9wxyz"," ",CHR(13)))
>
>cPhonenumber = "642-394-6369"
>cPhonenumber = STRTRAN(cPhoneNumber, "-","")
>CREATE CURSOR Results (Word C((2*LEN(cPhonenumber))))
>
>nSec = SECONDS()
>SELECT WORDS
>GetWords(cPhoneNumber,"","")
>? SECONDS() - nSec
>
>SELECT Results
>BROWSE NORM
>RETURN
>
>*-
>
>PROCEDURE GetWords (cUncoded, cCoded, cWordpart)
>LOCAL nT, cChar, cChars
>
>DO CASE
>   CASE !EMPTY(cUncoded)
>	cChars = aKeyCode[VAL(LEFT(cUncoded,1))+1]
>	FOR nT = 1 TO LEN(cChars)
>	    cChar = SUBSTR(cChars, nT, 1)
>
>	    DO CASE
>		CASE KEYMATCH(cWordPart+cChar+" ")
>		    GetWords(SUBSTR(cUnCoded,2), cCoded+IIF(EMPTY(cWordPart) AND !EMPTY(cCoded),"-","")+cChar, "")
>				
>		CASE EMPTY(cWordPart) AND nT = 1
>		    GetWords(SUBSTR(cUnCoded,2), cCoded+IIF(ISALPHA(RIGHT(cCoded,1)),"-","")+cChar, "")
>	    ENDCASE
>	    IF nT > 1 AND KEYMATCH(cWordPart+cChar) AND LEN(cUncoded) > 1
>		GetWords(SUBSTR(cUnCoded,2), cCoded+IIF(EMPTY(cWordPart) AND !EMPTY(cCoded),"-","")+cChar, cWordPart+cChar)
>	    ENDIF
>        ENDFOR
>
>   CASE EMPTY(cWordPart) OR KEYMATCH(cWordPart+" ")
>	INSERT INTO Results VALUES (cCoded)
>ENDCASE
>RETURN
>
>As you see, very compact and fast.
>
>Walter,
>
>
>>Just thought I'd pass this URL along:
>>http://www.calvinhsia.com/default.asp?Page=Phone
>>Calvin's solution was in VFP and he won (and it looks like he did it in the shortest amount of time). The demo page is setup as a VFP mtdll called from ASP. This is a great example why, IMHO, VFP has an important place on the web...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform