From 414856a5e28882c71f0b78af019a4776cf435f68 Mon Sep 17 00:00:00 2001 From: halw Date: Wed, 21 Apr 2010 13:43:34 +0000 Subject: [PATCH] Added safer version in Notes. Author:halw Date:2010-04-21T13:43:34.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@566 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../examples/example-command-line-arguments.wiki | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/documentation/current/examples/example-command-line-arguments.wiki b/documentation/current/examples/example-command-line-arguments.wiki index 8788c5d0..d937dbc3 100644 --- a/documentation/current/examples/example-command-line-arguments.wiki +++ b/documentation/current/examples/example-command-line-arguments.wiki @@ -14,6 +14,19 @@ myprogram -c "alpha beta" -h "gamma" This class inherits functionality for dealing with command line arguments from class ARGUMENTS. It uses the feature separate_character_option_value to return the values by option name for each of the two arguments. ARGUMENTS provides a rich set of features for command line argument processing. +The simple version in [[#Solution|Solution]] below is as submitted to Rosetta Code to illustrate class ARGUMENTS, but it should be noted that separate_character_option_value is of a detached type and will return a void reference if no value is found for a specified character option. Therefore, a safer version of the use of separate_character_option_value would include object test on the result: + + + if attached separate_character_option_value ('c') as l_val then + print ("Command line argument value for option 'c' is: ") + print (l_val + "%N") + end + if attached separate_character_option_value ('h') as l_val then + print ("Command line argument value for option 'h' is: ") + print (l_val + "%N") + end + + ==Source== Problem description from [http://rosettacode.org/wiki/Command-line_arguments Rosetta Code]