/* ***************************************************************************** * * * Copyright (c) 1978, 1979, 1980 * * by DIGITAL Equipment Corporation, Maynard, Mass. * * * * This software is furnished under a license and may be used and copied * * only in accordance with the terms of such license and 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. No title to and ownership of the software is hereby * * transferred. * * * * The information in this software is subject to change without notice * * and should not be construed as a commitment by DIGITAL Equipment * * Corporation. * * * * DIGITAL assumes no responsibility for the use or reliability of its * * software on equipment which is not supplied by DIGITAL. * * * ***************************************************************************** facility: SDL (Structure Definition Language) abstract: includes utility routines to convert an integer to a trimmed character string and to fill out a buffer with blanks to a given column width author: C.T. Pacy date: revised 22-DEC-1980 ctp */ %replace line_length by 132; /******************************* TRIM ****************************** * * accept an integer and return the equivalent character string * stripped of all leading blanks */ TRIM: proc (i) returns (char(32) var); dcl i fixed bin; dcl a char(32) var; a=character(i); a=substr(a,verify(a,' ')); return(a); end TRIM; /******************************** FILL ****************************** * * fill out the statement part of a short statement to n characters * (don't forget to account for the fact that tabs take up more * than one character space of output!) */ FILL: proc(a,n) returns (char(line_length) var); dcl tab char init (byte(9)); dcl n fixed bin, nblks fixed bin; dcl a char(*) var; dcl b char(line_length) var; dcl (l,i,j) fixed bin; b = a; i = index (b,tab); if i = 0 then l = length(b); else l = i - 1; do while (i ^= 0); l = l + (8 - mod(l,8)); if i>=length(b) then i=0; else do; j=index(substr(b,i+1),tab); if j=0 then do; l = l + length(substr(b,i+1)); i=0; end; else do; i = i + j; l = l + j - 1; end; end; end; if l < n then do; nblks = n - l; b = b || copy(' ',nblks); end; else b = b||' '; return (b); end FILL;