Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft JScript runtime (0x800A1391)

Status
Not open for further replies.

haneen97

Programmer
Dec 10, 2002
280
US
Hi,
I am migrating a web page that used to run through an application so it would run through another web page. I got an error (Microsoft JScript runtime (0x800A1391)
'text' is undefined) when I view the report page.

The parameter page is coded like this:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Infographics</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">

</script>
</head>

<body>
<%
dim qs, StartDate, EndDate, DeptList, DB,USR,PWD
DB="xxxxx"
USR="yyyyy"
PWD="zzzzz"

DeptList = "'00000562','00000061','00000024','00000232','00000321','00000035','00000030','00000064','00000063'"

%>

<form name="frmOpenRpt" method="post" id="frmOpenRpt" action="xStFInfographic.asp" >
<p align="center"> Date from:
<input name="txtDateFrom" type="text" id="txtDateFrom">
Date To:
<input name="txtDateTo" type="text" id="txtDateTo">
<input type="submit" name="Submit" value="View Report" onClick="

">
</p>
<p align="center">Departments:
<textarea name="txtDepts" id="txtDepts"><%=DeptList%></textarea>
</p>
<p align="center">Database:
<input name="txtDB" type="text" id="txtDB" value='<%=DB%>'>
</p>
<p align="center">User Name:
<input name="txtUSR" type="text" id="txtUSR" value='<%=USR%>'>
</p>
<p align="center"> Password:
<input name="txtPWD" type="password" id="txtPWD" value='<%=PWD%>'>
</p>
<p align="center">&nbsp; </p>
</form>
</body>
</html>



*****************************
The report page is coded like this:
**********************************


<%@ Language="JavaScript" %>
<%try{
Response.Write(
"<html>\r" +
" <head>\r" +
" <title>Active Patients by Department for Infographic</title>");
%>

<!--#include file="ServerFunctions.js"-->
<!--#include file="xStFInfographic.js"-->
<%
/* -------------------- Create text file ----------------------------- */
var TristateFalse = 0;
var ForWriting = 2;
myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
myActiveXObject.CreateTextFile("T:\\infographic.txt");
file = myActiveXObject.GetFile("T:\\infographic.txt");
text = file.OpenAsTextStream(ForWriting, TristateFalse);
/* -------------------- End Create text file ------------------------- */
Response.Write("\r" +
" <link media='print' rel='stylesheet' type='text/css' href='RptPrint.css'>\r" +
" <link media='screen' rel='stylesheet' type='text/css' href='RptScreen.css'>\r" +
" </head>\r" +
" <body>\r");
/* -------------------- Variables that will be passed in. --------------- */
var ReportName = 'Infographic';
// var FromDate = Request('StartDate' );
//var ToDate = Request('EndDate' );
var FromDate = Request.Form('txtDateFrom' );
var ToDate = Request.Form('txtDateTo' );
//var DepList = Request('Departments');
var DepList = Request.Form('txtDepts');
var IsGUI = Request('GUI' ); var IsGUIYes = 1;
var IsScreen = Request('Screen' ); var IsScreenYes = 1;
var PageBreaks = Request('PageBreaks' );
var PgBrByFac = 0;
var PgBrByDiv = 1;
var PgBrByDep = 2;
/* -------------------- Calculated Variables. --------------------------- */
var ScreenPage = 0;
var RptDateRange = GetRptDateRange(FromDate, ToDate);
dbConnect();
row = Conn.Execute(GetRptDefaults);
var ChainName = row('FACNAME').Value;
row=Conn.Execute(GetMainSQL());
/* -------------------- Tracker Variables ------------------------------- */
var StoredFac = '';
var StoredDiv = '';
var StoredDep = '';
var StoredPat = '';
var StoredDay = '';
if (row.EOF)
{Response.Write(NoData());}
else
{
var ThisFac = row('KEY_FACILI').Value;
var ThisDiv = row('KEY_DIVISI').Value;
var ThisDep = row('KEY_DEPART').Value;
var ThisPat = row('KEY_PATIEN').Value;
var ThisDay = row('KEY_DATE' ).Value;
};
/* -------------------- Beginning of data loop -------------------------- */
while (!row.EOF)
{
if (IsNewFac() || IsNewDivWPgB() || IsNewDepWPgB() )
{
if (ShouldPrintHeadersAndFooters() )
{
Response.Write(
" <!-------------------- Report Header -------------------------------------->\r" +
" <table class='TopTable' cols='50' width='100%'>\r" +
" <tr>\r" +
" <td colspan='20' width=' 40%' class='RptSubtitleLeft' ></td>\r" +
" <td colspan='30' width=' 60%' class='RptSubtitleRight'></td>\r" +
" </tr>\r" +
" <tr>\r" +
" <td colspan='50' width='100%' class='RptTitle'>\r" +
" Active Patients by Department - Infographic\r" +
" </td>\r" +
" </tr>\r" +
" <tr>\r" +
" <td colspan='50' width='100%' class='RptTitleLine'>\r" +
" <HR Align='center' noshade color='black'>\r" +
" </td>\r" +
" </tr>\r" +
" <tr>\r" +
" <td colspan='20' width=' 40%' class='RptSubtitleLeft'>\r" +
" " + ChainName + "\r" +
" </td>\r" +
" <td colspan='30' width=' 60%' class='RptSubtitleRight'>\r" +
" " + RptDateRange + "\r" +
" </td>\r" +
" </tr>\r" +
" </table>\r");
};
Response.Write(
" <!-------------------- Body Table Setup ----------------------------------->\r" +
" <table class='TableWVerticalLines' cols='50' width='100%'\r" +
" cellspacing='0' cellpadding='0'>\r" +
" <tr class='RptFont4x6N'>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'></td> <td width='2%'></td>\r" +
" <td width='2%'></td> <td width='2%'>&nbsp;</td>\r" +
" </tr>\r" +
" <!-------------------- Facility Header ---------------------------------->\r" +
" <tr class='RptFont11x14B'>\r" +
" <td colspan=' 8' width='16%' align='right'>Facility:&nbsp;&nbsp;</td>\r" +
" <td colspan='42' width='84%'>\r" +
" " + row('FACILITY').Value + "\r" +
" </td>\r" +
" </tr>\r");
};

/* -------------------- Spacer ---------------------------------------- */
if (PageBreaks==PgBrByFac && !IsNewFac() && (IsNewDiv() || IsNewDep() ) )
{
Response.Write(
" <!------------------- Spacer -------------------------------------------->\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r");
};

if (PageBreaks==PgBrByDiv && !IsNewFac() && !IsNewDiv() && IsNewDep() )
{
Response.Write(
" <!------------------- Spacer -------------------------------------------->\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r");
};

/* -------------------- Division Header ------------------------------- */
if (IsNewFac() || IsNewDiv() || IsNewDepWPgB() )
{
Response.Write(
" <!-------------------- Division Header ---------------------------------->\r" +
" <tr class='RptFont11x14B'>\r" +
" <td colspan=' 8' width='16%' align='right'>Division:&nbsp;&nbsp;</td>\r" +
" <td colspan='42' width='84%'>\r" +
" " + getColumn('DIVISION') + "\r" +
" </td>\r" +
" </tr>\r");
};

/* -------------------- Department Header ----------------------------- */
var deptname = getColumn('DEPARTMENT');
if (deptname == "RADIOLOGY SERVICES") {
deptname = "COMPREHENSIVE BREAST CENTER"
}
if (IsNewFac() || IsNewDiv() || IsNewDep() )
{
Response.Write(
" <!-------------------- Department Header -------------------------------->\r" +
" <tr class='RptFont11x14B'>\r" +
" <td colspan=' 8' width='16%' align='right'>Department:&nbsp;&nbsp;</td>\r" +
" <td colspan='42' width='84%'>\r" +
" " + deptname + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r" +
" <!-------------------- Row Header --------------------------------------->\r" +
" <tr class='RptFont9x12BU'>\r" +
" <td colspan='50' width='100%'>&nbsp;</td>\r" +
" </tr>\r");
};

/* -------------------- Row Data -------------------------------------- */
var ApptDate = unEmlDate(getColumn('KEY_DATE')).format('MM/DD/YYYY');
var ApptTime = formatTime(makeTimeFromStr(getColumn('KEY_TIME')));
var pataddr = getColumn('pataddr1') + " " + getColumn('pataddr2');
if (getColumn('FRESOURCE') != "95 PET") {
if (getColumn('FRESOURCE') != "STEREOTACTIC") {
if (getColumn('PROCNAME') != "COLON/GASTRO OR WITH VIDEO SCOPE") {
Response.Write(
" <!-------------------- Row Data ----------------------------------------->\r" +
" <tr class='RptFont9x12N' valign='top'>\r" +
" <td colspan='6' width='12%'>\r" +
" " + getColumn('patfirstname') + "\r" +
" </td>\r" +
" <td colspan='44' width='88%'>\r" +
" " + getColumn('patlastname') + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont9x12N' valign='top'>\r" +
" <td colspan=' 50' width='100%'>\r" +
" " + pataddr + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont9x12N' valign='top'>\r" +
" <td colspan='15' width='30%'>\r" +
" " + getColumn('patcity' ) + "\r" +
" </td>\r" +
" <td colspan=' 5' width='10%'>\r" +
" " + getColumn('patstate' ) + "\r" +
" </td>\r" +
" <td colspan='30' width='60%'>\r" +
" " + getColumn('patzipcode' ) + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r" +
" <tr class='RptFont9x12N' valign='top'>\r" +
" <td colspan='6' width='12%'>\r" +
" " + ApptDate + "\r" +
" </td>\r" +
" <td colspan='9' width='18%'>\r" +
" " + ApptTime + "\r" +
" </td>\r" +
" <td colspan='25' width='50%'>\r" +
" " + deptname + "\r" +
" </td>\r" +
" <td colspan='25' width='50%'>\r" +
" " + getColumn('FRESOURCE') + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont9x12N' valign='top'>\r" +
" <td colspan='15' width='30%'>&nbsp;</td>\r" +
" <td colspan='35' width='70%'>\r" +
" " + getColumn('PROCNAME' ) + "\r" +
" </td>\r" +
" </tr>\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r" +
" <tr class='RptFont4x6N'><td colspan='50'>&nbsp;</td></tr>\r");
}
}
}
/* -------------------- Write text file ------------------------------ */
if (getColumn('FRESOURCE') != "95 PET") {
if (getColumn('FRESOURCE') != "STEREOTACTIC") {
if (getColumn('PROCNAME') != "COLON/GASTRO OR WITH VIDEO SCOPE") {

var namestr = '"' + getColumn('patfirstname') + ' ' + getColumn('patlastname') + '","';
var addrstr = pataddr + '","' + getColumn('patcity') + '","' + getColumn('patstate') + '","' + getColumn('patzipcode') + '","';
var datestr = ApptDate + ' ' + ApptTime + '","' + getColumn('FRESOURCE') + '","' + getColumn('PROCNAME') + '","' + deptname + '"';
var textstr = namestr + addrstr + datestr;
text.Write(textstr);
text.Write("\n");
}
}
}

/* -------------------- Update Tracker Variables ---------------------- */
UpdateStoredVariables();
row.MoveNext();
if (!row.EOF){UpdateThisVariables();};
/* -------------------- Page Footer ----------------------------------- */
if (row.EOF || IsNewFac() || IsNewDivWPgB() || IsNewDepWPgB() )
{
Response.Write(" </table>\r");

if (ShouldPrintHeadersAndFooters() )
{
ScreenPage++;
Response.Write(
" <!-------------------- Page Footer ---------------------------------------->\r" +
" <table class='RptPgFooter' cols='50' width='100'>\r" +
" <tr>\r" +
" <td colspan='37' width='74%'>\r" +
" Printed on: " + GetPrintDate() + "\r" +
" </td>\r" +
" <td colspan='13' width='26%' align='right'>\r" +
" Page " + ScreenPage + "\r" +
" </td>\r" +
" </tr>\r" +
" </table>&nbsp;\r");
}
else
{if (!row.EOF){Response.Write("<Page>\r");};};
};
};
};
catch(e)
{Response.Write(ReturnErrMsg(e.number & 0xFFFF));};
finally
{CleanUp();};
text.Close();
Response.Write(
" </body>\r" +
"</html>\r");
%>


I can't see anything wrong with the text file. Actually it is working fine in the other application.

Please help.

Thanks a lot

Mo
 
Sorry,
Line 286
Statement: text.Close();
The fifth line from the bottom.

Mo
 
Is it possible that you are getting rid of text inside your CleanUp() ??

Also, I don't know if this is the problem but the first thing that jumped out at me was if an error happens in the part that I have marked in [red]red[/red] below then it will hit the text.Close() before text var is defined.
Code:
try
{
 [red]// some vars and stuff here[/red]
 text = blah blah;
}
catch (e)
{ // blah blah }
finally
{ // blah blah }

text.Close();
 
I don't think it is theh Cleanup ()

This is all what is in ClenaUp

function CleanUp()
{
if (row != null){row.Close;};
if (Conn != null){Conn.Close;};
};

I will keep looking in the try clause.

Mo
 
Does the text file actually get written?

If not, is it possible that there is different security in the other app where it is working? Like for example if your app is set up to use the default IUSR_MachineName account but the account doesn't have permission to create the file?
 
It may be so. I have to study the process with my DBA and Network Amin and let you know.

Mo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top