Don't Quote
Me

Proper use of single and
Double Quotes
In DCL

Last Updated
16-DEC-1998


One of the most common mistakes that occurs in DCL programming is the improper use of quotes (single and double). The double quote (") is used to inclose a string of characters. The single quote (') is used to signal symbol substitution. For example :

$WRITE SYS$OUTPUT "This is a proper usage of the double quotes."

and

$OTHER_NODE := MANGO
$
MONITOR SYSTEM/NODE='OTHER_NODE'

are both examples of proper usage of double and single quotes. DEC (Digital Equipment Corporation, now COMPAQ) also gave you the ability to do symbol substitution within a character string. To do this you must precede the symbol with two single quotes and follow it with one single quote. For example :

$USER = F$GETJPI ("USERNAME")
$INQUIRE BIRTHDAY "Enter in the birthday for user ''USER' now"

The above example is the proper usage of symbol substitution in a quoted string. The following example is not the proper way :

$USER = F$GETJPI ("USERNAME")
$
WRITE SYS$OUTPUT "The birthday for user ''USER' is unknown."

But, you may say, they look pretty much the same. The only difference is the first example uses the INQUIRE command and the second uses the WRITE command. Well, that is exactly the reason. If you were to check out the documentation in the DCL dictionary, and look at the description of the third parameters for the INQUIRE and the WRITE commands, you would see that the INQUIRE command asks for a string of characters, and the write command asks for a list of symbol expressions.

I know! Your are saying, "What's the difference, who cares, especially since the second example works just fine. I don't get any errors!" Well, before I tell you why you shouldn't do it, let me show you the way it should be done :

$USER = F$GETJPI ("USERNAME")
$
WRITE SYS$OUTPUT "The birthday for user ",USER," is unknown."

In the first incorrect example we have a single symbol expression with an inline symbol substitution. In the second correct example we have a list of three symbol expressions with no symbol substitution. The reason you should use the second form is that the first form takes almost eight times longer to execute, uses more memory, and if you have many of them in a DCL command procedure, will significantly slow you down. Especially if you do multiple translations.

As a general rule (not always), any time you do symbol translation in a string, you can do it better and faster by building one or more symbol expressions. The only time is when the documentation calls specifically for a character string, as in the INQUIRE command.

Some other examples are in the building of larger symbols in DCL. For example this section from the file SYS$MANAGER:SYLOGICALS.COM :

$DEFINE/SYSTEM SYS$ANNOUNCE -
"Welcome to Open VMS
''F$GETSYI("VERSION")' on node ''F$GETSYI("NODENAME")'"

would be better specified as :

$WELCOME = """Welcome to Open VMS " + F$GETSYI("VERSION") + -
           
" on node ", + F$GETSYI("NODENAME") + """"
$
DEFINE/SYSTEM SYS$ANNOUNCE 'WELCOME'

So! if you are doing symbol translation in a quoted string chances are you could do better, but please "Don't quote me!".

If you have any questions or problems with the above file, please feel free to eMail me with the specifics of your problem or question.


My Home Page | VMS Home

DCL | Utilities | Management | Tips

FORTRAN | Pascal

eMail Questions

Quiz?