Macro fif

Introduction

This macro provides a functional ternary if, allowing you to embed a conditional result within a single statement. This is useful for eliminating unnecessary statements and variables, and is essential for composing complex macros.

Syntax


	fif(boolean, value1, value2) => result

where:

Discussion

The type of result depends on the types of value1 and value2, which must be compatible. For the purposes of compatibility, integer and boolean are compatible, as are a and string, and d and decimal. If both value1 and value2 are Vars, then a Var will be returned. Otherwise, if both arguments are objects, the result will be an object and will probably need to be cast in order to use it.

Naturally, you do not need to assign result to a variable -- you can use the return value of fif whereever a value of that type may be used. That's almost the whole point.