; begin KiXgolfUDF ; ;! Function CIF($a, $y) Dim $,$s,$l,$e,$h,$q,$z,$c $l=Len($a)-1 Dim $w[$l] $c=@CRLF $y=Split($y,$c) ; ; LOOP 1 - pass through data and record longest entry in each column ; We also construct table top/botton/heading template as we go ; For Each $s in $y $h=@ For $=0 to $l $e=Len(Split($s,"&")[$]) If $w[$]<$e $w[$]=$e EndIf $h=Trim($h+" "+j($w[$],"<",@,"-")) Next Next ; ; LOOP 2 - Pass through data again, constructing table body ; For Each $s in $y $q=@ For $=0 to $l $q=$q+" | "+j($w[$],SubStr($a,$+1,1),Split($s,"&")[$]," ") ; Format data line Next $z=$z+"|"+SubStr($q,3)+" |"+$c +IIf($z=@,"|-"+Join(Split($h),"-+-")+"-|"+$c,@) ; IIf() the table is empty then this is the header line Next ; Add the header line to the top and bottom of the table $h="@-"+Join(Split($h),"---")+"-@" $CIF=$h+$c+$z+$h EndFunction ; Justification UDF ; $w=Width ; $t=Justification type ; $s=String to justify ; $c=Fill character ; Function j($w,$t,$s,$c) Dim $L,$R,$,$x If $t="<" $R=$c EndIf ; Left Justify If $t=">" $L=$c EndIf ; Right Justify If $t="=" $=$c EndIf ; Centre Justify, start on right while Len($s)<$w $s=$L+$j+$s+$R+$ $x=$ $=$j $j=$x ; Toggle centre justify RHS <-> LHS Loop $j=$s EndFunction ;! ;! ; end KiXgolfUDF ; vim:filetype=kix sw=4 ts=4
|