!standard A.17(4/2) 12-01-27 AI05-0285-1/01 !standard A.17(11/2) !class Amendment 12-01-27 !status Amendment 2012 12-01-27 !status work item 12-01-27 !status received 11-10-01 !priority Low !difficulty Easy !subject Defaulted environment variable queries !summary An additional form of the Value routine is added to Ada.Environment_Variables. !proposal A common usage is that one wants to determine the value of an environment variable, if the variable exists, but then assume a default value if the variable does not exist. The current package Environment_Variables requires two steps for this functionality (test whether the variable exists, then get the value if it does not). !wording Add after A.17(4/2): function Value (Name : in String; Default : in String) return String; Add after A.17(11/2): function Value (Name : in String; Default : in String) return String; If the external execution environment supports environment variables, then Value returns the value of the environment variable with the given name. If no environment variable with the given name exists, then Default is returned. If the execution environment does not support environment variables, then Program_Error is propagated. !discussion !corrigendum A.17(4/2) @dinsa @xcode< @b Value (Name : @b String) @b String;> @dinst @xcode< @b Value (Name : @b String; Default : @b String) @b String;> !corrigendum A.17(11/2) @dinsa @xindent @dinss @xcode<@b Value (Name : @b String; Default : @b String) @b String;> @xindent !ACATS Test Create an ACATS C-Test to test this subprogram. !ASIS No change needed. !appendix !topic Defaulted Environment Variable Lookups !reference Ada 2005 A.17 (4/2) !from /Brad Moore 11-10-01/ !keywords Environment Variable Lookup Default !discussion Ada.Environment_Variables provides the call; function Value (Name : in String) return String; To retrieve the value of an environment variable. A common usage however is that one wants to determine the value of an environment variable, if the variable exists, but then assume a default if the variable does not exist. It would be useful to have the subprogram; function Value (Name : in String; Default : in String) return String; If the Name exists, then that value is returned, otherwise the Default is returned. It is annoying to have to either make extra calls to test for the existence of the variable before calling Value, or wrapping this call in another user defined call that provides the desired behavior. **************************************************************** From: Jeff Cousins Sent: Tuesday, October 4, 2011 6:07 AM We would strongly agree with this one. In most if not all cases our default would simply be a null string, but it seems a good idea to generalise it. ****************************************************************