How to read the line in file which u need (little problem)

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Pihas
Posts: 53
Joined: Sat Oct 25, 2008 10:26 pm
Location: Lithuania
Contact:

How to read the line in file which u need (little problem)

Post by Pihas »

Inside Text document (mydoc.txt):
-- blablabla
blablabla
text 569 text


How to read 3 line from file mydoc.txt and get string from 5 to 8 (569)?

file=io.open("mydoc.txt","r")
numbers = file:read()
file:close()

screen.print(100,100,numbers,white)
LionX
Posts: 61
Joined: Mon Dec 27, 2004 11:40 am

Post by LionX »

to read the 1st line:
read 1 byte at a time until you see a byte=='\n'

'\n' is newline (enter key)



if you want to read each item in the line then you would check for spaces byte==' '
Post Reply