Re: text centering function?
Posted in 1994
>From: ries@hqrim.sedd.trw.com (Marc Ries) >Subject: text centering function? >Date: Thu, 24 Feb 1994 21:35:04 GMT >X-Informix-List-Id: <news.5660> > > Before I reinvent the wheel, does anyone have a quick function > to "center" text [something like txtcntr("text", line_width)]? Here's one. Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> : "%W% %E%" #!/bin/sh # shar: Shell Archiver (v1.22) # # This is a shell archive. # Remove everything above this line and run sh on the resulting file # If this archive is complete, you will see this message at the end # "All files extracted" # # Created: Fri Feb 25 09:45:59 1994 by johnl at Informix Software Inc # Files archived in this archive: # centre.4gl # if test -f centre.4gl; then echo "File centre.4gl exists"; else echo "x - centre.4gl" sed 's/^X//' << 'SHAR_EOF' > centre.4gl && X{ X @(#)centre.4gl 1.4 90/04/05 X @(#)Sphinx Informix Tools: General Library X @(#)Centre string in field X @(#)Author: JL X} X XFUNCTION centre(title, ncols) X X DEFINE X sccs CHAR(1), X title CHAR(512), X ncols INTEGER { width of field } X X DEFINE X col SMALLINT, X centr CHAR(512) X X LET col = (ncols - LENGTH(title)) / 2 X IF col > 0 THEN X LET centr = col SPACES, title CLIPPED X ELSE X LET sccs = "@(#)centre.4gl 1.4 90/04/05" X LET centr = title X LET ncols = LENGTH(title) X END IF X X RETURN centr[1,ncols] CLIPPED X XEND FUNCTION {centre} SHAR_EOF chmod 0444 centre.4gl || echo "$0: failed to restore centre.4gl" fi echo All files extracted exit 0