In the second method we will look at a way to define a variable that allows someone to pick from a list of values or allows them to enter any value.

Part A (restricting the values that a variable can take using an enum)

The following configuration is what we want to end up with. We will look at what it contains line by line and then look at how the variable can be used:

enum _my_location_codes

_my_location_codes = { "Not Valid", "AAA000", "AAA001", "AAA002", "AAA003" } init _my_location_codes = "Not Valid"

_my_location_codes visible_if TRUE

_my_location_codes help_text "Choose a location code”

The first line defines the variable _my_location_codes to be an enum. That means that it can only hold a value from the enumerated values assigned to it. It is not possible to set this variable to any other value.

The second line assigns a list of values to the variable. A variable doesn’t have to be an enum to give it a list of potential values like this, more on that in the next part of this example.

The third line gives the variable an initial value. Since this variable is an enum it should only be assigned a value from the list of allowed values. Note the use of init before the variable - the init keyword is only required if you want the user to be allowed to change this value via the additional button on the basic tab in itool. Without the init keyword the user would not be allowed to change the value.

The last line sets the variable so it can be seen via the additional button on the basic tab in itool. If you did not want to allow the user to see this variable you must use FALSE instead of TRUE.

You should be aware that enums behave differently than other variables on the additional button on the basic tab in itool. You cannot directly enter a value into an enum field, instead press Enter where the help text is. When you do this you will be presented a list of values to choose from. That is how to change the value for an enum.

The end result of this is to present to the user a field that they can change but can only select one of a predefined set of values. The question you may be asking is why you would do this. In this case the value of the _my_location_codes variable could control networking information. If there were one location code for each subnet you have HP-UX systems on, you could choose the appropriate location code to supply information such as routing and other networking information common to that subnet. This would require additional configurations that tested the value of _my_location_codes and set up networking information accordingly.

You may have noticed that _my_location_codes contained “Not Valid” as one of its possible values. There is a good reason for this - in this case we want to force the person doing the installation to set this value. If there is an initial value that you know is not valid, you can create some configuration like:

( _my_location_codes == "Not Valid" ) { error+="You have not selected a location code."

} else {

note+="The location code selected was " + ${_my_location_codes}

141