Jump to content

help please!!!!urgent.. about content of text file....


fbolavidez
 Share

Recommended Posts

Gudpm!Somebody help me about my problem in text files..whats wrong in my code?how can i know the content on the text file, whether 0 or 1?if the files contain 0, it will alert('File contain zero') else alert('File doesn't contain any zero') ?Thanks for any help....:-)here is my code:

function ReadFile(objRow){ 	 var filename = 'c:\\B64210189 0001.txt'	 		  var fso, ForReading; 		  ForReading = 1; 		  fso = new ActiveXObject('Scripting.FileSystemObject'); 		  file = fso.OpenTextFile(filename, ForReading, false); 		  var fn = file.ReadAll(); 		  if(fn != "1" && fn == "0")// if the file contain zero..		  {			  alert('File contains zero!')			  rowColor = 'red';		  }		  else		  {			  alert('File doesnt contain zero')			  rowColor = 'green';		  }			objRow.bgColor = rowColor;					  file.Close();	  }

Link to comment
Share on other sites

Your conditional says if it has a zero AND doesn't contain one where both statements must be true to run that code. So maybe try replacing && with ||, or create an if (fn=="0") { // some code}else if (fn=="1") { // some code}Hope this helps.
hi! i try the code but it's not working too.the content of the file is here:1110111111 1111101111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111101111 1111111111 11111111111111110111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111101111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111110111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111101111 11111111111111111111 1111111111 1111111111 1111111111 11111111111111111111 1111111111 1111111111 1111111111 1111111111then when i run my program it should alert('File contains zero!').any sample code to run this? thanks....
Link to comment
Share on other sites

An array doesn't have a value, it is a collection of values. If you want to pass a complex data structure like an array between languages you will need to serialize it so that both languages can understand it. JSP might be able to serialize an array that Javascript can unserialize and understand, but if not then you will need to build your own serializer in JSP and your own unserializer in Javascript to encode and decode the array.

Link to comment
Share on other sites

An array doesn't have a value, it is a collection of values. If you want to pass a complex data structure like an array between languages you will need to serialize it so that both languages can understand it. JSP might be able to serialize an array that Javascript can unserialize and understand, but if not then you will need to build your own serializer in JSP and your own unserializer in Javascript to encode and decode the array.
thanks! how can i do that? any sample code..thanks a lot for your help! :-)
Link to comment
Share on other sites

Learn about serialization here:http://en.wikipedia.org/wiki/SerializationIf the languages don't share an interface that you can use, then you'll have to think about a format that you can convert the array to in one language where you can convert it back to an array in another language. You can turn the array into a comma-separated list of values, for example, assuming that you can guarantee a comma won't appear in any element. If the array is multi-dimensional, then the format for representing it will become a lot more complex.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...