Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/05/2011, 01:22
ZeeKee
 
Fecha de Ingreso: octubre-2004
Mensajes: 9
Antigüedad: 19 años, 7 meses
Puntos: 0
Respuesta: Buscar una cadena de texto en un archivo txt y devolver un resultado.

Hola!

Muchas gracias por tu respuesta!


He podido cambiar algunas cosas y funciona genial!

Pero te comento, el objetivo es buscar diferentes cadenas de texto por ejemplo

'hymenaeos', 'otra palabra', '2353'

en todos y cada uno de los archivos 'Testx', 'Test2', 'Test3'

ahora mismo hace las busquedas de este modo, busca 'hymenaeos' en el Testx, otra palabra en el test2, 2353, en test 3, y asi sucesivamente.

Me podriais ayudar, saludos!

Cita:
<html>
<head>
<title>searching</title>
<script>
var text, NumFiles, Get, Count=0, Extend='.txt';
var Review = {Files:['magamgg2'],
Content:['TrafServiceWatch', 'Windows', '2353']};

function INITIALIZED(){var a=document.getElementById("Console");a.value="-> INIZIALIZANDO... \n";NumFiles=Review.Files.length;a.value+="-> Cargando y preparando los archivos de registro... Espere un momento por favor... \n";Get=setInterval("GET_FILE();",1E3)}function GET_FILE(){var a=document.getElementById("textReader");Count>=Num Files?clearInterval(Get):(a.src=Review.Files[Count]+Extend,setTimeout("text = getContent();",500))}
function getContent(){var a=document.getElementById("Console"),b=document.ge tElementById("Debbugger");a.value=a.value+"-> Abriendo Archivo "+Review.Files[Count]+" \n";var c=b.innerHTML+" <br />";a.value=a.value+'-> Buscando Coincidencia <strong>"'+Review.Content[Count]+'"</strong> dentro del archivo '+Review.Files[Count]+Extend+"... \n";var f,d=document.getElementById("textReader"),e="";try {if(d.contentDocument)f=d.contentDocument,e=f.getE lementsByTagName("BODY")[0].innerHTML;else if(d.contentWindow)e=
d.contentWindow.document.body.innerHTML;c=e.indexO f(Review.Content[Count])>-1?c+'<br /><input type="button" style="width:20px; height:20px; background-color:#0F0; border:none;" />&nbsp;&nbsp;&nbsp;El servicio<strong>'+Review.Content[Count]+"</strong> está iniciado en <strong>"+Review.Files[Count]+Extend+"</strong>":c+'<br /><input type="button" style="width:20px; height:20px; background-color:#F00; border:none;" />&nbsp;&nbsp;&nbsp;El servicio<strong>'+
Review.Content[Count]+"</strong> no está iniciado en<strong>"+Review.Files[Count]+Extend+"</strong>";b.innerHTML=c;a.value=a.value+"-> Cerrando Archivo "+Review.Files[Count]+" \n";a.scrollTop=a.scrollHeight}catch(g){b.innerHTM L=b.innerHTML+'<br /><input type="button" style="width:20px; height:20px; background-color:#F00; border:none;" /><label style="color:#F00">&nbsp;&nbsp;&nbsp;Error al intentar acceder a el archivo '+Review.Files[Count]+Extend+" puede que el archivo est&eacute; corrupto o no exista.<br /></label>"}Count++};
</script>
</head>
<body>
<iframe id="textReader" style="display: none;" ></iframe>
<form>
<input type="button" value="Revisar Servicios..." onClick="INITIALIZED();" />
</form>
Consola:<br />
<textarea id="Console" style="font-family:Arial; background-color:#FFF; font-size:14px; color:#F00; overflow:auto; width:100%; height:100px; border:1px #999 solid;">&nbsp;</textarea><br /><br />
Debugger:<br />
<div id="Debbugger">&nbsp;</div>
</body>