From a6a710a365f73d8d02d2066d856acd803723d675 Mon Sep 17 00:00:00 2001
From: mcmlxxix <>
Date: Wed, 24 Jun 2009 18:04:12 +0000
Subject: [PATCH] Added "Center()" method for centering text within a given
 width rather than on an entire line

---
 exec/load/funclib.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/exec/load/funclib.js b/exec/load/funclib.js
index c31ca5a594..5c6207e608 100644
--- a/exec/load/funclib.js
+++ b/exec/load/funclib.js
@@ -83,6 +83,23 @@ function PrintPadded(string,length,padding,justification)
 	if(justification=="right") newstring=(padded + newstring);
 	return(newstring);
 }
+function CenterString(string,length,padding)
+{
+	if(!padding) padding=" ";
+	var strlength=console.strlen(string);
+	if(strlength>length)
+	{
+		string=string.substring(0,length);
+	}
+	var padlength=length-strlength;
+	var newstring=string;
+	for(p=1;p<=padlength;p++)
+	{
+		if(p%2==0) newstring+=padding;
+		else newstring=padding+newstring;
+	}
+	return newstring;
+}
 function DrawLine(x,y,length,color)
 {
 	if(x && y)
-- 
GitLab