Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This code is written soley, and completely by JoshhT.
- Skype : JoshhT44
- Please do not steal, distribute, or plagiarise my work.
- If this code has helped you, feel free to thank me :)
- Whether it be a +1 on the post, or adding me on skype to say thanks.
- ]]--
- local args = {...}
- function cleanup()
- local a = args[1]
- local b = ""
- if string.sub(a, 1, 1) == "\"" then
- b = string.sub(a, 2, -1)
- else
- b = a
- end
- a = string.reverse(b)
- if string.sub(a, 1, 1) == "\"" then
- b = string.sub(a, 2, -1)
- b = string.reverse(b)
- end
- return b
- end
- local fileLoc = cleanup()
- local lineNum = tonumber(args[2])
- function program()
- local file = fs.open(fileLoc, "r")
- local list = {}
- local line = file.readLine()
- repeat
- table.insert(list, line)
- line = file.readLine()
- until line == nil
- file.close()
- print("Line " .. lineNum .. ": " .. list[lineNum])
- end
- if #args == 2 then
- if fs.exists(fileLoc) then
- program()
- else
- print("Invalid file location.")
- end
- elseif args[1] == "help" then
- print [[This program was written to help people
- Find an exact line in their program.
- Simply type in the program location,
- With or without the quotation marks, it works either way :)
- Then type the line you wish to retrieve. Example:
- lineFinder "/disk/mining/branch" 34
- Would print line 34 within the file specified.
- Any errors should be directed here,
- http://www.computercraft.info/forums2/index.php?/topic/5032-line-finder-by-joshht/
- Thanks for using my program :)
- JoshhT.]]
- else
- print("Please enter the file destination\nAnd line number only.")
- end
Advertisement
Add Comment
Please, Sign In to add comment