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 use expr {!$boolean_p}

Parameters:
value (required)
input value
Returns:
matched value or default

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_decode ad_decode (test acs-tcl) ad_decode ad_decode test_ad_decode->ad_decode test_datamodel__named_constraints datamodel__named_constraints (test acs-tcl) test_datamodel__named_constraints->ad_decode Class ::xowiki::includelet::book Class ::xowiki::includelet::book (public) Class ::xowiki::includelet::book->ad_decode Class ::xowiki::includelet::toc Class ::xowiki::includelet::toc (public) Class ::xowiki::includelet::toc->ad_decode acs_admin::posture_status acs_admin::posture_status (private) acs_admin::posture_status->ad_decode bm_delete_permission_p bm_delete_permission_p (public) bm_delete_permission_p->ad_decode bm_user_can_write_in_some_folder_p bm_user_can_write_in_some_folder_p (public) bm_user_can_write_in_some_folder_p->ad_decode

Testcases:
ad_decode, datamodel__named_constraints
[ show source ]
Show another procedure: