Click to See Complete Forum and Search --> : Help with passing a function


wwcbill
04-08-2003, 12:23 AM
Dear Sirs;
I am having a hard time trying to code a function. This what I am trying to do, but I can not get it to work. I am having a problem with my "WHILE" statemnet
My code is as follows:
-------------------------------------------------------------

<HTML>
<HEAD>
<TITLE>Title of your page</TITLE>
<script LANGUAGE="javascript">
function testFunc(testdata) {
document.write('<tr><td align=right>My Message:</td><td> <input value='+ testdata +' size="40"></td></tr>');
}
</script>
</HEAD>
<BODY>
<table border="1">
<script Language="JavaScript">
var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");
var myInputTextStream = myFileSysObj.OpenTextFile("c:\\testmail",1,true);
while(!!myInputTextStream.AtEndOfStream){
testFunc(testdata) = (myInputTextStream.ReadLine());
}
// Close the input
myInputTextStream.Close();
</script>
</table>
</BODY>
</HTML>

Jona
04-08-2003, 12:28 AM
You should only have one exclamation point on your while() loop:

while(!myInputTextStream.AtEndOfStream){

wwcbill
04-08-2003, 01:03 AM
Thanks for pointing out my coding error, but this is not the reason I can not pass anything from my function. Can you help. please.

Jona
04-08-2003, 01:09 AM
Perhaps:

testFunc(testdata) = (myInputTextStream.ReadLine());

should be:

testdata = myInputTextStream.ReadLine();
testFunc(testdata);

OR

testFunc(myInputTextStream.ReadLine());

wwcbill
04-08-2003, 04:35 PM
Dear Jona;
I have incorperated the changes you suggested into my code. It still does not work. Could you please copy my code and run it. Please tell me what I am doing wrong. It does not matter what you put into the file on your hard drive. Help help help!
_______________________________________________________
<HTML>
<HEAD>
<TITLE>Title of your page</TITLE>
<script LANGUAGE="javascript">
function testFunc(testdata) {
document.write('<tr><td align=right>My Message:</td><td> <input value='+ testdata +' size="40"></td></tr>');
}
</script>
</HEAD>
<BODY>
<table border="1">
<script Language="JavaScript">
var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");
var myInputTextStream = myFileSysObj.OpenTextFile("c:\\testmail",1,true);
while(!myInputTextStream.AtEndOfStream){
testdata = myInputTextStream.ReadLine();
testFunc(testdata);
// testFunc(myInputTextStream.ReadLine());
}
// Close the input
myInputTextStream.Close();
</script>
</table>
</BODY>
</HTML>

Jona
04-08-2003, 04:38 PM
The error: "Automation server can't create object."

The solution: Find a server that can.

wwcbill
04-08-2003, 04:52 PM
Jona;
I do not get that error. I also do not know the type of server to look for. How do I determine the sever type.

Jona
04-08-2003, 04:54 PM
On second thought... Javascript is client-side, so it shouldn't matter about the server at all. So... I don't know why, but that is the only error I get. Can you tell me the error you're getting?

wwcbill
04-08-2003, 04:59 PM
Actually I am not getting any error at all. I only get an error indicating that I have reached the end of the file. No out put at all.

Jona
04-08-2003, 05:08 PM
Oh, I see. Okay, in that case, try using alert(testdata) to see what you get... That's all I can say.

Scriptage
04-08-2003, 05:20 PM
works fine for me.....
everything works fine at my end....therefore...
the coding is fine...
it must be something to do with the file.
Are you running it from a server? If so you may not be able to access the client computer (haven't had much experience with activeX)...
Check that the file / filename are correct...that is the only thing I can suggest..
there is absolutely nothing wrong with the code

wwcbill
04-08-2003, 05:26 PM
Thank you for trying to help. But It apperars to be that this statement is the one causing the problem.
"while(!myInputTextStream.AtEndOfStream)". I can not understand why. I have put test statements before and after this statement. "document.write("1"), and document.write("2"). I only get a response of "1" nerver "2". If anyone else can understand what I have done wrong, could you please help. Thank you!

wwcbill
04-08-2003, 05:34 PM
Scriptage;
Thank you for testing my script. It looks as though there is something wrong with my operating system set up. I can not get past the "WHILE" statement. It indicates end of file before am actually at the end. I don"t know what to do about it, but thank you.