Answer to question 13

We could come up with lots of valid solutions here :
# Solution
1 SAY '"''"'variable'"''"'
2 SAY '__'variable'__'
3 say '>>'varname'<<'
4 say var'X'
5 say '('var1') ('var2')'

Solution 4 is the shortest to code.  Solution 5 allows showing more than one variable.

You could also come to solutions like these :

   say '"'var'"'
   say "'"var"'"
   say """"var""""

and may then wonder why you get sometimes strange results with

   say "var" - ""var"" - """var""", etc.

This has to do with line-editing characters and it may be useful to briefly review these:
# Line-end. You hopefully all know this character allows you to separate several commands, and commands prefixed with a #CP will let CP keep the command for itself.
@ Character delete.  This was useful in the ancient days when there were only typewriter terminals.  When you typed a wrong character, then on these terminals there was no backspace or delete key, and so you could tell CP to ignore the preceding character by appending an @.  For example, the string ABD@C was understood as ABC.
¢ Line delete.  As for the @, the ¢ allowed you to say to CP that all the preceding characters you entered at the terminal should be ignored.  So, ABCDEF¢FEDCBA would, at the end, result in FEDCBA.  Both the @ and the ¢ are no longer useful on our display terminals, and so it would be wise to disable them (see below for how you can do it).
" Escape.  In the case you want to enter a command or text that contains one of the above characters the escape character allows you to indicate to CP that the subsequent character has not to be interpreted as a line-editing character.  So, if you enter ABCD"#EF then the result becomes ABCD#EF.

If we suppose the ESCAPE character (") is turned ON, then
"var" means CP interprets both " characters as escape characters, and thus, they are discarded from the command.  The first one instructs CP not to consider the v as a line-editing character, thus only var is passed to REXX, which in turn displays the value of the variable, but you don't see the trailing blanks...
""var"" means CP interprets the first and third " character as an escape character, CP deletes them from the string passed to REXX, so that REXX gets say "var" resulting in the display of the word var (not the value of var).
"""var""" means CP interprets the first, third, fourth and sixth " as an escape character, leaving "var" for REXX, who interprets this as a literal string and thus displays the word var.

You can turn OFF some or all of the line-editing characters in the following manners :

  1. by issuing the CP TERM CHARDEL OFF you disable the @ character.  Similarly, you can disable the LINEDEL, LINEND and ESCAPE characters.
  2. by issuing the CP SET LINEDIT OFF you disable all line-editing characters with one command.  But attention, if you issue the CP Q TERM command, you still see what they were and can't determine if they are active or not.
  3. by updating the CP directory.  The format of the USER card is as follows :
       USER MAINT PASSWORD 32M 128M ABCEFG 64 linend linedel chardel escape
    

    All parameters are positional.  The 64 in the example indicated a priority level for the user in the VM/SP days.  This positional parameter has no meaning in VM/ESA, but its position remains for compatibility reasons.  The last 4 parameters can be set to OFF, indicating that the corresponding line-editing characters are to be disabled.  Unfortunately, it is not possible to disable the characters for all users via a PROFILE definition in the directory. To solve that problem...

  4. VM/ESA allows to define the line-editing characters in the SYSTEM CONFIG file:
       /* Special characters for terminals ************************/
         character_defaults line_end    #,
                            line_delete off,
                            char_delete @,
                            escape      "
    

In summary, we would recommend to disable the CHARDEL and LINEDEL characters, but keep the LINEND and ESCAPE characters.

Use the backward navigation to return to the lesson.