.TITLE LIB_ARGCHKRS Subprogram argument list check utilities .IDENT /V01.02/ ;++ARGCHKRS.MAR ; ; Facility: ; Fermilab Acclerator Control System - ACNET. ; General library routine. ; ; Abstract: ; Utility routine to check for number of required arguments. ; ; Environment: ; Called in user mode from a FORTRAN/PASCAL routine (usually). ; In FERMILIB.OLB object library. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 04-Oct-82 ; ; V01.00 04-Oct-82 FJN Created from ARGUTILS for use in support ; software packages ; V01.01 15-Apr-83 FJN Correct help comments ; V01.01 03-Jun-83 FJN Correct name to SS$_INSFARG ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $SFDEF ;Stack frame offsets $SSDEF ;System completion status codes .CROSS ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; ; NONE ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE LIB_CHK_ARGS Check for required arguments. ;+ LIB_CHK_ARGS ; Check for required number of arguments to the caller of this ; procedure. ; ; ret-sts.wlc.v = LIB_CHK_ARGS( nreq.rl.r ) ; ; nreq minimum number of arguments that are required to be in ; the argument list of caller of LIB_CHK_ARGS. Byte passed ; by reference. ; ; ret-sts completion status. SS$_NORMAL is returned if at least ; the number of required arguments is present in the caller's ; argument list. SS$_INSFARG is returned if too few ; arguments are in the caller's argument list or if a ; required argument is defaulted. Passed by value. ; ;- ;+0LIB_CHK_ARGS ; ; Functional Description: ; This routine checks for the existance of required arguments ; in the caller's argument list. ; ; Calling Sequence: ; status = LIB_CHK_ARGS( nreq ) ; ; Input Parameters: ; 4(AP) - address of byte giving the number of required arguments. ; ; Implicit Inputs: ; Stack frame containing old AP (of caller) pointing to argument list ; to be tested. ; ; Output Parameters: ; R0 - completion status code. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; SS$_NORMAL success, at least nreq arguments in outer call ; SS$_INSFARG insufficient number of required arguments or ; a required argument was defaulted. ; ; Side Effects: ; NONE ; ;- .ENTRY LIB_CHK_ARGS,^M MOVZWL #SS$_NORMAL,R0 ;Initialize to return success MOVL SF$L_SAVE_AP(FP),R1 ;Get old AP MOVZBL @4(AP),R2 ;Get number of args for previous call CMPB R2,(R1) ;Compare against true number of args. BGTRU 9$ ;If >number arguments, return failure 5$: TSTL (R1)[R2] ;Check value of a required argument BEQL 9$ ;If =0 (default), return failure SOBGTR R2,5$ ;Loop to check all the required args. RET ; 9$: MOVZWL #SS$_INSFARG,R0 ;Return failure, too few required args RET .END