-1

Im trying to get a code that will do something if a certain line number is in a text file for example "Test.txt" Ex.

if line "x" exists in test.txt msg $chan working
skdfsfwse
  • 19
  • 7

2 Answers2

0

thanks @denny for being the one to help me out.

if ($read(test.txt, n, x)) { 
  msg $chan working
}
skdfsfwse
  • 19
  • 7
  • Although this code may be help to solve the problem, providing additional context regarding _why_ and/or _how_ it answers the question would significantly improve its long-term value. Please [edit] your answer to add some explanation. – oɔɯǝɹ Jul 20 '16 at 19:15
0

You have couple of options.

  1. Searching to see if the number is lower or equal to the total lines. e.g: $lines(filename)
  2. You can extract the line and use a condition if it's full. e.g: $read(filename, LINE-NUMBER)

Notes for each method:

  1. Will only tell you if there is a line number, NOT if there is something inside this line.
  2. Will only give you the line if exists, if the line is empty or there is no such line then it will appears like it's empty.
Orel Eraki
  • 11,940
  • 3
  • 28
  • 36