Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reduce code article
Message
De
28/04/2006 17:10:44
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
28/04/2006 16:15:49
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01117574
Message ID:
01117685
Vues:
24
>>Hi Hilmar
>>
>>I finally skimmed through all the UT mags. The neatest trick of all was your ordering records bit.
>>
>>SELECT ..., at(Code, "QWER") as OrderField
>
>Yes, I found that impressive, too, that's why I included it. (I certainly hope I didn't give the impression that I had invented it, which I didn't - I read it in some UT message.)
>
>>That can be expanded to handle multi-string codes too. Assuming code is 5 chars with no spaces...
>>
>>select INT(AT("," + code + ",",",ABCDE,12345,FGHIJ,67890,") / 5 + 1) + 1 as OrderField
>>
>>I believe a UDF could be made for this, making it easier to use it in several similar queries. I would not make it very general purpose as it would add significant overhead with parameter checking etc.
>>
>>Something like this...
>>
>>UDFCodeOrder.PRG
>>RETURN INT(AT("," + code + ",",",PEARS,12345,APPLE,ORANG,") / 5 + 1) + 1
>>
>>With the query being
>>
>>select UDFCodeOrder() as OrderField
>>
>>Agreed?
>
>Well, yes, that seems the correct way of doing this. In the case of a UDF, a decision must be made about using greater simplicity (UDF) and greater speed (no UDF - type the expression directly).

Mentioning UDF versus directly typing the formula reminded me. There's a third option: http://msvfp.advisorguide.com/doc/17440
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform