//********************************************************************** // Use HTML.utl // HTML functions // // // Create: Fri 04-09-1998 // Update: Wed 16-09-1998 - Un-commented setting of pHtmlConversionTable // // //********************************************************************** Use Strings.nui // String manipulation for VDF Use Files.nui // Utilities for handling file related stuff Use URL.nui // URL manipulation integer oGlobalHtmlAttributes# object oGlobalHtmlAttributes is an array property integer pHtmlConversionTable 0 property integer pHtmlTrimCrState 1 // Exclamation mark property string pHtmlDocType ('<'+character(33)+'DOCTYPE HTML "-/'+'/IETF/'+'/DTD HTML/'+'/EN">') property string pHtmlMT_Generator "Visual DataFlex" property string pHtmlMT_Formatter "Visual DataFlex" move self to oGlobalHtmlAttributes# end_object class cAnsiToHtml_ConversionTable is an array procedure construct_object integer img# forward send construct_object img# property string pCharacterSetName "Un-named" property string pCharacterSetID "" end_procedure function Is_cAnsiToHtml_ConversionTable returns integer function_return 1 end_function procedure set CharacterConversion integer char# string html# // By setting the item value to character(char#) we avoid having // to call that function during the character translation: set value item (item_count(self)) to (character(char#)) set value item (item_count(self)) to html# end_procedure function ConvertAnsiToHtml string str# returns string integer max# itm# string html# char# get item_count to max# move 0 to itm# while itm# lt max# get value item itm# to char# increment itm# get value item itm# to html# increment itm# move (replaces(char#,str#,html#)) to str# end function_return str# end_function end_class function html_TextToHTML global string lsValue returns string get Text_Trim lsValue to lsValue move (replaces(character(10),lsValue,"
")) to lsValue get RemoveDblBlanks lsValue to lsValue get url_InsertLinks lsValue to lsValue function_return lsValue end_function function html_TextToHTML_LeaveSpaces global string lsValue returns string get Text_Trim lsValue to lsValue move (replaces(character(10),lsValue,"
")) to lsValue get url_InsertLinks lsValue to lsValue function_return lsValue end_function desktop_section object oAnsiToHtml_Latin_1 is a cAnsiToHtml_ConversionTable set pCharacterSetName to "Latin 1" set pCharacterSetID to "iso-8859-1" set CharacterConversion 160 to " " // set CharacterConversion 161 to "¡" // set CharacterConversion 162 to "¢" // set CharacterConversion 163 to "£" // set CharacterConversion 164 to "¤" // general currency set CharacterConversion 165 to "¥" // set CharacterConversion 166 to "¦" // | set CharacterConversion 167 to "§" // set CharacterConversion 168 to "¨" // set CharacterConversion 169 to "©" // (c) set CharacterConversion 170 to "ª" // set CharacterConversion 171 to "«" // set CharacterConversion 172 to "¬" // set CharacterConversion 173 to "­" // set CharacterConversion 174 to "®" // (r) set CharacterConversion 175 to "¯" // set CharacterConversion 176 to "°" // set CharacterConversion 177 to "±" // set CharacterConversion 178 to "²" // exp(2) set CharacterConversion 179 to "³" // exp(3) set CharacterConversion 180 to "´" // set CharacterConversion 181 to "µ" // set CharacterConversion 182 to "¶" // set CharacterConversion 183 to "·" // set CharacterConversion 184 to "¸" // set CharacterConversion 185 to "¹" // set CharacterConversion 186 to "º" // set CharacterConversion 187 to "»" // set CharacterConversion 188 to "¼" // 1/4 set CharacterConversion 189 to "½" // 1/2 set CharacterConversion 190 to "¾" // 3/4 set CharacterConversion 191 to "¿" // set CharacterConversion 192 to "À" // set CharacterConversion 193 to "Á" // set CharacterConversion 194 to "Â" // set CharacterConversion 195 to "Ã" // set CharacterConversion 196 to "Ä" // set CharacterConversion 197 to "Å" // set CharacterConversion 198 to "&Aelig;" // set CharacterConversion 199 to "Ç" // set CharacterConversion 200 to "È" // set CharacterConversion 201 to "É" // set CharacterConversion 202 to "Ê" // set CharacterConversion 203 to "Ë" // set CharacterConversion 204 to "Ì" // set CharacterConversion 205 to "Í" // set CharacterConversion 206 to "Î" // set CharacterConversion 207 to "Ï" // set CharacterConversion 208 to "Ð" // set CharacterConversion 209 to "Ñ" // set CharacterConversion 210 to "Ò" // set CharacterConversion 211 to "Ó" // set CharacterConversion 212 to "Ô" // set CharacterConversion 213 to "Õ" // set CharacterConversion 214 to "Ö" // set CharacterConversion 216 to "Ø" // set CharacterConversion 217 to "Ù" // set CharacterConversion 218 to "Ú" // set CharacterConversion 219 to "Û" // set CharacterConversion 220 to "Ü" // set CharacterConversion 221 to "Ý" // set CharacterConversion 222 to "Þ" // set CharacterConversion 223 to "ß" // set CharacterConversion 224 to "à" // set CharacterConversion 225 to "á" // set CharacterConversion 226 to "â" // set CharacterConversion 227 to "ã" // set CharacterConversion 228 to "ä" // set CharacterConversion 229 to "å" // set CharacterConversion 230 to "æ" // set CharacterConversion 231 to "ç" // set CharacterConversion 232 to "è" // set CharacterConversion 233 to "é" // set CharacterConversion 234 to "ê" // set CharacterConversion 235 to "ë" // set CharacterConversion 236 to "ì" // set CharacterConversion 237 to "í" // set CharacterConversion 238 to "î" // set CharacterConversion 239 to "ï" // set CharacterConversion 240 to "ð" // set CharacterConversion 241 to "ñ" // set CharacterConversion 242 to "ò" // set CharacterConversion 243 to "ó" // set CharacterConversion 244 to "ô" // set CharacterConversion 245 to "õ" // set CharacterConversion 246 to "ö" // set CharacterConversion 248 to "ø" // set CharacterConversion 249 to "ù" // set CharacterConversion 250 to "ú" // set CharacterConversion 251 to "û" // set CharacterConversion 252 to "ü" // set CharacterConversion 253 to "ý" // set CharacterConversion 254 to "þ" // set CharacterConversion 255 to "ÿ" // end_object // oAnsiToHtml_Latin_1 end_desktop_section // Uncomment the following line in order to have the function convert ANSI // characters to native html characters. //set pHtmlConversionTable of oGlobalHtmlAttributes# to (oAnsiToHtml_Latin_1(self)) // Make the html_AnsiToHtml function cut away superfluous trailing cr/lf // characters when printing text. set pHtmlTrimCrState of oGlobalHtmlAttributes# to true // If function ConvertChar is not already defined we define it here: #IFDEF get_ConvertChar #ELSE Function ConvertChar Global integer bToAnsi String sString Returns String Pointer psString integer iVoid bIsCString Move (ascii(Right(sString,1))=0) to bIsCString If Not bISCString Append sString (character(0)) GetAddress Of sString To psString if bToAnsi Move (OEMToANSI(psString,psString)) To iVoid else Move (ANSItoOEM(psString,psString)) To iVoid Function_Return (if(bIsCString, sString, cstring(sString))) End_Function #ENDIF // This function assumes that string parameter contains ANSI characters function html_AnsiToHtml global string str# returns string move (replaces("&",str#,"&")) to str# move (replaces('"',str#,""")) to str# move (replaces("<",str#,"<")) to str# move (replaces(">",str#,">")) to str# if (pHtmlTrimCrState(oGlobalHtmlAttributes#)) ; move (Text_RemoveTrailingCr(str#)) to str# move (replaces(character(10),str#,"
")) to str# move (replaces(character(13),str#,"")) to str# move (RemoveDblBlanks(str#)) to str# if (pHtmlConversionTable(oGlobalHtmlAttributes#)) ; get ConvertAnsiToHtml of (pHtmlConversionTable(oGlobalHtmlAttributes#)) str# to str# function_return str# end_function // This function is identical to html_AnsiToHtml except that it // assumes the parameter to be OEM characters. function html_DfToHtml global string str# returns string function_return (html_AnsiToHtml(ConvertChar(1,str#))) end_function // This is identical to the html_DfToHtml function except that it will // never return the empty string. Where html_DfToHtml would return the // empty string this function will return a 'non breaking space'. You // may want to use this function when writing table data since it will // ensure that the cells are appearing even if their content is empty. function html_DfToHtmlTable global string str# returns string string rval# move (html_AnsiToHtml(ConvertChar(1,str#))) to rval# if rval# eq "" move " " to rval# function_return rval# end_function External_Function HtmlShellExecute "ShellExecuteA" SHELL32.DLL ; handle hwnd# String lpszOp# String lpszFile# String lpszParams# ; String lpszDir# integer FsShowCmd# returns integer // This may be used to start any kind of document. Not just html docs. procedure html_StartDoc global string doc# integer grb# handle scrhDC# string dir# move (GetDesktopWindow()) to scrhDC# // Defined in WinUser.pkg // We assume that the document is in a directory along DFPATH or that // the directory path is part of the doc name: get SEQ_ExtractPathFromFileName doc# to dir# // Is a path specified? if dir# eq "" get SEQ_FindFileAlongDFPath doc# to dir# else move "" to dir# // Parameters Directory move (HtmlShellExecute(scrhDC#,"Open",doc#,"",dir#,1)) to grb# end_procedure procedure html_WriteHeader global integer channel# string title# writeln channel channel# (pHtmlDocType(oGlobalHtmlAttributes#)) writeln '' writeln '' writeln (' '+html_DfToHtmlTable(title#)+'') //writeln ' ' writeln (' ') writeln '' end_procedure