It is not as user-friendly as most DroidScript code but it will seem really obvious to some people and really difficult to others.
I recommend you try it and if it doesn't make sense to you, come back and ask here with the code that you are having troubles with.
Steve suggested a better idea doing this from DS. This process works well to some extent. It reads the file line by line so it will again take very long time to completely read the file specially when it is 50mb or above...
Besides,
The android may alert 'app not responding dialog'...
You need to add progress to prevent this...
Good luck!
var file,len
function OnStart()
{
var res
console.log(app.FileExists("/sdcard/Download/Untitled7.txt"))
file = app.CreateFile( "/sdcard/Download/Untitled 7.txt", "r" );
len = file.GetLength();
console.log( "file len: " + len );
file.Seek( 0 );
while(true)
{
res = readNext();
if(typeof res == "undefined")
{
alert( "Finished" );
break;
}
alert( res )
}
}
function readNext()
{
var lin;
if(file.GetPointer() < len)
{
lin = file.ReadText( "Line" );
}
else
{
file.Close();
lin = undefined;
}
return( lin )
}
then to access a line, you just set a variable to the index (which SHOULD be the line number + 1) if I'm not mistaken. for example :
//get 10th line
//(using text var from above example)
var line = 10
app.ShowPopup(text[line + 1])
This is based off an extremely elaborate keyboard shortcut method I have been utilizing in an app I'm working on, and so as I cut out a tiny part of it to try and apply to this question, that above code may or may not work for you in the context of your situation.
it works, but change the following :
text[line+1]
should actually be :
text[(line+1)]