[Javascript] While statement array losing data

Tim Lewis twlewis at softhome.net
Thu May 17 07:21:51 CDT 2007


This list is great!  I come from a VB background, and learning JS.  I have
a routine in which I load data through DAO into an array.  My problem is
that as soon as the program leaves my While statement, the data in the
array disappears.  I have studied and studied my code, but I cannot find a
reason.  I am very thankful for any help on this.

Tim
My code is:
<html><head>
<script language="JavaScript">
<!--
function Main() {
var sDB="C:\\Temp\\LOGDB.MDB";
var objConnection = new ActiveXObject("DAO.DBEngine.36");
var objRecordSet = objConnection.workspaces(0).OpenDatabase(sDB);
var iResultCount=0;iCount=0;
var sLineIn = new Array();
var sTransCount="";
var SEARCHRESULT;
sSearchCommand = "SELECT * FROM HL7_Segments WHERE SegmentLineData LIKE
'*MSH*'";
SEARCHRESULT = objRecordSet.OpenRecordset(sSearchCommand)
SEARCHRESULT.MoveFirst();
while (! SEARCHRESULT.EOF) {
        sTransCount = SEARCHRESULT("TransactionCount");
        sLineIn[iResultCount] = sTransCount;
        var msg=confirm("iResultLine for "+iResultCount+" is
"+sLineIn[iResultCount]); if (msg==false) {return;};
        iResultCount++;
        SEARCHRESULT.MoveNext(); }
for (var iCount=0;iCount<iResultCount;iCount++) {
var msg=confirm("Final iResultLine for "+iCount+" is "+sLineIn[iCount]);
if (msg==false) {return;}; }
objRecordSet.Close;
objRecordSet = Nothing;
objConnection = Nothing;
}
-->
</script>
</head><body><form>
<input type="button" value="Click me!" onclick="Main()">
</form></body></html>





More information about the Javascript mailing list