VFP 9 and ICASE

VFP 9 has a new useful function (especially for reports) named ICASE.
This helps where you had to do IIF(...(IIF...(IF now you can do it
using ICASE in a simpler way

Example (you can run it from command prompt):
Before:

FOR ln_count = 1 TO 4
DO CASE
CASE ln_count = 1
gc_cstmeth = "A"
CASE ln_count = 2
gc_cstmeth = "F"
CASE ln_count = 3
gc_cstmeth = "C"
CASE ln_count = 4
gc_cstmeth = " "
ENDCASE

? IIF(gc_cstmeth = "A", "Average", IIF(gc_cstmeth = "F", "FIFO",
IIF(gc_cstmeth = "L", "LIFO", "Not entered")))
NEXT

Now, using ICase
FOR ln_count = 1 TO 4
DO CASE
CASE ln_count = 1
gc_cstmeth = "A"
CASE ln_count = 2
gc_cstmeth = "F"
CASE ln_count = 3
gc_cstmeth = "C"
CASE ln_count = 4
gc_cstmeth = " "
ENDCASE

? ICASE(gc_cstmeth = "A", "Average", gc_cstmeth = "F", "FIFO",
gc_cstmeth = "L", "LIFO", "Not Entered")
NEXT

No comments: