How to write any string

B

Bob Murdoch

I have a situation where I call a COM object from ASP that is supposed to
create a file. On occasion, especially during development, the output of
the COM function is an error string rather than the file name. I'd like to
display this error string, regardless of it's contents. Right now,
depending on the error string, I get an error message about missing a
semicolon or some such. I've tried using Encode and Server.HTMLEncode with
no luck.

The ASP code contains two <DIV>'s. The first one is visible and shows an
animated progress bar. The second one is hidden initially. Once the COM
function has returned, the page hides the first <DIV> and populates/unhides
a second <DIV> that either contains the results or an error message.

The ASP code looks like this:

function WriteErrorTable(AErrorMsg)
{
Response.write('\n<script language="javascript"
type="text/javascript">\n');
Response.write('function GetDivContent()\n');
Response.write('{\n');
Response.write(' var vHtmlString = \'\';\n');
Response.write(' vHtmlString += \'<table border="0" cellpadding="2"
cellspacing="1">\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;"><b>An error occurred while creating the
report</b></td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \" <tr><td>' +
Server.HTMLEncode(AErrorMsg) + '</td></tr>\";\n');
Response.write(' vHtmlString += \' <tr><td>&nbsp;</td></tr>\';\n');
Response.write(' vHtmlString += \' <tr><td align="center"
style="color: Red;">Please contact your system
administrator</td></tr>\';\n');
Response.write(' vHtmlString += \'</table>\';\n');
Response.write(' return(vHtmlString);\n');
Response.write('}\n');
Response.write('</script>\n');
}

The source of the page causing the error is:

<script language="javascript" type="text/javascript">
function GetDivContent()
{
var vHtmlString = '';
vHtmlString += '<table border="0" cellpadding="2" cellspacing="1">';
vHtmlString += ' <tr><td align="center" style="color: Red;"><b>An error
occurred while creating the report</b></td></tr>';
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += " <tr><td>Error - Error: The report could not be created.

(Error writing formula - Invalid formula syntax (Row=10, Col=111,
Formula='if(C10&gt;0,sum(Z10,AB10,AD10,AF10,AH10,AJ10,AL10,AN10,AP10,AR10,AT
10,AV10,AX10,AZ10,BB10,BD10,BF10,BH10,BJ10,BL10,BN10,BP10,BR10,BT10,BV10,BX1
0,BZ10,CB10,CD10,CF10,CH10,CJ10,CL10,CN10,CP10,CR10,CT10,CV10,CX10,CZ10,DB10
,DD10)/C10,0)'))</td></tr>";
vHtmlString += ' <tr><td>&nbsp;</td></tr>';
vHtmlString += ' <tr><td align="center" style="color: Red;">Please
contact your system administrator</td></tr>';
vHtmlString += '</table>';
return(vHtmlString);
}
</script>


As you can see on the line "(Error writing formula - Invalid formula syntax
(Row=10, Col=111, Formula='if(C10&gt;0,sum", the '>' symbol in the error
message is being converted to '&gt;' so I'm not sure exactly what HTMLEncode
is doing (or not doing).

tia,

Bob M..
 
B

Bob Murdoch

I finally wound up replacing all CR and LF in the string, and stuck it in a
read-only text area. Works like a charm.

Bob M..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,160
Latest member
CollinStri
Top