.MCALL .MODULE .MODULE STRPAD,VERSION=03,COMMENT=,IDENT=NO,LIB=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL STRPAD - FORTRAN CALLABLE SUBROUTINE ; ; CALL STRPAD(A,I[,ERR]) ; ; THIS ROUTINE PADS STRING A IN PLACE WITH BLANKS TO LENGTH I. ; PADDING OCCURS BY CONCATENATING A STRING OF BLANKS TO THE RIGHT OF ; A, WHERE THE NUMBER OF BLANKS IS EQUAL TO (I - LEN(A)). IF THE ; PRESENT LENGTH OF THE STRING IN A IS GREATER THAN OR EQUAL TO I, ; THEN NO PADDING OCCURS. IF OPTIONAL ARGUMENT ERR IS GIVEN, AND ; THE LENGTH OF THE STRING IN A IS GREATER THAN I, THEN ERR IS SET ; TO .TRUE.,OTHERWISE ERR IS NOT CHANGED. THIS ROUTINE IS USEFUL ; FOR OUTPUT USING A-TYPE FORMAT ITEMS ; ; MAS .PSECT SYS$I .GLOBL $SYSLB STRPAD::MOV (R5)+,R3 ;# OF ARGS IN LOW BYTE MOV (R5)+,R1 ;STRING POINTER MOV @(R5)+,R2 ;LENGTH BEQ 20$ ;ZERO, ALWAYS SIGNAL ERROR 10$: TSTB (R1)+ ;AT END OF STRING YET? BEQ 40$ ;YES, BEGIN BLANK PADDING ;>>> sob? DEC R2 ;COUNT LENGTH BNE 10$ 20$: CMPB #3,R3 ;ERR GIVEN? BHI 30$ ;NO, JUST RETURN CMP #-1,@R5 ;ARG PRESENT? BEQ 30$ ;= -> NO MOVB #-1,@(R5)+ ;SET ERR TO .TRUE. 30$: RETURN 40$: DEC R1 ;BACK UP OVER NULL 50$: MOVB #40,(R1)+ ;OUTPUT BLANKS ;>>> sob? DEC R2 BNE 50$ CLRB (R1)+ ;TERMINATE OUTPUT STRING RETURN .END