Chapter 6 Solutions to Module 6 Variables and Expressions
Lesson 1 Understanding Variables
Q 6-1 The following are acceptable names for variables:
------------------------------------------------------------------------------------------
| |
| Variable Name |
| |
------------------------------------------------------------------------------------------
| |
| b. CIERROR |
| |
| c. FRED_FLINTSTONE |
| |
| d. HPINPRI |
| |
| f. _JAMES_BOND |
| |
------------------------------------------------------------------------------------------
Q 6-2 According to the values assigned them (by the user
or the system), the variables listed below are of
the specified type:
-------------------------------------------------------------------------------------------
| |
| Variable Type |
| |
-------------------------------------------------------------------------------------------
| |
| HPJOBLIMIT (number of jobs allowed to run): integer |
| |
| HPJOBCOUNT (number of jobs currently running): integer |
| |
| RESPONSE (user response - either Y or N): string |
| |
| FILE NAME (user-supplied file name): string |
| |
-------------------------------------------------------------------------------------------
Q 6-3 Hint: HELP VARIABLESReturn. According to the Help
facility, each of the following variables are
defined.
Hint: SHOWVAR variablenameReturn
Their current values depend on your system:
------------------------------------------------------------------------------------------
| |
| Variable Current Value Definition |
| |
------------------------------------------------------------------------------------------
| |
| HPJOBLIMIT 7 Current job limit. |
| |
| HPSESLIMIT 60 Current session limit. |
| |
| HPPROMPT : The initial system prompt. |
| |
| HPPATH HPGROUP,PUB, Current search path |
| PUB.SYS |
| |
| HPVERSION X.11.50 Current version of operating |
| system. |
| |
| HPUSER USER1 User name. |
| |
| HPSESCOUNT varies with the system Current number of sessions. |
| |
------------------------------------------------------------------------------------------
Q 6-4 To list all the system-defined and user-defined
variables, enter this command:
SHOWVAR @
Q 6-5 The system-defined variables in the STATS command
file are the following:
HPJOBLIMIT
HPJOBCOUNT
Q 6-6 No, neither variable is user-modifiable.
Q 6-7 In the LF command file, the three user-defined
variables are:
RESPONSE
FILE NAME
OPTION
Exercise 6-1: Variables
1. To define a variable called MYPROMPT and assign it the value
currently stored in HPPROMPT, enter the following:
SETVAR MYPROMPT HPPROMPT
2. To display the value of MYPROMPT, enter the following:
SHOWVAR MYPROMPT
3. To delete MYPROMPT and verify that it is gone, enter the
following:
DELETEVAR MYPROMPT
SHOWVAR MYPROMPT
MYPROMPT is a user-defined variable.
HPPROMPT is a system-defined variable.
You cannot delete system-defined variables.
********* End of Exercise 6-1 **********