.TITLE NBLEN - Return the non-blank length of a string ; ; Author: Chris Chaundy ; Date: 02-Jun-1981 ; ;+ ; This procedure finds the length of a string excluding trailing spaces. ; ; Calling sequence: ; ; length = NBLEN (str_dsc) ; ; Inputs: ; str_dsc - string descriptor ; ; Outputs: ; length - length of string ; ; Side-effects: ; none ;- STR_DSC = 4 .PSECT _STR_CODE PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT .ENTRY NBLEN,^M ; Initialization MOVQ @STR_DSC(AP),R0 ; R0 <15:0> = len, R1 = adr of STR_DSC MOVQ R0,R2 ; save the descriptor in R2, R3 ; Find last spaces in string 10$: LOCC #^A' ',R0,(R1) ; find space BEQL 20$ ; input string exhausted MOVL R1,R4 ; note current position in string SKPC #^A' ',R0,(R1) ; skip over it (or them) BNEQ 10$ ; loop if more string to go ; Find the length SUBL3 R3,R4,R0 ; return length in R0 RET ; No trailing blanks so return original length 20$: MOVZWL R2,R0 ; set output length RET .END