Jump to content
  • 0

get a line of a file


Splawsh

Question

Hello all

I have a problem 

I want get a line of a file to use in (ex:gg.alert) or other

but i only know how get all lines 😕

please help me

 

ex: [ /system/build.prop] | [line (7) only]

I trying some codes but they didn't work

print (" Help me :( ")
os.exit()

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

file = io.open("/system/build.prop")
local number_of_loop = 0
local extracted = {}
repeat 
  text = file:read("l*")
  number_of_loop = number_of_loop + 1
  extracted[number_of_loop] = text
until number_of_loop == 7

gg.alert(extracted[7])

Simple loop to get seventh line in the file.

Link to comment
Share on other sites

35 minutes ago, ItsSC said:

file = io.open("/system/build.prop")
local number_of_loop = 0
local extracted = {}
repeat 
  text = file:read("l*")
  number_of_loop = number_of_loop + 1
  extracted[number_of_loop] = text
until number_of_loop == 7

gg.alert(extracted[7])

Simple loop to get seventh line in the file.

hey bro 

very THANKS you❤❤❤

Link to comment
Share on other sites

3 minutes ago, Splawsh said:

hey bro 

very THANKS you❤❤❤

you're welcome, if the line is not stable but text has a changing pattern, you can use string.gmatch to find the text you want.

Link to comment
Share on other sites

On 5/4/2020 at 9:04 PM, ItsSC said:

you're welcome, if the line is not stable but text has a changing pattern, you can use string.gmatch to find the text you want.

OK 

solve my problem by your help 🙂

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.