Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for a better way
Message
From
18/12/1999 10:01:00
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
18/12/1999 01:04:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00305584
Message ID:
00305639
Views:
29
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform