#53739 - 2001-02-08 02:42 PM
KiX-to-HTML converter
|
cj
MM club member
   
Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
|
{this message has been updated}This is the lastest version of the program - 3.1, if you have an earlier version, C&P this one: Hi all,
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: kix32 KiX2HTML.kix and enter a filename when prompted or kix32 KiX2HTML.kix $K2Hfilename="your drab script.kix" You will get a display like this: {the display has been updated to show a colour version of the KiX script, as it renders} then the ie4+ window will open. This is an early version and can be a little slow for big scripts. If you want to turn off the line numbers in the HTML output: ( ; ; Vars you can edit ; $bL1n35=1 ; 1=lines on output HTML, 0=no lines } I have been using Bryce's script for testing as it contains some HTML.
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... cj 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
[This message has been edited by cj (edited 09 February 2001).]
|
|
Top
|
|
|
|
#53743 - 2001-02-09 01:55 AM
Re: KiX-to-HTML converter
|
Anonymous
Anonymous
Unregistered
|
Nice Script CJ, looks good when outputted.Just some info, When I ran the script it processed 225 lines but when it opened, the line numbers down the side of the browser only went up to 099. eg, 097: 098: 099: 099: 099: 099: etc... Terry.
|
|
Top
|
|
|
|
#53746 - 2001-02-09 09:40 PM
Re: KiX-to-HTML converter
|
Paul_Berquam
Hey THIS is FUN
Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
|
Awesome script cj. Is there no limit?------------------
"He was a good little monkey and always very curious..."
_________________________
He was a good little monkey and always very curious...
|
|
Top
|
|
|
|
#53754 - 2001-12-20 02:20 PM
Re: KiX-to-HTML converter
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Wizard ,here a quote from KiX 2001 reference : quote:
COM automation in KiXtart 2001COM Automation is a way for applications (such as Word and Excel) to expose functionality to other applications, including scripting languages such as KiXtart. This provides an easy way to access properties and call methods of other applications from within a script. Note: the new COM automation support in KiXtart 2001 replaces the OLE functions in previous versions of KiXtart. Creating a COM object in KiXtart is simple: $Object = CreateObject("WScript.Shell") $ExcelSheet = CreateObject("Excel.Sheet") To release all system and memory resources associated with an object, simply assign any other value to the variable: $Object = 0
find a compiled version of the latest documentation at www.scriptlogic.com/kixtart hth -Gandalf [ 20 December 2001: Message edited by: jpols ]
_________________________
|
|
Top
|
|
|
|
#53757 - 2001-12-22 02:00 AM
Re: KiX-to-HTML converter
|
cj
MM club member
   
Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
|
|
|
Top
|
|
|
|
#53758 - 2003-09-30 05:45 PM
Re: KiX-to-HTML converter
|
Dean F
Lurker
Registered: 2003-09-30
Posts: 1
Loc: Seattle
|
CJ- I thought I'd post an update to your code since I thoroughly benefited from the base code and enjoy using it.
I had to fix the following issues prior to using it in KiX 4.2x Issue 1. - An operator (i.e. "=","AND","OR","NOT","In","/","\","*","&","+","-") followed by an open bracket such as “(“ would cause the operator to not be formatted correctly. Issue 2. - Certain characters or commands were dropped if directly followed by a comment character “;” in the same line. Issue 3. - A slash (“/” or “\”) following an operator would get dropped. Issue 4. - Some text would get formatted in the light magenta color incorrectly. Light Magenta was removed. Issue 5. - Some 4.2x commands did not get converted. Updated script to have all correct 4.2x commands. Issue 6. - KiX ver 3.x OLE calls are outdated and will not work in current version of KiX. Replaced with COM functions. Issue 7. - Script could not handle converting larger KiX scripts (roughly 300+ lines) due to varriable reassignment and memory settings. Reworked with an array to dump longer variables to arrayed variables. Issue 8. - Updated commands and functions to latest version of KiX.
I'll admit that I probably made a few unconventional modifications. Additionally, to handle some of the newer KiX 4.2x code, I had to modify how it converts special characters. In doing so, it doesn't always display the output to the DOS console correctly but it will convert it correctly to HTML.
Also, it is recommended that when attempting to convert larger scripts (about 700+ lines) that one uses a "faster" machine - at least a P4 with a 512MB of RAM.
I also disabled the HTML tag conversions as that would interfere with some of the newer functionalities.
If anyone finds an error, please post it.
Enjoy!
code:
;============================================= ;Written in KiXscripts Editor ver 1.7 ;Written by CJ - February, 2001 ;Last Modified on 9/28/2003 at 11:46:34 PM by: ;Dean F. ;=============================================
Break ON CLS $ = SetOption("WrapAtEOL","On") $ = SetOption("Explicit","On") $ = SetConsole("Show")
; KiX2HTML converter - for colorful displays in HTML format ; ; This script will convert your KiX script to a colorful ; HTML page for easy reading.
;================================================ ;Variable Settings and Declarations ;================================================ ;===================================== ; Variables you can't edit ;===================================== Global $HTML,$False,$True,$CRLF,$Title,$SingleQuotes,$DblQuotes,$K2HCmdIsBlank Global $K2HCommand,$NoLinesProcessed,$Document,$Error,$Lines,$RightChar1 Global $K2HTextColor,$K2HFunctionColor,$K2HBracketColor,$K2HCommandColor,$K2HCommentColor Global $K2HHTMLTagColor,$K2HQuoteColor,$K2HHTMLColor,$K2Hfilename Global $ProcessNextLine,$SpecialChar,$K2HChar Global $Nul,$Commands,$Functions,$Operators,$HTMLTags,$Step, $CMDStep,$TagStep,$OperStep,$CMD,$Test,$TheCommand, $VariableLength,$ScreenRes,$ScreenWid,$ScreenHit,$IE, $Und,$Count,$Visible,$OperatorCheck $HTML = $HTML + $K2HTextColor $False = 0 $True = -1 $CRLF = Chr(13) + Chr(10); - OLD CARRIAGE Return AND LINE FEED $SingleQuotes = 0 $DblQuotes = 0 $K2HCmdIsBlank = 0 $K2HCommand = "" $K2HChar = "" $NoLinesProcessed = 1 $Document = "" $Error = 0 Dim $MoreHTML [5]
;===================================== ; Variables you can edit ;===================================== ;============= ; Color Table ;============= $K2HFunctionColor = "<B><font color=#0000ff>"; light blue $K2HBracketColor = "<font color=#ff0000>"; red $K2HCommandColor = "<B><font color=#0000ff>"; light blue $K2HCommentColor = "<I><font color=#008000>"; dark green $K2HHTMLTagColor = "<font color=#8b4513>"; brown $K2HQuoteColor = "<font color=#990066>"; blue violet $K2HTextColor = "<font color=#000000>"; black $K2HHTMLColor = "<font color=#ff00ff>"; light magenta
;============= $Lines = 1; 1 = lines on output HTML, 0 = no lines
;====================================== ;KiX Commands, Functions, and Variables ;====================================== $Commands = "?","ABS","Beep","Big","Break","Call","Case", "CD","CLS","Color","Cookie1","Copy","Debug","Del", "Dim","Display","Do","Each","Else","EndIf","EndSelect", "EnumIPInfo","ExistKey","Exit","FlushKB","For","FreeFileHandle", "Next","Get","Gets","Global","Go","Gosub","GoTo", "KBHit","If","Loop","MD","Password","Play","Quit", "RD","ReDim","Return","Run","Select","Set","SetL", "SetM","SetTime","Shell","Sleep","Small","Until", "Use","While" $Operators = "=","AND","OR","NOT","In","/","\","*","&","+","-" $Functions = "AddKey","AddPrinterConnection","AddProgramGroup", "AddProgramItem","Asc","AScan","At","BackupEventLog", "Box","CDbl","Chr","CInt","ClearEventLog","Close", "CompareFileTimes","CreateObject","CStr","DecToHex", "DelKey","DelPrinterConnection","DelProgramGroup", "DelProgramItem","DelTree","DelValue","Dir","EndFunction", "EnumGroup","EnumIPInfo","EnumKey","EnumLocalGroup", "EnumValue","Execute","Exist","ExpandEnvironmentVars", "Fix","FormatNumber","Function","GetDiskSpace","GetFileAttr", "GetFileSize","GetFileTime","GetFileVersion","GetObject", "IIf","InGroup","InStr","InStrRev","Int","IsDeclared", "Join","KBHit","KeyExist","Lcase","Left","Len","LoadHive", "LoadKey","LogEvent","Logoff","LTrim","MemorySize", "MessageBox","Open","ReadLine","ReadProfileString", "ReadType","ReadValue","RedirectOutput","Right","Rnd", "Round","RTrim","SaveKey","SendKeys","SendMessage", "SetASCII","SetConsole","SetDefaultPrinter","SetFileAttr", "SetFocus","SetOption","SetSystemState","SetTitle", "SetWallpaper","ShowProgramGroup","Shutdown","SIDToName", "Split","SRnd","SubStr","Trim","Ubound","Ucase","UnloadHive", "Val","VarType","VarTypeName","WriteLine","WriteProfileString","WriteValue" $HTMLTags = "A","ABBR","ACRONYM","ADDRESS","APPLET","AREA","B", "BASE","BASEFONT","BDO","BGSOUND","BIG","BLINK","BLOCKQUOTE", "BODY","BR","BUTTON","CAPTION","CENTER","CITE","CODE", "COL","COLGROUP","DD","DEL","DFN","DIR","DIV","DL", "DT","EM","EMBED","FIELDSET","FONT","FORM","FRAME", "FRAMESET","H1","H2","H3","H4","H5","H6","HEAD","HR", "HTML","I","IFRAME","ILAYER","IMG","INPUT","INS", "ISINDEX","KBD","KEYGEN","LABEL","LAYER","LEGEND", "LI","LINK","LISTING","MAP","MENU","META","MULTICOL", "NOBR","NOEMBED","NOFRAMES","NOLAYER","NOSCRIPT", "OBJECT","OL","OPTGROUP","OPTION","P","PARAM","TR", "PLAINTEXT","PRE","Q","S","SAMP","SCRIPT","SELECT", "SERVER","SMALL","SOUND","SPACER","SPAN","STRIKE", "STRONG","STYLE","SUB","SUP","TBODY","TEXTAREA","TITLE", "TT","U","UL","VAR","WBR","XMP","TABLE","TD","TFOOT","TH","THEAD"
;================================================ ;Ask for the full path to the KIX script file. ;================================================Color w + /n While $K2Hfilename = "" Color w + /n "Please enter the full path and filename of your script." ? "When typing in a long file path, " Color y+/n "QUOTES ARE NOT NECESSARY" Color w + /n "!" ? "Type " Color R + /n "EXIT" Color w + /n " to exit this program. " Color w + /n "Press ENTER when ready." ? "<Path or EXIT>" Color w/n Gets $K2Hfilename If Ucase("$K2Hfilename") = "EXIT" Exit EndIf If Exist($K2Hfilename) = 0 CLS Color y + /n "File not found! Press a key" Get $Nul 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>$CRLF<head><title>KiX2HTML - $K2Hfilename</title><head>$CRLF<body>$CRLF" Gosub CheckVariableLength $HTML = $HTML + "<style><!--body{ font-family: courier, arial--></style>$CRLF" Gosub CheckVariableLength $HTML = $HTML + "$CRLF" Gosub CheckVariableLength
$Nul = Open(1,"$K2Hfilename",0) "KiX-2-HTML Converter" ? "Converting $K2Hfilename to HTML:" ? ? Color w/n "Line:" ? "1 " $ProcessNextLine = ReadLine(1) If $ProcessNextLine = ";ENDOFFILE" $Error = 1 EndIf
;================================================ ;Check each Command (Character by Character), properly format the character/command ;and convert it to HTML format and dump it to a string of variables ;================================================While $Error = 0 Gosub CheckVariableLength $OperatorCheck = 0 If $Lines = 1; draw line numbers $HTML = $HTML + $K2HTextColor $Document = $NoLinesProcessed ;Display line num in TEXT colour.. If $NoLinesProcessed < 1000 $Document = "$NoLinesProcessed" EndIf If $NoLinesProcessed < 100 $Document = "0$NoLinesProcessed" EndIf If $NoLinesProcessed < 10 $Document = "00$NoLinesProcessed" EndIf ; | this is why $HTML = $HTML + "$Document: "; V we have to.. Gosub CheckVariableLength If ($SingleQuotes = 1) OR ($DblQuotes = 1) $HTML = $HTML + $K2HQuoteColor Gosub CheckVariableLength EndIf; restore quotes color and If $K2HCmdIsBlank = 1 $HTML = $HTML + $K2HTextColor Gosub CheckVariableLength EndIf; restore html color EndIf If $ProcessNextLine = "" $HTML = $HTML + " "; blank line Gosub CheckVariableLength Else ; scan line for special chars and keywords $SpecialChar = 1 Do $K2HChar = SubStr("$ProcessNextLine",$SpecialChar,1) ; special chars Select Case $K2HChar = "<" "$K2HCommand" Color r + /n "<" $HTML = $HTML + $K2HCommand + $K2HBracketColor + "<" Gosub CheckVariableLength $K2HCommand = "" $K2HCmdIsBlank = 1 If $SingleQuotes = 1 OR $DblQuotes = 1 $HTML = $HTML + $K2HQuoteColor Gosub CheckVariableLength Else $HTML = $HTML + $K2HTextColor Gosub CheckVariableLength EndIf Case $K2HChar = ">" "$K2HCommand" Color r + /n ">" $HTML = $HTML + $K2HCommand + $K2HBracketColor + ">" Gosub CheckVariableLength $K2HCommand = "" $K2HCmdIsBlank = 0 If $SingleQuotes = 1 OR $DblQuotes = 1 $HTML = $HTML + $K2HQuoteColor Gosub CheckVariableLength Else $HTML = $HTML + $K2HTextColor Gosub CheckVariableLength EndIf ;Check For Operators and change color to RED if found Case $K2HChar = "(" OR $K2HChar = ")" OR $K2HChar = "[" OR $K2HChar = "]" OR $K2HChar = "{" OR $K2HChar = "}" OR $K2HChar = "/" OR $K2HChar = "\" Color r + /n "$K2HChar" $HTML = $HTML + $K2HCommand Gosub CheckVariableLength $K2HCommand = "" If ($SingleQuotes = 0) AND ($DblQuotes = 0) $HTML = $HTML + $K2HBracketColor Gosub CheckVariableLength EndIf $HTML = $HTML + $K2HChar Gosub CheckVariableLength If ($SingleQuotes = 0) AND ($DblQuotes = 0) $HTML = $HTML + $K2HTextColor Gosub CheckVariableLength EndIf If ($SingleQuotes = 1) OR ($DblQuotes = 1) $HTML = $HTML + $K2HQuoteColor Gosub CheckVariableLength EndIf If $K2HCmdIsBlank = 1 $HTML = $HTML + $K2HTextColor Gosub CheckVariableLength EndIf Case $K2HChar = "'" Color c/n; single quotes If $DblQuotes = 0 If $SingleQuotes = 0; turn ' on $HTML = $HTML + $K2HCommand + $K2HQuoteColor + $K2HChar "$K2HCommand" Color c/n "'" Gosub CheckVariableLength $K2HCommand = "" $SingleQuotes = 1 Else; turn ' off $HTML = $HTML + $K2HCommand + $K2HQuoteColor + $K2HChar "$K2HCommand" Color c/n "'" Gosub CheckVariableLength $K2HCommand = "" $SingleQuotes = 0 If $K2HCmdIsBlank = 1 $HTML = $HTML + $K2HTextColor Color m + /n Gosub CheckVariableLength Else $HTML = $HTML + $K2HTextColor Color w/n Gosub CheckVariableLength EndIf EndIf Else $HTML = $HTML + $K2HCommand + $K2HChar "$K2HChar" $K2HCommand = "" Gosub CheckVariableLength EndIf Case $K2HChar = '"' Color c/n; double quotes If $SingleQuotes = 0 If $DblQuotes = 0; turn " on $HTML = $HTML + $K2HCommand + $K2HQuoteColor + $K2HChar "$K2HCommand" Color c/n '"' Gosub CheckVariableLength $K2HCommand = "" $DblQuotes = 1 Else; turn " off $HTML = $HTML + $K2HCommand + $K2HQuoteColor + $K2HChar "$K2HCommand" Color c/n '"' Gosub CheckVariableLength $K2HCommand = "" $DblQuotes = 0 If $K2HCmdIsBlank = 1 Color m + /n Else $HTML = $HTML + $K2HTextColor Color w/n Gosub CheckVariableLength EndIf EndIf Else $HTML = $HTML + $K2HCommand + $K2HChar "$K2HChar" Gosub CheckVariableLength $K2HCommand = "" EndIf Case $K2HChar = Chr(9) $HTML = $HTML + " " " " $K2HChar = Chr(0); 1 tab = 5 spaces Gosub CheckVariableLength Case $K2HChar = "/" If SubStr($ProcessNextLine, $SpecialChar-1, 1) = "<" $HTML = $HTML + $K2HHTMLTagColor + $K2HHTMLTagColor + $K2HChar Color y/n "/" Gosub CheckVariableLength EndIf Case $K2HChar = ";" AND $SingleQuotes = 0 AND $DblQuotes = 0 ; comments, but not in quotes... $HTML = $HTML + $K2HTextColor + $K2HCommand ;Write out the previously read $K2HCommand Gosub CheckVariableLength Color w/n "$K2HCommand" $HTML = $HTML + $K2HCommentColor + SubStr($ProcessNextLine, $SpecialChar, Len($ProcessNextLine) - $SpecialChar + 1) + $K2HTextColor + "</I>" ;Write out the comment Gosub CheckVariableLength Color g/n SubStr($ProcessNextLine, $SpecialChar, Len($ProcessNextLine)-$SpecialChar + 1) $SpecialChar = Len("$ProcessNextLine") Case 1 $K2HCommand = $K2HCommand + $K2HChar If $SpecialChar = Len("$ProcessNextLine") $K2HChar = Chr(0) EndIf ; end of line EndSelect $RightChar1 = SubStr($ProcessNextLine, $SpecialChar+1, 1); Look at last character in current line; If $RightChar1 = '(' AND $K2HChar = ' ' ;Resolve Operator comming before an open parenthesis ; strip space for word check If $K2HChar = " " $K2HCommand = SubStr($K2HCommand, 1, Len($K2HCommand)-1) EndIf $Nul = CheckOperators Gosub CheckVariableLength EndIf If ($RightChar1 = "(" OR $RightChar1 = "[" OR $RightChar1 = "{");If last character equals one of these $K2HChar = "";delete the character. It will be picked up on the next line. EndIf ; space or EoL, but only in non quotes If ($K2HChar=" " OR $K2HChar=Chr(0) OR SubStr($ProcessNextLine, $SpecialChar+1, 1)=">" OR SubStr($ProcessNextLine, $SpecialChar+1, 1)="(") AND ($SingleQuotes=0) AND ($DblQuotes=0) If SubStr($ProcessNextLine, $SpecialChar + 1, 1) =">" $K2HChar=Chr(0) EndIf ; strip space for word check If $K2HChar = " " $K2HCommand = SubStr($K2HCommand, 1, Len($K2HCommand)-1) EndIf ;COMMANDS = BLUE TEXT $Nul = CheckCommands Gosub CheckVariableLength ;FUNCTIONS = BLUE TEXT $Nul = CheckFunctions Gosub CheckVariableLength ;OPERATORS = RED TEXT $Nul = CheckOperators Gosub CheckVariableLength ;HTML TAGS = YELLOW TEXT - This appears to have an odd affect on the Command Window Display ;$Nul = CheckHTMLTags ;Gosub CheckVariableLength If $K2HChar = " " $K2HCommand = $K2HCommand + " " EndIf; replace stripped space $HTML = $HTML + $K2HCommand + $K2HChar "$K2HCommand" $K2HCommand = "" EndIf ;=============== ;Test MessageBox ;$Nul = MessageBox("K2HChar = $K2HChar@CRLFK2HCommand = $K2HCommand","Test Results 1",16) ;=============== $SpecialChar = $SpecialChar + 1 Color w/n Until $SpecialChar = Len("$ProcessNextLine") + 1 EndIf $K2HCommand = "" $HTML = $HTML + "<br>$CRLF" Gosub CheckVariableLength $ProcessNextLine = ReadLine(1) ? If @ERROR = 0 $NoLinesProcessed = $NoLinesProcessed + 1 "$NoLinesProcessed " Else Color w + /n ? "$NoLinesProcessed lines processed." $Error = 1 EndIf Loop $Nul = Close(1)
;===================================== ;Wrap up the KIX Script HTML Code ;===================================== $HTML = $HTML + "</body>$CRLF</html>$CRLF" Gosub CheckVariableLength
? "Launching IE Window..." ?
;================================================ ;Dump output of KIX SCRIPT to Internet Explorer ;================================================
;===================================== ; Set properties and display form ... ;===================================== $Nul = ScreenRes $IE = CreateObject("InternetExplorer.Application") $IE.AddressBar = $False $IE.MenuBar = $True $IE.ToolBar = $True $IE.StatusBar = $False $IE.Resizable = $True $IE.Top = 1 $IE.Left = 1 $IE.Height = $ScreenHit $IE.Width = $ScreenWid $IE.TopMost = 1 $IE.Visible = $True $IE.Navigate("about:blank")
While $IE.Busy <> 0 AND @ERROR = 0 Loop
;===================================== ; Get a handle to the open document ... ;===================================== $Document = $IE.Document $Document.Open
For $Count = 0 to Ubound($MoreHTML) $Und = $MoreHTML[$Count] If NOT (($Und = "") OR ($Und = "undefined") OR ($Und = "undefined ")) $Document.Write($MoreHTML[$Count]) EndIf Next
;===================================== ;Create the HTML version of the KIX ;===================================== $Document.Write("$HTML") $Visible = 0 While $Visible = 0 $Visible = SetFocus('$Title') Loop
$IE = ""
;================================================ ;EXIT SCRIPT ;================================================ Exit
;================================================ ;SUBFUNCTIONS AND ROUTINES ;================================================ ;Check to see if the length of the $HTML variable is too long. If so, reassign it. :CheckVariableLength $VariableLength = Len("$HTML") If $VariableLength => 20000 $Step = $Step + 1 ReDim PRESERVE $MoreHTML[$Step] $MoreHTML[$Step] = $HTML $HTML = "" EndIf Return
;Obtain the System Screen Resolution ;Examples of the above SCREENRES Function: ;1: $Resolution=ScreenRes ; "your Screen are is " ; $Resolution[0] "x" $Resolution[1] ; ;2: "your screen resolution is:" ; join(screenres,"x") ; ;3: ScreenRes ; assigns variables $ScreenHit and $ScreenWid Function ScreenRes(optional $) If NOT "" + $ $ = "." EndIf For Each $ In GetObject("winmgmts:\\" + $ + "\root\cimv2").ExecQuery("Select * from Win32_DesktopMonitor",,48) $ScreenRes = $.ScreenWidth,$.ScreenHeight $ScreenHit = $.ScreenHeight $ScreenWid = $.ScreenWidth Next EndFunction
;Check for COMMAND WORDS in the script and change the color to BLUE if found Function CheckCommands For $CMDStep = 0 to Ubound($Commands) $CMD = $Commands[$CMDStep] If $K2HCommand = $CMD If $K2HChar = " " $K2HCommand = $K2HCommand + " " EndIf; replace stripped space Color b + /n "$K2HCommand" If $K2HChar = SubStr("$K2HCommand",Len("$K2HCommand")-0,1) $K2HCommand = SubStr("$K2HCommand",1,Len("$K2HCommand")-1) EndIf $HTML = $HTML + $K2HCommandColor + $K2HCommand + $K2HChar + $K2HTextColor + "</B>" $K2HCommand = "" $K2HChar = "" EndIf Next EndFunction
;Check for FUNCTION WORDS in the script and change the color to BLUE if found Function CheckFunctions For $CMDStep = 0 to Ubound($Functions) $CMD = $Functions[$CMDStep] If $K2HCommand = $CMD If $K2HChar = " " $K2HCommand = $K2HCommand + " " EndIf; replace stripped space Color b + /n "$K2HCommand" If $K2HChar = SubStr("$K2HCommand",Len("$K2HCommand")-0,1) $K2HCommand = SubStr("$K2HCommand",1,Len("$K2HCommand")-1) EndIf $HTML = $HTML + $K2HCommandColor + $K2HCommand + $K2HChar + $K2HTextColor + "</B>" $K2HCommand = "" $K2HChar = "" EndIf Next EndFunction
;Check for OPERATOR WORDS in the script and change the color to RED if found Function CheckOperators For $OperStep = 0 to Ubound($Operators) $CMD = $Operators[$OperStep] If $K2HCommand = $CMD If $K2HChar = " " $K2HCommand = $K2HCommand + " " EndIf; replace stripped space Color r + /n "$K2HCommand" $HTML = $HTML + $K2HBracketColor + $K2HCommand + $K2HChar + $K2HTextColor $K2HCommand = "" $K2HChar = "" $OperatorCheck = 1 EndIf Next EndFunction
;Check for HTML TAG WORDS in the script and change the color to YELLOW/BROWN if found Function CheckHTMLTags For $TagStep = 0 to Ubound($HTMLTags) $CMD = $HTMLTags[$TagStep] If $K2HCommand = $CMD AND (($DblQuotes = 1) OR ($K2HCmdIsBlank = 1)) If $K2HChar = " " $K2HCommand = $K2HCommand + " " EndIf; replace stripped space Color y/n "$K2HCommand" $HTML = $HTML + $K2HHTMLTagColor + $K2HCommand + $K2HChar + $K2HTextColor $K2HCommand = "" $K2HChar = "" EndIf Next EndFunction
My apologies on previously posting the "long lines".
I forgot to mention that PostPrep will do pretty much the same. This just does it through a DOS console.
Good Luck, [ 30. September 2003, 18:45: Message edited by: Dean F ]
_________________________
-Dean F.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 883 anonymous users online.
|
|
|