If, line 5 of file test.txt = "color"..do...else do ...

Discussion in 'Programming' started by Peuplarchie, Nov 17, 2008.

  1. #1
    Good day to you,
    I woking on a script which is customizable for the web editor to change some option on the way some item on the page are displayed.

    My question is:

    How can I put in my code something that would do :

    if in file "setting.txt" row 5, the word "colored" appears do this piece of code else , do this piece.

    This would be within a function.

    Thanks !
     
    Peuplarchie, Nov 17, 2008 IP
  2. Ancient Dragon

    Ancient Dragon Peon

    Messages:
    192
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. open the file
    2. read the first five lins
    3. search for the word "colored"
    4. do the if-the-else test

    Exactly how to do the above will depend on what programming language you are using.
     
    Ancient Dragon, Nov 18, 2008 IP
  3. shineDarkly

    shineDarkly Banned

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    or try a loop and counter method, open the file, loop through the lines, if loop 5 then "do this piece" :)
     
    shineDarkly, Nov 18, 2008 IP