  | 
»  | 
 | 
  
 | 
 | 
Check Your Answers |    |  
 |   |  Is Your Answer ... ? |  If Not, Start With | 
|---|
 | 1.  | VAR_1 VARIABLE_1  |  Lesson 1 |  | 2.  | HPPROMPT or HPPATH  |  Lesson 1 |  | 3.  |  FALSE |  Lesson 1 |  | 4.  |  TRUE |  Lesson 1 |  | 5.  | SHOWVAR VARIABLE1 or  ECHO !VARIABLE1  |  Lesson 1 |  | 6.  | ECHO HELLO ___ WELCOME TO THE ...  - OR - SETVAR A "HELLO __ WELCOME TO THE ..." SHOWVAR Aor ECHO !A  |  Lesson 2 |  | 7.  | INPUT USERNAME;PROMPT="What is your name?" ECHO HELLO !USERNAME __ WELCOME TO THE ...  |  Lesson 2 |  | 8.  | You must explicitly dereference the value of VAR_A 
by using the statements in b and c. |  Lesson 2 |  | 9.  | CFA:  It prints: *** HELLO JULIO FROM SPAIN *** and quits. CFB:  It prints:  *** HELLO JULIO FROM SPAIN *** and reprompts. CFA:  It prints *** SORRY, NO MESSAGE *** and quits. CFB:  It prints *** SORRY, NO MESSAGE *** and quits. CFA:  It prints:  *** HELLO GINA FROM ITALY *** and quits.  It never gives you a chance to enter the //. CFB:  It prints:  HELLO GINA FROM ITALY *** and quits after you enter //. 
  | Lesson 2
 |  
 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,PUB.SYS | Current search path |  | 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:
 - 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
  |  
 
 To define a variable called MYPROMPT and assign it the value currently stored in HPPROMPT, enter the following:
 
SETVAR MYPROMPT HPPROMPT
 To display the value of MYPROMPT, enter the following:
 
SHOWVAR MYPROMPT
 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 ********** Lesson 2 Using Variables and Expressions |    |  
 - Q 6-8
 The method of dereferencing used in the two ECHO statements of the STATS command file is explicit dereferencing (exclamation points are used).
 - Q 6-9
 To give the three user-defined variables, USER, GROUP, and ACCT, the same values as those currently stored in the system-defined variables, HPUSER,HPGROUP, and HPACCT, you would do the following:
 
   SETVAR USER, HPUSER
   SETVAR GROUP, HPGROUP
   SETVAR ACCT, HPACCT
  |  
 - Q 6-10
 According to the IF-THEN statement in the STATS file, the following messages are displayed in each of the following situations:
 The current number of jobs is 10 and the job limit is 12.
 
   ***APPROACHING JOB LIMIT ---
   STREAM JOB LATER
  |  
 The current number of jobs is 5 and the job limit is 10.
 
   ***NUMBER OF JOBS IS STILL REASONABLE ---
   STREAM JOB NOW
  |  
 
 
 Exercise 6-2: IF-THEN-ELSE Statement- 1.
 Your IF-THEN-ELSE statement should look like this:
 
   IF HPSESCOUNT >= (HPSESLIMIT*3)/4 THEN
      SHOWVAR HPSESCOUNT
      SHOWVAR HPSESLIMIT
      ECHO ***TOO MANY PEOPLE ON SYSTEM --- LOG OFF NOW***
   ELSE
      SHOWVAR HPSESCOUNT
      SHOWVAR HPSESLIMIT
      ECHO *** CURRENT SESSION LIMIT NOT EXCEEDED ***
   ENDIF
 |  
 
 ****************** End of Exercise 6-2 ************* - Q 6-11
 As long as you respond with anything other than //, you will be prompted continually for file names.
 - Q 6-12
 To terminate being prompted for any more file names, you must respond with //.
 
 Your CF command file should look like this:
 
   INPUT RESPONSE;PROMPT="Do you want to change the prompt? (Y or N): "
      IF RESPONSE = 'Y' THEN
         SETVAR MYRESP 'N'
         WHILE MYRESP = 'N' DO
             INPUT HPPROMPT;PROMPT="Enter your new prompt (10 char. max): "
             ECHO !HPPROMPT
             INPUT MYRESP;PROMPT="Is this prompt OK? (Y or N): "
         ENDWHILE
      ELSE
         ECHO Current prompt remains in effect !HPPROMPT
   DELETEVAR RESPONSE,MYRESP
 |  
 When you enter your final prompt, this prompt should be displayed:
 
USERx:
 Use this command to change HPPROMPT to the initial system prompt:  
 
 ************ End of Exercise 6-3 ************  
 |