changeset 653:643e93f4b941

Added prsubstr() utility function.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Jul 2007 20:21:18 +0000
parents daa42c69dc35
children 4fc281dbe97b
files ggrtf.tf
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ggrtf.tf	Wed Jul 25 20:14:21 2007 +0000
+++ b/ggrtf.tf	Wed Jul 25 20:21:18 2007 +0000
@@ -206,6 +206,14 @@
 	/return strcat({1},_tmps)
 
 
+;; If string is longer than specified max, cut and pad with ellipsis (...)
+/def -i prsubstr =\
+	/if (strlen({1})>{2})\
+		/return "$[substr({1},0,{2}-3)]..."%;\
+	/else \
+		/return {1}%;\
+	/endif
+
 ;; Return string describing time elapsed from given timestamp parameter
 /def -i prgetstime =\
 	/let _tmps=$[prgettime(time()-{1})]%;\