
July 19th, 2005, 01:43 PM
| | | How to write any string
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> </td></tr>\';\n');
Response.write(' vHtmlString += \" <tr><td>' +
Server.HTMLEncode(AErrorMsg) + '</td></tr>\";\n');
Response.write(' vHtmlString += \' <tr><td> </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> </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>0,sum(Z10,AB10,AD10,AF10,AH10,A J10,AL10,AN10,AP10,AR10,AT
10,AV10,AX10,AZ10,BB10,BD10,BF10,BH10,BJ10,BL10,BN 10,BP10,BR10,BT10,BV10,BX1
0,BZ10,CB10,CD10,CF10,CH10,CJ10,CL10,CN10,CP10,CR1 0,CT10,CV10,CX10,CZ10,DB10
,DD10)/C10,0)'))</td></tr>";
vHtmlString += ' <tr><td> </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>0,sum", the '>' symbol in the error
message is being converted to '>' so I'm not sure exactly what HTMLEncode
is doing (or not doing).
tia,
Bob M.. | 
July 19th, 2005, 01:45 PM
| | | Re: How to write any string
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..
"Bob Murdoch" <ram_re_move_5@erols.com> wrote in message
news:O1RwgjiTEHA.2416@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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[/color]
to[color=blue]
> 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[/color]
with[color=blue]
> 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[/color]
populates/unhides[color=blue]
> 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> </td></tr>\';\n');
> Response.write(' vHtmlString += \" <tr><td>' +
> Server.HTMLEncode(AErrorMsg) + '</td></tr>\";\n');
> Response.write(' vHtmlString += \' <tr><td> </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> </td></tr>';
> vHtmlString += " <tr><td>Error - Error: The report could not be[/color]
created.[color=blue]
>
> (Error writing formula - Invalid formula syntax (Row=10, Col=111,
>[/color]
Formula='if(C10>0,sum(Z10,AB10,AD10,AF10,AH10,A J10,AL10,AN10,AP10,AR10,AT[color=blue]
>[/color]
10,AV10,AX10,AZ10,BB10,BD10,BF10,BH10,BJ10,BL10,BN 10,BP10,BR10,BT10,BV10,BX1[color=blue]
>[/color]
0,BZ10,CB10,CD10,CF10,CH10,CJ10,CL10,CN10,CP10,CR1 0,CT10,CV10,CX10,CZ10,DB10[color=blue]
> ,DD10)/C10,0)'))</td></tr>";
> vHtmlString += ' <tr><td> </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[/color]
syntax[color=blue]
> (Row=10, Col=111, Formula='if(C10>0,sum", the '>' symbol in the error
> message is being converted to '>' so I'm not sure exactly what[/color]
HTMLEncode[color=blue]
> is doing (or not doing).
>
> tia,
>
> Bob M..
>
>[/color] |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|