.TITLE WHICH_QUAL ;; ; INTEGER FUNCTION WHICH_QUAL ( qual1 , qual2 , ... ) ; ; When called with a list of command qualifier names (of qualifiers ; which are supposed to be mutually exclusive), checks to make sure ; that no more than one was present on the command. If the Nth one ; was the one present, the function result is N. If none was pres- ; ent, then the ordinal of a default one, if any, is returned (if no ; default one is defined, zero is returned). If more than one was ; present, minus one is returned. ; ; Example: ; CLD: Define Verb ZZZ ; . . . ; Qualifier A , Default ; Qualifier B ; Qualifier C ; ; Program: . . . ; I = WHICH_QUAL('A','B','C') ; . . . ; ; If command = ZZZ /B then I = 2 ; ZZZ /C 3 ; ZZZ 1 (since /A is default) ; ZZZ /A /B -1 ; ; .INDEX COMMAND LANGUAGE INTERFACE>> ; ; Alan L. Zirkle Naval Surface Weapons Center ; Code K105 ; 9 Jul 1984 Dahlgren, Virginia 22448 ; .ENTRY WHICH_QUAL, ^M CLRQ R2 ; R2 = last present qual, R3 = # of quals pres. MOVL (AP), R4 ; R4 = current qual being checked MOVAB G^CLI$_PRESENT, R5 ; R5 = status value CLI$_PRESENT MOVAB G^CLI$_DEFAULTED, R6 ; R6 = status value CLI$_DEFAULTED LOOP: PUSHL (AP)[R4] ; Push address of next qual. descriptor CALLS #1, G^CLI$PRESENT ; Call VMS function CLI$PRESENT CMPL R0, R5 ; Is this qualifier present? BEQL PRESENT ; Branch if so CMPL R0, R6 ; Is this qualifier defaulted? BEQL DEFAULT ; Branch if so LOOPEND: DECL R4 ; R4 = ordinal of next qualifier BGTR LOOP ; Loop until all qualifiers checked MOVL R2, R0 ; Return ordinal of qual to use (zero if none) RET ; Return PRESENT: MOVL R4, R2 ; Save ordinal of present qualifier AOBLEQ #1, R3, LOOPEND ; Increment count of present qualifiers; ; Continue looping unless count > 1 MOVL #-1, R0 ; Return minus one as the function result RET ; Return DEFAULT: TSTL R3 ; Do we already have a PRESENT qualifier? BNEQ LOOPEND ; Branch if so MOVL R4, R2 ; Save ordinal of defaulted qualifier BRB LOOPEND ; Continue looping .END