Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To iif or not to iif = .t.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00513276
Message ID:
00513583
Views:
13
Nick,

Which why complex code should be coded as a simple call to a method, that can use whatever language constructs it needs to make the code maintainable. I had a grid that needed the backcolor or a column to be one of several colors to match the multipart color coded ticket. The BackColor property was just set to:

thisform.StageColor( recno( "stackstages" ) )

and the method looked like:
* this method provides the colored cells for the grdStages
* they match the colors of the pages from the stack ticket

lparameter pnRecno

do case
   case ( pnRecno = 1 )            && Yard
      return rgb( 255, 255, 255 )
   case ( pnRecno = 2 )            && Pre Dryer
      return rgb( 255, 255, 0 )
   case ( pnRecno = 3 )            && Kiln
      return rgb( 255, 128, 255 )
   case ( pnRecno = 4 )            && Cooling Shed
      return rgb( 255, 128, 0 )
   case ( pnRecno = 5 )            && Plant
      return rgb( 255, 255, 164 )
   otherwise
      return rgb( 192, 192, 192 )
endcase
That's far better solution than 6 nested IIF()s.

>For example, considering GridHighlighter features, you might imagine the complexity of the final IIF which is stored to Dynamic... properties. You (me :)just cannot work with the expression of that kind in one line.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform