[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

CLI parsing and ambiguous verbs?

» close window

The Question is:

 
1. can I define a command, either foreign or in cld, that can have arbitrary
characters appended to the name?
 
example: the command is workhard but if the user types workharder or
workhardxx1 the same program will be run.
 
2. having solved 1, can the program now see what the appended characters
are?
 
 


The Answer is :

    Sort of. In its current implementation, the DCL command interpreter
    only considers the first four characters of any command. Thus, for
    instance, the command verb "DELEGATE" would be interpreted as "DELETE".
 
    Although a four character window of recognition may not be exactly what
    you're thinking of, it will do exactly what you have requested. The
    command verbs WORKHARD, WORKHARDER and WORKHARDXX1 will all activate
    the same image, but so will WORKSLOWER.
 
    Note however, that this is NOT documented behaviour, at present it's
    only an artifact of the way DCL implements recognition of unique
    contractions of commands. Indeed there is already latent support in DCL
    for enabling strict spell checking of all commands. So the wizard would
    strongly recommend against designing an application which was dependent
    on this behaviour.
 
    However, should you choose to ignore the Wizard's strong recommendation,
    it IS possible to identify the exact command verb used to invoke the
    image, but only by parsing the entire command line yourself. The routine
    CLI$GET_VALUE recognises two special entities, $VERB and $LINE which
    return the identified verb (up to four characters) and the entire command
    line. Here is a crude MACRO program which demonstrates their use.
    Note that MACRO is the true language of Wizard spells and incantations,
    those that prefer other tongues will have to affect their own translation.
 
       .title VerbAndLine
 
; Program displays the command verb and command line entered at DCL.
; Needs to be defined as a DCL verb as follows:
;  $ SET COMMAND SYS$INPUT:
;     DEFINE VERB <some-verb>
;     IMAGE <this-image>
 
;  Note that the command line should not exceed the length of the variable
;  "value". No attempt is made to correct the output length of the value
;  when writing output.
 
       .PSECT $DATA,rd,wrt,noexe
verb:  .ASCID /$VERB/
line:  .ASCID /$LINE/
value: .ASCID /                                                              /
       .PSECT $CODE,rd,nowrt,exe
       .ENTRY Start,^M<>
       PUSHAQ value
       PUSHAQ verb
       CALLS #2,G^CLI$GET_VALUE
       PUSHAQ value
       CALLS #1,G^LIB$PUT_OUTPUT
       PUSHAQ value
       PUSHAQ line
       CALLS #2,G^CLI$GET_VALUE
       PUSHAQ value
       CALLS #1,G^LIB$PUT_OUTPUT
        RET
       .END Start
 
    Applying this program to the problem as posed:
 
    $ SET COMMAND SYS$INPUT:
      DEFINE VERB WORKHARD
        IMAGE DKA100:[WIZARD]VERBANDLINE
 
    $ WORKHARD
    WORK
    WORKHARD
    $ workharder
    WORK
    WORKHARDER
    $ workhardxx1
    WORK
    WORKHARDXX1
    $ run verbandline
    RUN
    RUN VERBANDLINE
    $ workslower
    WORK
    WORKSLOWER
 
    In its current form, it will not accept any parameters or qualifiers:
 
    $ workharder xxx
    %DCL-W-MAXPARM, too many parameters - reenter command with fewer
    parameters \XXX\
 
    This could be overcome by defining appropriate verbs and qualifiers,
    but if that's too much work, you can tell DCL to ignore the remainder
    of the line by adding a single parameter as follows:
 
    $ SET COMMAND SYS$INPUT:
      DEFINE VERB WORKHARD
        IMAGE DKA100:[WIZARD]VERBANDLINE
    	PARAMETER P1,TYPE(VALUE=$REST_OF_LINE)
 

answer written or last revised on ( 16-JAN-2000 )

» close window