Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looking for a better way
Message
De
18/12/1999 10:01:00
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
18/12/1999 01:04:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00305584
Message ID:
00305639
Vues:
28
>If these are the only codes you have, you can write a small CarCodeToCarName function and call it in your SQL statement:
>
>Select CarCodeToCarName(MyTable.CarCode) from MyTable into etc...
>
>
function CarCodeToCarName
>lparameter tcCarCode
>local lcCarName
>do case
>case tcCarCode = 1
>   lcCarName = "Ford"
>case tcChevy
>   lcCarName = "Chevy"
>case etc
>otherwise
>   lcCarName = "Unknown"
>endcase
>*-- padr is necessary because the size of the field
>*   will be set by VFP based on the first record
>*   and we want it to be large enough to hold any value.
>return padr(lcCarName, 20)
>
>

>Anyway, having a table for car types is probably a better solution :)

...Or an array (which may still get populated from such a table). Many times in FPD2.6 I've used an array and a function which returned its nth element, like
 Lparam aArray, nRow
if betw(nRow, 1, alen(aArray))
   return(aArray[nRow])
else
   return '???'
endif
In real life this also head some checking to see whether the array has one or two dimensions. Still, I didn't include the function in the SQL select, but rather included it in a report field, because of the speed and width issues.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform