files read issue

i have stored some nos in my file.Now I want to read 3 digits from that no.How can I do that .when i do that using
[lua]local path = system.pathForFile( “myFile.txt”, system.DocumentsDirectory )
local file = io.open( path, “r” )
if file then
local data = file:read( “*n” )
print( “data”…data )
io.close( file )
end[/lua]
I get the whole no.Can anyone let me know how can i get 3 digits from a 9 digit no so that i can get all the digits one by one.Please help me… [import]uid: 45566 topic_id: 25611 reply_id: 325611[/import]

Here there - here’s the first three digits;

[lua]local path = system.pathForFile( “myFile.txt”, system.DocumentsDirectory )
local file = io.open( path, “r” )
if file then
data = file:read( “*n” )
print( “data”…data )
io.close( file )
end

numberString = tostring(data)
threeDigits = numberString:sub(1,3)
print (threeDigits)[/lua]

And here’s the last three;
[lua]local path = system.pathForFile( “myFile.txt”, system.DocumentsDirectory )
local file = io.open( path, “r” )
if file then
data = file:read( “*n” )
print( “data”…data )
io.close( file )
end

numberString = tostring(data)
threeDigits = numberString:sub(7,9)
print (threeDigits)[/lua]

Hope this helps :slight_smile:

Peach [import]uid: 52491 topic_id: 25611 reply_id: 103477[/import]