ad_decode (public)
ad_decode value [ args... ]
Defined in packages/acs-tcl/tcl/utilities-procs.tcl
This procedure is analogous to sql decode procedure. The first parameter is the value we want to decode. This parameter is followed by a list of pairs where first element in the pair is convert from value and second element is convert to value. The last value is default value, which will be returned in the case convert from values matches the given value to be decoded. Note that in most cases native Tcl idioms such as expr or switch will do the trick. This proc CAN make sense when one has many alternatives to decode, as in such cases a switch statement would not be as compact.
Good usage:
ad_decode $value f Foo b Bar d Dan s Stan l Lemon m Melon Unknown
---> a oneliner as opposed to a long switch statement
Bad usage:
ad_decode $boolean_p t 0 1
---> just useexpr {!$boolean_p}
- Parameters:
- value (required)
- input value
- Returns:
- matched value or default
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- ad_decode, datamodel__named_constraints