'ls2html: Option Public Option Explicit Option Compare Nocase %REM ls2html is a script library that contains functions to convert raw LotusScript code (in the form of a string or a file) to formatted HTML. The two main functions you'll use are ConvertFile and ConvertString (the other functions are mainly internal helper functions). These will convert a file or a string of LotusScript, using the internal default styles, which should approximate the look of code within the Notes/Domino Designer IDE. If you want to use your own custom styles, you can define your own style definition (with a StyleDef variable) and pass it in to the ConvertFileEx or ConvertStringEx functions. You can also use the last parameter of the ConvertFileEx and ConvertStringEx functions to specify the way that the resulting HTML is formatted. If you specify True or OUTPUT_CSS as the last parameter, then the HTML uses CSS styles to format the output (you can get the structure of the CSS <style> definition by calling the StyleDefToString function). If you specify False or OUTPUT_INLINE_STYLE as the last parameter, then the HTML uses inline style definitions for formatting. If you specify OUTPUT_TAGS as the last parameter, then the output is in an XML-like format, with simple tags surrounding the LotusScript statements, functions, classes, etc. Here's an example of use: Use "ls2html" '** output the LSS file using the default style Call ConvertFile("C:\myscript.lss", "C:\myscript.lss.html") '** get the default style and make some modifications, and output again Dim style As StyleDef Call GetDefaultLsStyleDef(style) style.datatype = "color: yellow;" style.quote = "color: orange;" style.class = "color: red;" Call ConvertFileEx("C:\myscript.lss", "C:\myscript2.lss.html", style, False) '** look at some of the different formatting options for a string of LotusScript rawLS$ = "Dim session as New NotesSession" Print ConvertString(rawLS$) Print ConvertStringEx(rawLS$, style, True) Print ConvertStringEx(rawLS$, style, OUTPUT_TAGS) This code may be freely used in any way you want to use it; however, if you end up using it (especially publicly), please mention where it came from. version 1.0d Julian Robichaux -- http://www.nsftools.com %END REM '** DECLARATIONS '** these are "persistent state" variables that are used to remember '** whether we're in the middle of a multi-line comment or quote Dim inCommentBlock As Integer Dim inQuoteBlock As Integer Dim quoteEndChar As String '** these are lists of words that are recognized as LotusScript keywords '** (populated in the Initialize block) Dim datatypes List As String Dim operators List As String Dim keywords List As String Dim statements List As String Dim functions List As String Dim constants List As String Dim classes List As String '** these are characters that end a word in a line of text '** (populated in the Initialize block) Dim wordEndChars As String '** options for outputting the formatted script (used in ConvertFileEx '** and ConvertLineEx Const OUTPUT_INLINE_STYLE = 0 Const OUTPUT_CSS = 1 Const OUTPUT_TAGS = 2 '** this is our custom data type that we use to store the style information '** about the different keyword types we recognize (see the default style '** generated by GetDefaultLsStyleDef for an example) Type StyleDef script As String comment As String quote As String datatype As String operator As String keyword As String statement As String function As String constant As String class As String End Type '** constants that we use for consistency throughout the script '** (if you're overly concerned about the size of your output strings, '** you can shorten the _STYLE names in order to keep the formatted '** blocks of script shorter) Const OPEN_COMMENT_BLOCK = "%REM" Const CLOSE_COMMENT_BLOCK = "%END REM" Const CLOSE_COMMENT_BLOCK2 = "%ENDREM" Const SCRIPT_STYLE = "lotusscript" Dim START_SCRIPT As String Dim END_SCRIPT As String Const COMMENT_STYLE = "ls-comment" Dim START_COMMENT As String Dim END_COMMENT As String Const QUOTE_STYLE = "ls-quote" Dim START_QUOTE As String Dim END_QUOTE As String Const DATATYPE_STYLE = "ls-datatype" Dim START_DATATYPE As String Dim END_DATATYPE As String Const OPERATOR_STYLE = "ls-operator" Dim START_OPERATOR As String Dim END_OPERATOR As String Const KEYWORD_STYLE = "ls-keyword" Dim START_KEYWORD As String Dim END_KEYWORD As String Const STATEMENT_STYLE = "ls-statement" Dim START_STATEMENT As String Dim END_STATEMENT As String Const FUNCTION_STYLE = "ls-function" Dim START_FUNCTION As String Dim END_FUNCTION As String Const CLASS_STYLE = "ls-class" Dim START_CLASS As String Dim END_CLASS As String Const CONSTANT_STYLE = "ls-constant" Dim START_CONSTANT As String Dim END_CONSTANT As String Function ConvertFile (fileName As String, outFileName As String) As Integer '** A wrapper for the ConvertFileEx function, using common settings Dim style As StyleDef Call GetDefaultLsStyleDef(style) ConvertFile = ConvertFileEx(fileName, outFileName, style, True) End Function Function ConvertFileEx (fileName As String, outFileName As String, style As StyleDef, useCSS As Integer) As Integer '** This is the function that does all the work of converting a LotusScript '** file (usually designated with an LSS extension) to HTML. You not only '** specify the input and output file names, but also the StyleDef that '** should be used (could be the result of GetDefaultLsStyleDef for the '** default style) and the output type (OUTPUT_INLINE_STYLE (False), '** OUTPUT_CSS (True), or OUTPUT_TAGS) Dim inFile As Integer Dim outFile As Integer Dim rawLS As String Dim convertedLS As String On Error Goto displayError '** try to get the input and output files inFile = Freefile() Open fileName For Input As inFile outFile = Freefile() Open outFileName For Output As outFile '** reset our globals and constants Call ResetGlobals() Call ResetStyleInfo(style, useCSS) '** as long as we're not just outputting tags (OUTPUT_TAGS), '** write some header information If Not (useCSS = OUTPUT_TAGS) Then Print #outFile, "<html><head>" Print #outFile, "<title>" & fileName & " (converted by ls2html)</title>" If (Abs(useCSS) = OUTPUT_CSS) Then Print #outFile, "<style>" & StyleDefToString(style) & "</style>" End If Print #outFile, "</head>" Print #outFile, "<body>" End If Print #outFile, START_SCRIPT '** line-by-line, convert the input file While Not Eof(inFile%) Line Input #inFile, rawLS Print #outFile, ConvertLine(rawLS) Wend '** and write some closing information when we're done Print #outFile, END_SCRIPT If Not (useCSS = OUTPUT_TAGS) Then Print #outFile, "</body>" Print #outFile, "<p><hr><center>" Print #outFile, "ls2html was brought to you by <a href='http://www.nsftools.com'>nsftools.com</a></center>" Print #outFile, "</body>" Print #outFile, "</html>" End If '** close the files Close inFile, outFile ConvertFileEx = True Exit Function displayError: Messagebox "Error " & Err & " Converting LS File: " & Error ConvertFileEx = False Exit Function End Function Function ConvertString (ls As String) As String '** A wrapper for the ConvertStringEx function, using common settings Dim style As StyleDef Call GetDefaultLsStyleDef(style) ConvertString = ConvertStringEx(ls, style, False) End Function Function ConvertStringEx (ls As String, style As StyleDef, useCSS As Integer) As String '** This is the function that does all the work of converting a LotusScript '** string to HTML. You specify the string to be converted as well as the '** StyleDef that should be used (could be the result of GetDefaultLsStyleDef '** for the default style) and the output type (OUTPUT_INLINE_STYLE (False), '** OUTPUT_CSS (True), or OUTPUT_TAGS). '** Keep in mind that adding all these formatting tags can easily increase the '** length of the original string by 5 to 10 times, so you risk exceeding the 64k '** String limit if you convert large pieces of script with this function Dim lineTerm As String Dim tempString As String Dim lastPos As Integer Dim pos As Integer On Error Goto displayError Call ResetGlobals() Call ResetStyleInfo(style, useCSS) lineTerm = GetLineTerminator(ls) ConvertStringEx = START_SCRIPT lastPos = 1 pos = Instr(lastPos, ls, lineTerm) While(pos > 0) tempString = Mid$(ls, lastPos, pos - lastPos) ConvertStringEx = ConvertStringEx & ConvertLine(tempString) & lineTerm lastPos = pos + Len(lineTerm) pos = Instr(lastPos, ls, lineTerm) Wend tempString = Mid$(ls, lastPos) ConvertStringEx = ConvertStringEx & ConvertLine(tempString) ConvertStringEx = ConvertStringEx & END_SCRIPT Exit Function displayError: Messagebox "Error " & Err & " Converting LS String: " & Error Exit Function End Function Function ConvertLine (Byval ls As String) As String '** This is the workhorse function that does all the conversion. '** It's set up to convert line-by-line, which should simplify the '** process of formatting large chunks of LotusScript. Pass in '** a line of raw Script (minus the line terminator), and get a '** formatted version of the Script in return. Dim i As Integer Dim thisChar As String Dim thisWord As String Dim fooString As String '** if this is a blank line, there's nothing to do If (Trim(ls) = "") Then 'ConvertLine = ls & "<p>" ConvertLine = ls Exit Function End If '** get rid of characters that will mess up the HTML Call ConvertInvalidHTML(ls) '** see if this starts a %REM block If (Left$(ls, Len(OPEN_COMMENT_BLOCK)) = OPEN_COMMENT_BLOCK) Then ConvertLine = ConvertLine & START_COMMENT & ls inCommentBlock = True Exit Function End If '** if we're already in a %REM block, all we have to do is check to see '* if it's over yet If (inCommentBlock) Then If ((Left$(SuperTrim(ls), Len(CLOSE_COMMENT_BLOCK)) = CLOSE_COMMENT_BLOCK) Or _ (Left$(SuperTrim(ls), Len(CLOSE_COMMENT_BLOCK2)) = CLOSE_COMMENT_BLOCK2)) Then ConvertLine = ConvertLine & ls & END_COMMENT inCommentBlock = False Else ConvertLine = ls End If Exit Function End If '** if we got this far, go through the line one character at a time (sorry '** about that) and process it For i = 1 To Len(ls) thisChar = Mid$(ls, i, 1) '** if this is a letter or a number, we can just keep going If (Instr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", thisChar) > 0) Then thisWord = thisWord & thisChar '** if we're inside a quote, all we really have to look for is the quoteEndChar Elseif inQuoteBlock Then If (thisChar = quoteEndChar) And (Mid$(ls, i, 1) <> quoteEndChar & quoteEndChar) Then '** whatever we're expecting as the terminator for the current quoted line '** doubled characters don't count inQuoteBlock = False quoteEndChar = "" ConvertLine = ConvertLine & thisWord & thisChar & END_QUOTE thisWord = "" Else '** no quoteEndChar, so keep going thisWord = thisWord & thisChar End If Else '** if we found a wordEndChar, we need to check the word we've built '** to see if it's a keyword If (Instr(wordEndChars, thisChar) > 0) Then If (Lcase(thisWord) = "rem") Then ConvertLine = ConvertLine & START_COMMENT & thisWord & Mid$(ls, i) & END_COMMENT thisWord = "" Exit For Elseif Iselement(operators(thisWord)) Then ConvertLine = ConvertLine & START_OPERATOR & thisWord & END_OPERATOR Elseif Iselement(keywords(thisWord)) Then ConvertLine = ConvertLine & START_KEYWORD & thisWord & END_KEYWORD Elseif Iselement(statements(thisWord)) Then ConvertLine = ConvertLine & START_STATEMENT & thisWord & END_STATEMENT Elseif Iselement(functions(thisWord & thisChar)) Then ConvertLine = ConvertLine & START_FUNCTION & thisWord & thisChar & END_FUNCTION thisChar = "" Elseif Iselement(functions(thisWord)) Then ConvertLine = ConvertLine & START_FUNCTION & thisWord & END_FUNCTION Elseif Iselement(constants(thisWord)) Then ConvertLine = ConvertLine & START_CONSTANT & thisWord & END_CONSTANT Elseif Iselement(classes(thisWord)) Then ConvertLine = ConvertLine & START_CLASS & thisWord & END_CLASS Elseif (Mid$(ls, i, 2) = "&#") Then '** this is a special case -- an escaped character in HTML is 5 characters, '** starting with &# and ending with a semi-colon (this is important, because '** that could be a converted &, <, or >) fooString = Mid$(ls, i, 5) If (fooString = "&#38;") Then '** &#38; is an ampersand (&) If (thisWord = "") Then ConvertLine = ConvertLine & START_OPERATOR & fooString & END_OPERATOR Else ConvertLine = ConvertLine & START_DATATYPE & thisWord & fooString & END_DATATYPE End If Elseif ((fooString = "&#60;") Or (fooString = "&#62;")) Then '** &#60; and &#62; are < and > ConvertLine = ConvertLine & thisWord & START_OPERATOR & fooString & END_OPERATOR Else ConvertLine = ConvertLine & thisWord & fooString End If i = i+4 thisChar = "" '** if we have a word that ends with a datatype character, mark it Elseif Iselement(datatypes(thisChar)) And (thisWord <> "") Then ConvertLine = ConvertLine & START_DATATYPE & thisWord & thisChar & END_DATATYPE thisChar = "" '** otherwise, we didn't find anything interesting, so we can just write the word Else ConvertLine = ConvertLine & thisWord End If '** check the single character we've got against the known LotusScript operators If (thisChar = "%") And (thisWord = "") Then '** skip this case, because "%" can start a keyword thisWord = thisChar Else If Iselement(operators(thisChar)) Then ConvertLine = ConvertLine & START_OPERATOR & thisChar & END_OPERATOR Else ConvertLine = ConvertLine & thisChar End If thisWord = "" End If '** quotation mark, pipe, or open brace starts a quoted segment Elseif (Instr("""|{", thisChar) > 0) Then inQuoteBlock = True ConvertLine = ConvertLine & thisWord & START_QUOTE & thisChar thisWord = "" If (thisChar = "{") Then quoteEndChar = "}" Else quoteEndChar = thisChar End If '** single quote starts a single-line comment Elseif (thisChar = "'") Then ConvertLine = ConvertLine & START_COMMENT & Mid$(ls, i) & END_COMMENT Exit For '** if nothing matches, just add the character to the word '** we're building and continue on Else thisWord = thisWord & thisChar End If End If Next '** don't forget the last word If Iselement(operators(thisWord)) Then ConvertLine = ConvertLine & START_OPERATOR & thisWord & END_OPERATOR Elseif Iselement(keywords(thisWord)) Then ConvertLine = ConvertLine & START_KEYWORD & thisWord & END_KEYWORD Elseif Iselement(statements(thisWord)) Then ConvertLine = ConvertLine & START_STATEMENT & thisWord & END_STATEMENT Elseif Iselement(functions(thisWord)) Then ConvertLine = ConvertLine & START_FUNCTION & thisWord & END_FUNCTION Elseif Iselement(constants(thisWord)) Then ConvertLine = ConvertLine & START_CONSTANT & thisWord & END_CONSTANT Elseif Iselement(classes(thisWord)) Then ConvertLine = ConvertLine & START_CLASS & thisWord & END_CLASS Else ConvertLine = ConvertLine & thisWord End If 'ConvertLine = ConvertLine & "<br>" End Function Sub ResetGlobals () '** reset the global state variables before starting a new conversion inCommentBlock = False inQuoteBlock = False quoteEndChar = "" End Sub Sub Initialize Call ResetGlobals '** these are all the characters that will end a word wordEndChars = " .,+-*/\^<>=()%!#@$&:" & Chr(9) '** populate the lists of LotusScript keywords (R4 and R5...I added '** the list of ND6 keywords at the end) datatypes("%") = "" 'datatypes("&") = "" '** we handle this as a special case in ConvertLine datatypes("!") = "" datatypes("#") = "" datatypes("@") = "" datatypes("$") = "" operators("+") = "" operators("-") = "" operators("*") = "" operators("/") = "" operators("\") = "" operators("=") = "" operators("<") = "" operators(">") = "" operators("(") = "" operators(")") = "" 'operators("&") = "" '** we handle this as a special case in ConvertLine operators(".") = "" operators(",") = "" operators("_") = "" operators(":") = "" operators("#") = "" operators("And") = "" operators("Eqv") = "" operators("Imp") = "" operators("Is") = "" operators("IsA") = "" operators("Like") = "" operators("Mod") = "" operators("Not") = "" operators("Or") = "" operators("Xor") = "" keywords("Access") = "" keywords("Alias") = "" keywords("Append") = "" keywords("Array") = "" keywords("As") = "" keywords("Base") = "" keywords("Binary") = "" keywords("Bind") = "" keywords("ByVal") = "" keywords("ByRef") = "" keywords("Compare") = "" keywords("Currency") = "" keywords("Declare") = "" keywords("Event") = "" keywords("Explicit") = "" keywords("Currency") = "" keywords("From") = "" keywords("GoSub") = "" keywords("GoTo") = "" keywords("Initialize") = "" keywords("Input") = "" keywords("Integer") = "" keywords("Len") = "" keywords("Lib") = "" keywords("List") = "" keywords("LMBCS") = "" keywords("LoadMsgFile") = "" keywords("Lock") = "" keywords("Long") = "" keywords("LSServer") = "" keywords("Me") = "" keywords("MsgDescription") = "" keywords("MsgText") = "" keywords("New") = "" keywords("NoCase") = "" keywords("NoPitch") = "" keywords("Option") = "" keywords("Output") = "" keywords("Pitch") = "" keywords("Preserve") = "" keywords("Private") = "" keywords("Public") = "" keywords("Published") = "" keywords("Random") = "" keywords("Read") = "" keywords("Remove") = "" keywords("Shared") = "" keywords("Single") = "" keywords("Static") = "" keywords("String") = "" keywords("Terminate") = "" keywords("Unicode") = "" keywords("Variant") = "" keywords("Write") = "" statements("Case") = "" statements("Class") = "" statements("Const") = "" statements("Dim") = "" statements("Do") = "" statements("Else") = "" statements("%Else") = "" statements("ElseIf") = "" statements("%ElseIf") = "" statements("End") = "" statements("%End") = "" statements("%ENDREM") = "" statements("Exit") = "" statements("For") = "" statements("ForAll") = "" statements("Function") = "" statements("Get") = "" statements("If") = "" statements("%If") = "" statements("Include") = "" statements("%Include") = "" statements("Let") = "" statements("Loop") = "" statements("Next") = "" statements("On") = "" statements("Property") = "" statements("ReDim") = "" statements("REM") = "" statements("%REM") = "" statements("Resume") = "" statements("Return") = "" statements("Select") = "" statements("Set") = "" statements("Step") = "" statements("Stop") = "" statements("Sub") = "" statements("Then") = "" statements("To") = "" statements("Type") = "" statements("Use") = "" statements("UseLSX") = "" statements("Wend") = "" statements("While") = "" statements("With") = "" functions("Abs") = "" functions("ACos") = "" functions("ActivateApp") = "" functions("ArrayAppend") = "" functions("ArrayGetIndex") = "" functions("ArrayReplace") = "" functions("Asc") = "" functions("ASin") = "" functions("ATn") = "" functions("ATn2") = "" functions("Beep") = "" functions("Bin") = "" functions("Bin$") = "" functions("Call") = "" functions("CCur") = "" functions("CDat") = "" functions("CDbl") = "" functions("ChDir") = "" functions("ChDrive") = "" functions("Chr") = "" functions("Chr$") = "" functions("CInt") = "" functions("CLng") = "" functions("Close") = "" functions("CodeLock") = "" functions("CodeLockCheck") = "" functions("CodeUnlock") = "" functions("Command") = "" functions("Command$") = "" functions("Cos") = "" functions("CreateLock") = "" functions("CreateObject") = "" functions("CSng") = "" functions("CStr") = "" functions("CurDir") = "" functions("CurDir$") = "" functions("CurDrive") = "" functions("CurDrive$") = "" functions("CVar") = "" functions("DataType") = "" functions("Date") = "" functions("Date$") = "" functions("DateNumber") = "" functions("DateSerial") = "" functions("DateValue") = "" functions("Day") = "" functions("Deftype") = "" functions("DefCur") = "" functions("DefDbl") = "" functions("DefInt") = "" functions("DefLng") = "" functions("DefSng") = "" functions("DefStr") = "" functions("DefVar") = "" functions("Delete") = "" functions("DestroyLock") = "" functions("Dir") = "" functions("Dir$") = "" functions("Doevents") = "" functions("Environ") = "" functions("Environ$") = "" functions("EOF") = "" functions("Erase") = "" functions("Erl") = "" functions("Err") = "" functions("Error") = "" functions("Error$") = "" functions("Evaluate") = "" functions("Execute") = "" functions("Exp") = "" functions("FileAttr") = "" functions("FileCopy") = "" functions("FileDateTime") = "" functions("FileLen") = "" functions("Fix") = "" functions("Format") = "" functions("Format$") = "" functions("Fraction") = "" functions("FreeFile") = "" functions("FullTrim") = "" functions("GetFileAttr") = "" functions("GetObject") = "" functions("GetThreadInfo") = "" functions("Hex") = "" functions("Hour") = "" functions("IMESetMode") = "" functions("IMEStatus") = "" functions("Input") = "" functions("Input$") = "" functions("InputB") = "" functions("InputB$") = "" functions("InputBP") = "" functions("InputBP$") = "" functions("InputBox") = "" functions("InputBox$") = "" functions("InStr") = "" functions("InStrB") = "" functions("InStrBP") = "" functions("InStrC") = "" functions("Int") = "" functions("IsArray") = "" functions("IsDate") = "" functions("IsDefined") = "" functions("IsElement") = "" functions("IsEmpty") = "" functions("IsList") = "" functions("IsNull") = "" functions("IsNumeric") = "" functions("IsObject") = "" functions("IsScalar") = "" functions("IsUnknown") = "" functions("Kill") = "" functions("LBound") = "" functions("LCase") = "" functions("LCase$") = "" functions("Left") = "" functions("Left$") = "" functions("LeftB") = "" functions("LeftB$") = "" functions("LeftBP") = "" functions("LeftBP$") = "" functions("LeftC") = "" functions("Len") = "" functions("LenB") = "" functions("LenBP") = "" functions("LenC") = "" functions("Line") = "" '** as in Line Input functions("ListTag") = "" functions("LOC") = "" functions("Lock") = "" functions("LOF") = "" functions("Log") = "" functions("LSet") = "" functions("LTrim") = "" functions("LTrim$") = "" functions("MessageBox") = "" functions("Mid") = "" functions("Mid$") = "" functions("MidB") = "" functions("MidB$") = "" functions("MidBP") = "" functions("MidBP$") = "" functions("MidC") = "" functions("Minute") = "" functions("MkDir") = "" functions("Month") = "" functions("MsgBox") = "" functions("Name") = "" functions("Now") = "" functions("Oct") = "" functions("Oct$") = "" functions("Open") = "" functions("Print") = "" functions("Put") = "" functions("Randomize") = "" functions("Reset") = "" functions("Right") = "" functions("Right$") = "" functions("RightB") = "" functions("RightB$") = "" functions("RightBP") = "" functions("RightBP$") = "" functions("RightC") = "" functions("RmDir") = "" functions("Rnd") = "" functions("Round") = "" functions("RSet") = "" functions("RTrim") = "" functions("RTrim$") = "" functions("Run") = "" functions("Second") = "" functions("Seek") = "" functions("SendKeys") = "" functions("SetFileAttr") = "" functions("Sgn") = "" functions("Shell") = "" functions("Sin") = "" functions("Sleep") = "" functions("Space") = "" functions("Space$") = "" functions("Spc") = "" functions("Sqr") = "" functions("Str") = "" functions("Str$") = "" functions("StrComp") = "" functions("StrCompare") = "" functions("StrConv") = "" functions("StrLeft") = "" functions("StrLeftBack") = "" functions("StrRight") = "" functions("StrRightBack") = "" functions("String") = "" functions("String$") = "" functions("Tab") = "" functions("Tan") = "" functions("Time") = "" functions("Time$") = "" functions("TimeNumber") = "" functions("TimeSerial") = "" functions("TimeValue") = "" functions("Timer") = "" functions("Today") = "" functions("Trim") = "" functions("Trim$") = "" functions("TypeName") = "" functions("UBound") = "" functions("UCase") = "" functions("UCase$") = "" functions("UChr") = "" functions("UChr$") = "" functions("Uni") = "" functions("Unlock") = "" functions("UString") = "" functions("UString$") = "" functions("Val") = "" functions("Weekday") = "" functions("Width") = "" functions("Write") = "" functions("Year") = "" functions("Yield") = "" '## Internal Constants ## constants("Empty") = "" constants("False") = "" constants("Nothing") = "" constants("Null") = "" constants("Pi") = "" constants("True") = "" '## %If Constants ## constants("WIN16") = "" constants("WIN32") = "" constants("WINNT") = "" constants("WIN95") = "" constants("WIN40") = "" constants("WINDOWS") = "" constants("HPUX") = "" constants("SOLARIS") = "" constants("UNIX") = "" constants("OS2") = "" constants("MAC") = "" constants("OLE") = "" constants("MAC68K") = "" constants("MACPPC") = "" '## Function Constants ## constants("ACLLEVEL_AUTHOR") = "" constants("ACLLEVEL_DEPOSITOR") = "" constants("ACLLEVEL_DESIGNER") = "" constants("ACLLEVEL_EDITOR") = "" constants("ACLLEVEL_MANAGER") = "" constants("ACLLEVEL_NOACCESS") = "" constants("ACLLEVEL_READER") = "" constants("ACLTYPE_MIXED_GROUP") = "" constants("ACLTYPE_PERSON") = "" constants("ACLTYPE_PERSON_GROUP") = "" constants("ACLTYPE_SERVER") = "" constants("ACLTYPE_SERVER_GROUP") = "" constants("ACLTYPE_UNSPECIFIED") = "" constants("ACTIONCD") = "" constants("ALIGN_CENTER") = "" constants("ALIGN_FULL") = "" constants("ALIGN_LEFT") = "" constants("ALIGN_NOWRAP") = "" constants("ALIGN_RIGHT") = "" constants("ASSISTANTINFO") = "" constants("ATTACHMENT") = "" constants("AUTHORS") = "" constants("COLOR_BLACK") = "" constants("COLOR_BLUE") = "" constants("COLOR_CYAN") = "" constants("COLOR_DARK_BLUE") = "" constants("COLOR_DARK_CYAN") = "" constants("COLOR_DARK_GREEN") = "" constants("COLOR_DARK_MAGENTA") = "" constants("COLOR_DARK_RED") = "" constants("COLOR_DARK_YELLOW") = "" constants("COLOR_GRAY") = "" constants("COLOR_GREEN") = "" constants("COLOR_LIGHT_GRAY") = "" constants("COLOR_MAGENTA") = "" constants("COLOR_RED") = "" constants("COLOR_WHITE") = "" constants("COLOR_YELLOW") = "" constants("DATABASE") = "" constants("DATETIMES") = "" constants("DB_REPLICATION_PRIORITY_HIGH") = "" constants("DB_REPLICATION_PRIORITY_LOW") = "" constants("DB_REPLICATION_PRIORITY_MED") = "" constants("DB_REPLICATION_PRIORITY_NOTSET") = "" constants("EFFECTS_EMBOSS") = "" constants("EFFECTS_EXTRUDE") = "" constants("EFFECTS_NONE") = "" constants("EFFECTS_SHADOW") = "" constants("EFFECTS_SUBSCRIPT") = "" constants("EFFECTS_SUPERSCRIPT") = "" constants("EMBED_ATTACHMENT") = "" constants("EMBED_OBJECT") = "" constants("EMBED_OBJECTLINK") = "" constants("EMBEDDEDOBJECT") = "" constants("ERRORITEM") = "" constants("EV_ALARM") = "" constants("EV_COMM") = "" constants("EV_MAIL") = "" constants("EV_MISC") = "" constants("EV_REPLICA") = "" constants("EV_RESOURCE") = "" constants("EV_SECURITY") = "" constants("EV_SERVER") = "" constants("EV_UNKNOWN") = "" constants("EV_UPDATE") = "" constants("FONT_COURIER") = "" constants("FONT_HELV") = "" constants("FONT_ROMAN") = "" constants("FORMULA") = "" constants("FT_DATABASE") = "" constants("FT_DATE_ASC") = "" constants("FT_DATE_DES") = "" constants("FT_FILESYSTEM") = "" constants("FT_FUZZY") = "" constants("FT_SCORES") = "" constants("FT_STEMS") = "" constants("FT_THESAURUS") = "" constants("HTML") = "" constants("ICON") = "" constants("ID_CERTIFIER") = "" constants("ID_FLAT") = "" constants("ID_HIERARCHICAL") = "" constants("LSOBJECT") = "" constants("MIME_PART") = "" constants("NAMES") = "" constants("NOTESLINKS") = "" constants("NOTEREFS") = "" constants("NOTES_DESKTOP_CLIENT") = "" constants("NOTES_FULL_CLIENT") = "" constants("NOTES_LIMITED_CLIENT") = "" constants("NUMBERS") = "" constants("OTHEROBJECT") = "" constants("OUTLINE_CLASS_DATABASE") = "" constants("OUTLINE_CLASS_DOCUMENT") = "" constants("OUTLINE_CLASS_FOLDER") = "" constants("OUTLINE_CLASS_FORM") = "" constants("OUTLINE_CLASS_FRAMESET") = "" constants("OUTLINE_CLASS_NAVIGATOR") = "" constants("OUTLINE_CLASS_PAGE") = "" constants("OUTLINE_CLASS_UNKNOWN") = "" constants("OUTLINE_CLASS_VIEW") = "" constants("OUTLINE_OTHER_FOLDERS_TYPE") = "" constants("OUTLINE_OTHER_UNKNOWN_TYPE") = "" constants("OUTLINE_OTHER_VIEWS_TYPE") = "" constants("OUTLINE_TYPE_ACTION") = "" constants("OUTLINE_TYPE_NAMEDELEMENT") = "" constants("OUTLINE_TYPE_NOTELINK") = "" constants("OUTLINE_TYPE_URL") = "" constants("PAGINATE_BEFORE") = "" constants("PAGINATE_DEFAULT") = "" constants("PAGINATE_KEEP_TOGETHER") = "" constants("PAGINATE_KEEP_WITH_NEXT") = "" constants("PICKLIST_CUSTOM") = "" constants("PICKLIST_NAMES") = "" constants("PICKLIST_RESOURCES") = "" constants("PICKLIST_ROOMS") = "" constants("PROMPT_OK") = "" constants("PROMPT_OKCANCELCOMBO") = "" constants("PROMPT_OKCANCELEDIT") = "" constants("PROMPT_OKCANCELEDITCOMBO") = "" constants("PROMPT_OKCANCELLIST") = "" constants("PROMPT_OKCANCELLISTMULT") = "" constants("PROMPT_PASSWORD") = "" constants("PROMPT_YESNO") = "" constants("PROMPT_YESNOCANCEL") = "" constants("QUERYCD") = "" constants("READERS") = "" constants("REPLICA_CANDIDATE") = "" constants("RICHTEXT") = "" constants("RULER_ONE_CENTIMETER") = "" constants("RULER_ONE_INCH") = "" constants("SEV_FAILURE") = "" constants("SEV_FATAL") = "" constants("SEV_NORMAL") = "" constants("SEV_WARNING1") = "" constants("SEV_WARNING2") = "" constants("SIGNATURE") = "" constants("SPACING_DOUBLE") = "" constants("SPACING_ONE_POINT_50") = "" constants("SPACING_SINGLE") = "" constants("STYLE_NO_CHANGE") = "" constants("TAB_CENTER") = "" constants("TAB_DECIMAL") = "" constants("TAB_LEFT") = "" constants("TAB_RIGHT") = "" constants("TARGET_ALL_DOCS") = "" constants("TARGET_ALL_DOCS_IN_VIEW") = "" constants("TARGET_NEW_DOCS") = "" constants("TARGET_NEW_OR_MODIFIED_DOCS") = "" constants("TARGET_NONE") = "" constants("TARGET_RUN_ONCE") = "" constants("TARGET_SELECTED_DOCS") = "" constants("TARGET_UNREAD_DOCS_IN_VIEW") = "" constants("TEMPLATE") = "" constants("TEMPLATE_CANDIDATE") = "" constants("TEXT") = "" constants("TRIGGER_AFTER_MAIL_DELIVERY") = "" constants("TRIGGER_BEFORE_MAIL_DELIVERY") = "" constants("TRIGGER_DOC_PASTED") = "" constants("TRIGGER_DOC_UPDATE") = "" constants("TRIGGER_MANUAL") = "" constants("TRIGGER_NONE") = "" constants("TRIGGER_SCHEDULED") = "" constants("UNAVAILABLE") = "" constants("UNKNOWN") = "" constants("USERDATA") = "" constants("USERID") = "" constants("VC_ALIGN_CENTER") = "" constants("VC_ALIGN_LEFT") = "" constants("VC_ALIGN_RIGHT") = "" constants("VC_ATTR_PARENS") = "" constants("VC_ATTR_PUNCTUATED") = "" constants("VC_ATTR_PERCENT") = "" constants("VC_FMT_ALWAYS") = "" constants("VC_FMT_CURRENCY") = "" constants("VC_FMT_DATE") = "" constants("VC_FMT_DATETIME") = "" constants("VC_FMT_FIXED") = "" constants("VC_FMT_GENERAL") = "" constants("VC_FMT_HM") = "" constants("VC_FMT_HMS") = "" constants("VC_FMT_MD") = "" constants("VC_FMT_NEVER") = "" constants("VC_FMT_SCIENTIFIC") = "" constants("VC_FMT_SOMETIMES") = "" constants("VC_FMT_TIME") = "" constants("VC_FMT_TODAYTIME") = "" constants("VC_FMT_YM") = "" constants("VC_FMT_YMD") = "" constants("VC_FMT_Y4M") = "" constants("VC_FONT_BOLD") = "" constants("VC_FONT_ITALIC") = "" constants("VC_FONT_STRIKEOUT") = "" constants("VC_FONT_UNDERLINE") = "" constants("VC_SEP_COMMA") = "" constants("VC_SEP_NEWLINE") = "" constants("VC_SEP_SEMICOLON") = "" constants("VC_SEP_SPACE") = "" constants("VIEWMAPDATA") = "" constants("VIEWMAPLAYOUT") = "" constants("VW_SPACING_DOUBLE") = "" constants("VW_SPACING_ONE_POINT_25") = "" constants("VW_SPACING_ONE_POINT_50") = "" constants("VW_SPACING_ONE_POINT_75") = "" constants("VW_SPACING_SINGLE") = "" classes("Button") = "" classes("Field") = "" classes("Navigator") = "" classes("NotesACL") = "" classes("NotesACLEntry") = "" classes("NotesAgent") = "" classes("NotesDatabase") = "" classes("NotesDateRange") = "" classes("NotesDateTime") = "" classes("NotesDbDirectory") = "" classes("NotesDocument") = "" classes("NotesDocumentCollection") = "" classes("NotesEmbeddedObject") = "" classes("NotesForm") = "" classes("NotesInternational") = "" classes("NotesItem") = "" classes("NotesLog") = "" classes("NotesMIMEEntity") = "" classes("NotesName") = "" classes("NotesNewsletter") = "" classes("NotesOutline") = "" classes("NotesOutlineEntry") = "" classes("NotesRegistration") = "" classes("NotesReplication") = "" classes("NotesRichTextItem") = "" classes("NotesRichTextParagraphStyle") = "" classes("NotesRichTextStyle") = "" classes("NotesRichTextTab") = "" classes("NotesSession") = "" classes("NotesTimer") = "" classes("NotesUIDatabase") = "" classes("NotesUIDocument") = "" classes("NotesUIView") = "" classes("NotesUIWorkspace") = "" classes("NotesView") = "" classes("NotesViewColumn") = "" classes("NotesViewEntry") = "" classes("NotesViewEntryCollection") = "" classes("NotesViewNavigator") = "" classes("ODBCConnection") = "" classes("ODBCQuery") = "" classes("ODBCResultSet") = "" '** new in Notes\Domino 6 keywords("Boolean") = "" keywords("Byte") = "" keywords("Charset") = "" functions("CBool") = "" functions("CByte") = "" functions("Implode") = "" functions("Join") = "" functions("Replace") = "" functions("Split") = "" functions("StrToken") = "" classes("JavaClass") = "" classes("JavaError") = "" classes("JavaMethod") = "" classes("JavaMethodCollection") = "" classes("JavaObject") = "" classes("JavaProperty") = "" classes("JavaPropertyCollection") = "" classes("JavaSession") = "" classes("NotesAdministrationProcesss") = "" classes("NotesColorObject") = "" classes("NotesDOMAttributeNode") = "" classes("NotesDOMCDATASectionNode") = "" classes("NotesDOMCharacterDataNode") = "" classes("NotesDOMCommentNode") = "" classes("NotesDOMDocumentFragmentNode") = "" classes("NotesDOMDocumentNode") = "" classes("NotesDOMDocumentTypeNode") = "" classes("NotesDOMElementNode") = "" classes("NotesDOMEntityNode") = "" classes("NotesDOMEntityReferenceNode") = "" classes("NotesDOMNamedNodeMap") = "" classes("NotesDOMNode") = "" classes("NotesDOMNodeList") = "" classes("NotesDOMNotationNode") = "" classes("NotesDOMParser") = "" classes("NotesDOMProcessingInstructionNode") = "" classes("NotesDOMTextNode") = "" classes("NotesDOMXMLDeclNode") = "" classes("NotesDXLExporter") = "" classes("NotesDXLImporter") = "" classes("NotesMIMEHeader") = "" classes("NotesNoteCollection") = "" classes("NotesReplicationEntry") = "" classes("NotesRichTextDocLink") = "" classes("NotesRichTextNavigator") = "" classes("NotesRichTextRange") = "" classes("NotesRichTextSelection") = "" classes("NotesRichTextTable") = "" classes("NotesSAXAttributeList") = "" classes("NotesSAXException") = "" classes("NotesSAXParser") = "" classes("NotesStream") = "" classes("NotesUIScheduler") = "" classes("NotesXMLProcessor") = "" classes("NotesXSLTransformer") = "" End Sub Sub ConvertInvalidHTML (ls As String) '** convert the characters that will give HTML problems ls = ReplaceSubstring(ls, "&", "&#38;") ls = ReplaceSubstring(ls, "<", "&#60;") ls = ReplaceSubstring(ls, ">", "&#62;") End Sub Function ReplaceSubstring (Byval theString As String, find As String, replace As String) As String Dim pos As Integer pos = Instr(theString, find) Do While (pos > 0) theString = Left$(theString, pos - 1) & replace & Mid$(theString, pos + Len(find)) pos = Instr(pos + Len(replace), theString, find) Loop ReplaceSubstring = theString End Function Function GetLineTerminator (theString As String) As String '** figure out the line terminator character in this string If (Instr(theString, Chr(13) & Chr(10)) > 0) Then GetLineTerminator = Chr(13) & Chr(10) Elseif (Instr(theString, Chr(13)) > 0) Then GetLineTerminator = Chr(13) Elseif (Instr(theString, Chr(10)) > 0) Then GetLineTerminator = Chr(10) Elseif (Instr(theString, Chr(0)) > 0) Then GetLineTerminator = Chr(0) Else '** default to Chr(10) GetLineTerminator = Chr(10) End If End Function Function StyleDefToString (style As StyleDef) As String '** convert a StyleDef to a string you can use in a <style> block '** or a CSS file Dim lineTerm As String Dim styleString As String lineTerm = Chr(13) & Chr(10) styleString = "." & SCRIPT_STYLE & " { " & style.script & " }" & lineterm styleString = styleString & "." & COMMENT_STYLE & " { " & style.comment & " }" & lineTerm styleString = styleString & "." & QUOTE_STYLE & " { " & style.quote & " }" & lineTerm styleString = styleString & "." & DATATYPE_STYLE & " { " & style.datatype & " }" & lineTerm styleString = styleString & "." & OPERATOR_STYLE & " { " & style.operator & " }" & lineTerm styleString = styleString & "." & KEYWORD_STYLE & " { " & style.keyword & " }" & lineTerm styleString = styleString & "." & STATEMENT_STYLE & " { " & style.statement & " }" & lineTerm styleString = styleString & "." & FUNCTION_STYLE & " { " & style.function & " }" & lineTerm styleString = styleString & "." & CLASS_STYLE & " { " & style.class & " }" & lineTerm styleString = styleString & "." & CONSTANT_STYLE & " { " & style.constant & " }" & lineTerm StyleDefToString = styleString End Function Sub GetDefaultLsStyleDef (style As StyleDef) '** convert the StyleDef that was passed to us to our default StyleDef style.script = "font-family: sans-serif; font-size: 9pt; color: black;" style.comment = "color: green;" style.quote = "color: black;" style.datatype = "color: black;" style.operator = "color: blue;" style.keyword = "color: blue;" style.statement = "color: blue;" style.function = "color: blue;" style.class = "color: black;" style.constant = "color: purple;" End Sub Sub ResetStyleInfo (style As StyleDef, useCSS As Integer) '** based on the useCSS parameter that was passed, set the global '** tag variables we'll use in the conversion functions If (useCSS = OUTPUT_INLINE_STYLE) Then START_SCRIPT = "<pre><div style=""" & style.script & """>" END_SCRIPT = "</div></pre>" START_COMMENT = "<font style=""" & style.comment & """>" END_COMMENT = "</font>" START_QUOTE = "<font style=""" & style.quote & """>" END_QUOTE = "</font>" START_DATATYPE = "<font style=""" & style.datatype & """>" END_DATATYPE = "</font>" START_OPERATOR = "<font style=""" & style.operator & """>" END_OPERATOR = "</font>" START_KEYWORD = "<font style=""" & style.keyword & """>" END_KEYWORD = "</font>" START_STATEMENT = "<font style=""" & style.statement & """>" END_STATEMENT = "</font>" START_FUNCTION = "<font style=""" & style.function & """>" END_FUNCTION = "</font>" START_CLASS = "<font style=""" & style.class & """>" END_CLASS = "</font>" START_CONSTANT = "<font style=""" & style.constant & """>" END_CONSTANT = "</font>" Elseif (useCSS = OUTPUT_TAGS) Then START_SCRIPT = "<" & SCRIPT_STYLE & ">" END_SCRIPT = "</" & SCRIPT_STYLE & ">" START_COMMENT = "<" & COMMENT_STYLE & ">" END_COMMENT = "</" & COMMENT_STYLE & ">" START_QUOTE = "<" & QUOTE_STYLE & ">" END_QUOTE = "</" & QUOTE_STYLE & ">" START_DATATYPE = "<" & DATATYPE_STYLE & ">" END_DATATYPE = "</" & DATATYPE_STYLE & ">" START_OPERATOR = "<" & OPERATOR_STYLE & ">" END_OPERATOR = "</" & OPERATOR_STYLE & ">" START_KEYWORD = "<" & KEYWORD_STYLE & ">" END_KEYWORD = "</" & KEYWORD_STYLE & ">" START_STATEMENT = "<" & STATEMENT_STYLE & ">" END_STATEMENT = "</" & STATEMENT_STYLE & ">" START_FUNCTION = "<" & FUNCTION_STYLE & ">" END_FUNCTION = "</" & FUNCTION_STYLE & ">" START_CLASS = "<" & CLASS_STYLE & ">" END_CLASS = "</" & CLASS_STYLE & ">" START_CONSTANT = "<" & CONSTANT_STYLE & ">" END_CONSTANT = "</" & CONSTANT_STYLE & ">" Else START_SCRIPT = "<pre><div class=" & SCRIPT_STYLE & ">" END_SCRIPT = "</div></pre>" START_COMMENT = "<font class=" & COMMENT_STYLE & ">" END_COMMENT = "</font>" START_QUOTE = "<font class=" & QUOTE_STYLE & ">" END_QUOTE = "</font>" START_DATATYPE = "<font class=" & DATATYPE_STYLE & ">" END_DATATYPE = "</font>" START_OPERATOR = "<font class=" & OPERATOR_STYLE & ">" END_OPERATOR = "</font>" START_KEYWORD = "<font class=" & KEYWORD_STYLE & ">" END_KEYWORD = "</font>" START_STATEMENT = "<font class=" & STATEMENT_STYLE & ">" END_STATEMENT = "</font>" START_FUNCTION = "<font class=" & FUNCTION_STYLE & ">" END_FUNCTION = "</font>" START_CLASS = "<font class=" & CLASS_STYLE & ">" END_CLASS = "</font>" START_CONSTANT = "<font class=" & CONSTANT_STYLE & ">" END_CONSTANT = "</font>" End If End Sub Function SuperTrim (thisString As String) As String '** remove all the leading and trailing whitespace from a string, '** convert any internal whitespace (space, tab, line terminator) '** to a space character, and change multiple whitespaces '** inside the string to a single space Dim newString As String Dim char As String Dim i As Integer Dim whitespace As String Dim lastCharWasSpace As Integer whitespace = " " & Chr(9) & Chr(0) & Chr(10) & Chr(13) lastCharWasSpace = False For i = 1 To Len(thisString) char = Mid$(thisString, i, 1) If (Instr(whitespace, char) > 0) Then If Not (lastCharWasSpace) Then newString = newString & " " End If lastCharWasSpace = True Else newString = newString & char lastCharWasSpace = False End If Next SuperTrim = Trim$(newString) End Function


ls2html was brought to you by nsftools.com