This is the lastest version of the program - 3.1, if you have an earlier version, C&P this one:
This will convert your drab black and white KiX scripts into bright beautiful colours and display them in a browser window as HTML.
You can then save/print them in your documentation and impresses your boss/friends. Maybe that girl in accounting will go out with you 
anyway... to run, just save this script as KiX2HTML.kix and run:
This is an early version and can be a little slow for big scripts.
The HTML tag section is 80% functional - try it with a .HTM file. There are still some little glitches with HTML in KiX as it is within quotes and should be treated as quoted text. I may remove the HTML colours and leave it as quoted text yet...
code:
break on
cls;
; KiX2HTML converter - for colourful displays
; version 3.1
; by cj
;
; This script will convert your KiX script to a colourful
; HTML page for easy reading.
;
; Vars you can edit
;
$bL1n35=1 ; 1=lines on output HTML, 0=no lines
;
; Colour table
;
$K2Hfunctions="<font color=#000080>" ; dark blue
$K2Hbrackets="<font color=#ff0000>" ; red
$K2Hcommands="<font color=#0000ff>" ; light blue
$K2Hcomments="<font color=#008000>" ; dark green
$K2Hhtmltag="<font color=#8b4513>" ; brown
$K2Hquotes="<font color=#008080>" ; dark cyan
$K2Htext="<font color=#000000>" ; black
$K2Hhtml="<font color=#ff00ff>" ; light magenta
;-------------------------------------------------------------------Do not edit below line-------------------------
; vars you can't edit
$html=$html+$K2Htext
$f4l5e=0 $t4u3=-1
$c8l4=chr(13)+chr(10)
dim $title
$in00t31=0 $in00t32=0 $in41m1=0
$uu04d="" $l1n3=1 $d15p14y=""
color w+/n
while $K2Hfilename=""
color w+/n "Please enter the full path and filename of your script" ? ">" color w/n gets $K2Hfilename
if exist($K2Hfilename)=0 cls color y+/n "File not found! Press a key" get$ cls $K2Hfilename="" endif ?
loop
; Parse the script - line by line and create a HTML sequence from the commands found
; start HTML sequence with:
$html="<html>$c8l4<head><title>KiX2HTML - by cj - $K2Hfilename</title><head>$c8l4<body>$c8l4"
$html=$html+"<style><!--body{ font-family: courier, arial--></style>$c8l4"
;$html=$html+"<font size=+1>" ; increase font size by 1
;$html=$html+"<B>" ; Bold
$html=$html+"$c8l4"
$=open(1, $K2Hfilename)
"KiX-2-HTML Converter" ?
"Version 3.1 by cj" ? ?
"Converting $K2Hfilename to HTML:" ? ? color w/n
"Line: $l1n3 "
$l1n3ine=readline(1)
while @error=0
; "$$l1n3ine='$l1n3ine'" ? "length="len($l1n3ine) ? ?
if $bL1n35=1 ; draw line numbers
$html=$html+$K2Htext $d15p14y=$l1n3 ; display line num in TEXT colour..
if $l1n3<100 $d15p14y="0$l1n3" endif if $l1n3<10 $d15p14y="00$l1n3" endif ; | this is why
$html=$html+"$d15p14y: " ; V we have to..
if ($in00t31=1) or ($in00t32=1) $html=$html+$K2Hquotes endif ; restore quotes colour
if $in41m1=1 $html=$html+$K2Hhtml endif ; restore html colour
endif
if $l1n3ine="" $html=$html+" " ; blank line
else
; scan line for special chars and keywords
$i=1
do
$char=substr($l1n3ine, $i, 1)
; special chars
select
case $char="<" "$uu04d" color m+/n "<" $html=$html+$uu04d+$K2Hhtml+"<" $uu04d="" $in41m1=1
case $char=">" "$uu04d" color m+/n ">" $html=$html+$uu04d+$K2Hhtml+">" $uu04d="" $in41m1=0
if $in00t31=1 or $in00t32=1 $html=$html+$K2Hquotes else $html=$html+$K2Htext endif
case $char="(" or $char=")" or $char="[" or $char="]" or $char="{" or $char="}"
color r+/n "$char"
$html=$html+$uu04d $uu04d="" if ($in00t31=0) and ($in00t32=0) $html=$html+$K2Hbrackets endif $html=$html+$char
if ($in00t31=0) and ($in00t32=0) $html=$html+$K2Htext endif
if ($in00t31=1) or ($in00t32=1) $html=$html+$K2Hquotes endif if $in41m1=1 $html=$html+$K2Hhtml endif
case $char="'" color c/n ; single quotes
if $in00t32=0
if $in00t31=0 ; turn ' on
$html=$html+$uu04d+$K2Hquotes+$char "$uu04d" color c/n "'" $uu04d="" $in00t31=1
else ; turn ' off
$html=$html+$uu04d+$K2Hquotes+$char "$uu04d" color c/n "'" $uu04d="" $in00t31=0
if $in41m1=1 $html=$html+$K2Hhtml color m+/n else $html=$html+$K2Htext color w/n endif
endif
else
$html=$html+$uu04d+$char "$char" $uu04d=""
endif
case $char='"' color c/n ; double quotes
if $in00t31=0
if $in00t32=0 ; turn " on
$html=$html+$uu04d+$K2Hquotes+$char "$uu04d" color c/n '"' $uu04d="" $in00t32=1
else ; turn " off
$html=$html+$uu04d+$K2Hquotes+$char "$uu04d" color c/n '"' $uu04d="" $in00t32=0
if $in41m1=1 color m+/n else $html=$html+$K2Htext color w/n endif
endif
else
$html=$html+$uu04d+$char "$char" $uu04d=""
endif
case $char=chr(9)
$html=$html+" " " " $char=chr(0) ; 1 tab = 5 spaces
case $char="/"
if substr($l1n3ine, $i-1, 1)="<" $html=$html+$K2Hhtmltag+$K2Hhtmltag+$char color y/n "/" endif
case $char=";" and $in00t31=0 and $in00t32=0 ; comments, but not in quotes...
$html=$html+$K2Hcomments+substr($l1n3ine, $i, len($l1n3ine)-$i+1)+$K2Htext
color g/n substr($l1n3ine, $i, len($l1n3ine)-$i+1) $i=len("$l1n3ine")
case 1
$uu04d=$uu04d+$char
if $i=len("$l1n3ine") $char=chr(0) endif ; end of line
endSelect
if ($char=" " or $char=chr(0) or substr($l1n3ine, $i+1, 1)=">") and ($in00t31=0) and ($in00t32=0) ; space or EoL, but only in non quotes
if substr($l1n3ine, $i+1, 1)=">" $char=chr(0) endif
if $char=" " $uu04d=substr($uu04d, 1, len($uu04d)-1) endif ; strip space for word check
; if $char=" " ? "$$word = '$uu04d', inHTML = $in41m1" ? endif
select
; commands
case $uu04d="BEEP" or $uu04d="BIG" or $uu04d="CALL" or $uu04d="CASE" or $uu04d="CD" or $uu04d="CLS"
or $uu04d="COLOR" or $uu04d="COOKIE1" or $uu04d="COPY" or $uu04d="DEL" or $uu04d="DIM" or $uu04d="DISPLAY"
or $uu04d="DO" or $uu04d="ELSE" or $uu04d="ENDIF" or $uu04d="ENDSELECT" or $uu04d="FLUSHKB" or $uu04d="GET"
or $uu04d="GETS" or $uu04d="GLOBAL" or $uu04d="GO" or $uu04d="GOSUB" or $uu04d="GOTO" or $uu04d="IF"
or $uu04d="LOOP" or $uu04d="MD" or $uu04d="PASSWORD" or $uu04d="PLAY" or $uu04d="RD" or $uu04d="RETURN"
or $uu04d="RUN" or $uu04d="SELECT " or $uu04d="SET" or $uu04d="SETL" or $uu04d="SETM" or $uu04d="SETTIME"
or $uu04d="SHELL" or $uu04d="SLEEP" or $uu04d="SMALL" or $uu04d="UNTIL" or $uu04d="USE" or $uu04d="WHILE"
if $char=" " $uu04d=$uu04d+" " endif ; replace stripped space
color b+/n "$uu04d" $html=$html+$K2Hcommands+$uu04d+$char+$K2Htext $uu04d=""
; functions
case ($uu04d="ADDKEY" or $uu04d="ADDPRINTERCONNECTION" or $uu04d="ADDPROGRAMGROUP" or $uu04d="ADDPROGRAMITEM"
or $uu04d="ASC" or $uu04d="AT" or $uu04d="BOX" or $uu04d="CHR" or $uu04d="CLOSE" or $uu04d="COMPAREFILETIMES"
or $uu04d="DECTOHEX" or $uu04d="DELKEY" or $uu04d="DELPRINTERCONNECTION" or $uu04d="DELPROGRAMGROUP"
or $uu04d="DELPROGRAMITEM" or $uu04d="DELTREE" or $uu04d="DELVALUE" or $uu04d="DIR" or $uu04d="ENUMGROUP"
or $uu04d="ENUMKEY" or $uu04d="ENUMLOCALGROUP" or $uu04d="ENUMVALUE" or $uu04d="EXECUTE" or $uu04d="EXIST"
or $uu04d="EXISTKEY" or $uu04d="GETDISKSPACE" or $uu04d="GETFILEATTR" or $uu04d="GETFILESIZE" or $uu04d="GETFILETIME"
or $uu04d="GETFILEVERSION" or $uu04d="INGROUP" or $uu04d="INSTR" or $uu04d="LCASE" or $uu04d="LEN" or $uu04d="LOADHIVE"
or $uu04d="LOADKEY" or $uu04d="LOGEVENT" or $uu04d="LOGOFF" or $uu04d="LTRIM" or $uu04d="MESSAGEBOX"
or $uu04d="OLECALLFUNC" or $uu04d="OLECALLPROC" or $uu04d="OLECREATEOBJECT" or $uu04d="OLEGETOBJECT"
or $uu04d="OLEGETPROPERTY" or $uu04d="OLEGETSUBOBJECT" or $uu04d="OLEPUTPROPERTY" or $uu04d="OLERELEASEOBJECT"
or $uu04d="OPEN" or $uu04d="READLINE" or $uu04d="READPROFILESTRING" or $uu04d="READTYPE" or $uu04d="READVALUE"
or $uu04d="REDIRECTOUTPUT" or $uu04d="RND" or $uu04d="RTRIM" or $uu04d="SAVEKEY" or $uu04d="SENDKEYS"
or $uu04d="SENDMESSAGE" or $uu04d="SETCONSOLE" or $uu04d="SETDEFAULTPRINTER" or $uu04d="SETFILEATTR" or $uu04d="SETFOCUS"
or $uu04d="SETWALLPAPER" or $uu04d="SHOWPROGRAMGROUP" or $uu04d="SHUTDOWN" or $uu04d="SRND" or $uu04d="SUBSTR" or $uu04d="UCASE"
or $uu04d="UNLOADHIVE" or $uu04d="VAL" or $uu04d="WRITELINE" or $uu04d="WRITEPROFILESTRING" or $uu04d="WRITEVALUE"
or $uu04d="BREAK" or $uu04d="EXIT" or $uu04d="QUIT") and ($in41m1=0)
if $char=" " $uu04d=$uu04d+" " endif ; replace stripped space
color b/n "$uu04d" $html=$html+$K2Hfunctions+$uu04d+$char+$K2Htext $uu04d=""
; HTML tags
case ($uu04d="A" or $uu04d="ABBR" or $uu04d="ACRONYM" or $uu04d="ADDRESS" or $uu04d="APPLET" or $uu04d="AREA"
or $uu04d="B" or $uu04d="BASE" or $uu04d="BASEFONT" or $uu04d="BDO" or $uu04d="BGSOUND" or $uu04d="BIG" or $uu04d="BLINK"
or $uu04d="BLOCKQUOTE" or $uu04d="BODY" or $uu04d="BR" or $uu04d="BUTTON" or $uu04d="CAPTION" or $uu04d="CENTER" or $uu04d="CITE"
or $uu04d="CODE" or $uu04d="COL" or $uu04d="COLGROUP" or $uu04d="DD" or $uu04d="DEL" or $uu04d="DFN" or $uu04d="DIR"
or $uu04d="DIV" or $uu04d="DL" or $uu04d="DT" or $uu04d="EM" or $uu04d="EMBED" or $uu04d="FIELDSET" or $uu04d="FONT"
or $uu04d="FORM" or $uu04d="FRAME" or $uu04d="FRAMESET" or $uu04d="H1" or $uu04d="H2" or $uu04d="H3" or $uu04d="H4"
or $uu04d="H5" or $uu04d="H6" or $uu04d="HEAD" or $uu04d="HR" or $uu04d="HTML" or $uu04d="I" or $uu04d="IFRAME"
or $uu04d="ILAYER" or $uu04d="IMG" or $uu04d="INPUT" or $uu04d="INS" or $uu04d="ISINDEX" or $uu04d="KBD" or $uu04d="KEYGEN"
or $uu04d="LABEL" or $uu04d="LAYER" or $uu04d="LEGEND" or $uu04d="LI" or $uu04d="LINK" or $uu04d="LISTING" or $uu04d="MAP"
or $uu04d="MENU" or $uu04d="META" or $uu04d="MULTICOL" or $uu04d="NOBR" or $uu04d="NOEMBED" or $uu04d="NOFRAMES"
or $uu04d="NOLAYER" or $uu04d="NOSCRIPT" or $uu04d="OBJECT" or $uu04d="OL" or $uu04d="OPTGROUP" or $uu04d="OPTION"
or $uu04d="P" or $uu04d="PARAM" or $uu04d="PLAINTEXT" or $uu04d="PRE" or $uu04d="Q" or $uu04d="S" or $uu04d="SAMP"
or $uu04d="SCRIPT" or $uu04d="SELECT" or $uu04d="SERVER" or $uu04d="SMALL" or $uu04d="SOUND" or $uu04d="SPACER" or $uu04d="SPAN"
or $uu04d="STRIKE" or $uu04d="STRONG" or $uu04d="STYLE" or $uu04d="SUB" or $uu04d="SUP" or $uu04d="TBODY" or $uu04d="TEXTAREA"
or $uu04d="TITLE" or $uu04d="TT" or $uu04d="U" or $uu04d="UL" or $uu04d="VAR" or $uu04d="WBR" or $uu04d="XMP"
or $uu04d="TABLE" or $uu04d="TD" or $uu04d="TFOOT" or $uu04d="TH" or $uu04d="THEAD" or $uu04d="TR") and ($in41m1=1)
if $char=" " $uu04d=$uu04d+" " endif ; replace stripped space
color y/n "$uu04d" $html=$html+$K2Hhtmltag+$uu04d+$char+$K2Htext $uu04d=""
case 1
if $char=" " $uu04d=$uu04d+" " endif ; replace stripped space
$html=$html+$uu04d+$char "$uu04d" $uu04d=""
endSelect
endif
$i=$i+1 color w/n
until $i=len("$l1n3ine")+1
endif
$uu04d=""
$html=$html+"<br>$c8l4"
$l1n3ine=readline(1) ? if @error=0 $l1n3=$l1n3+1 "$l1n3 " else ? color w+/n "$l1n3 lines processed." ? ? endif
loop
$=close(1)
$html=$html+"</body>$c8l4</html>$c8l4"
;"$html"
$top="10" $l1n3eft="10" $height="450" $width="600" "Launching ie Window..." ? gosub ie
?
quit
:IE
; thanks goto Bryce for this IE rendering code - great work!
;$top="100"
;$l1n3eft="200"
;$height="400"
;$width="275"
$ie = olecreateobject("internetexplorer.application")
if $ie = 0 exit endif
; Set properties and display form ...
$nul = oleputproperty($ie, "addressbar","s","$f4l5e")
$nul = oleputproperty($ie, "menubar", "s", "$t4u3")
$nul = oleputproperty($ie, "toolbar", "s", "$t4u3")
$nul = oleputproperty($ie, "statusbar", "s", "$f4l5e")
$nul = oleputproperty($ie, "resizable", "s", "$t4u3")
$nul = oleputproperty($ie, "top", "s", "$top")
$nul = oleputproperty($ie, "left", "s", "$l1n3eft")
$nul = oleputproperty($ie, "height", "s", "$height")
$nul = oleputproperty($ie, "width", "s", "$width")
$nul = oleputproperty($ie, "visible", "s", "$t4u3")
$nul = olecallfunc($ie, "navigate", "s", "about:blank")
while olegetproperty($ie, "busy") <> "0" and @error = 0 loop
; Get a handle to the open document ...
$d15p14yoc = val("&" + olegetproperty($ie, "document"))
$nul = olecallfunc($d15p14yoc, "write", "s", "$html")
;while setfocus("$title") <> 0 loop
return