Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reduce code article
Message
De
28/04/2006 17:51:56
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/04/2006 12:11:28
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01117574
Message ID:
01117698
Vues:
14
>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
>
>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?

Mike,
I haven't tried it but I think creating an array and doing ascan() would be faster and neater. ie:

alines(aOrder,"ABCDE,12345,FGHIJ,67890",.t.,",")
select ascan(aOrder,code,1,-1,1,15) as OrderField...


Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform