Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select text based on a number
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00948140
Message ID:
00948175
Views:
16
>Is there a command that will allow you to select text based on a number?
>Say you have a number value 1, 2, or 3 and you want to return the text "This is one" if the number value is 1, and "This is two" if the number value is 2, etc. Is there a command that can do this type of thing, I would guess it would look something like this...
>m.StringVariable = ???(m.NumberVariable,'One','Two','Three')
>so m.StringVariable = 'One' if the m.NumberVariable = 1
>I can do this with multiple IIF(), but if there is a easier way I'd sure like to know.
>
>Thanks!!
>Colombo.

Jim,
Taka a look in Download section. There are classes with that change the numbers to words,
Donwload #9217, Download #9181 or Download #9852 (Spanish)

But If the text is based only on digits it is easier to declare an array with 10 elements starting with zero
DIMENSION digitNames[10]
digitNames[ 1] = "Zero"
digitNames[ 2] = "One"
digitNames[ 3] = "Two"
....
digitNames[10] = "Nine"


m.StringVariable = digitNames[m.NumberVariable+1]
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform