Results 1 to 3 of 3

Thread: read lines stop on number 10?

  1. #1
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default read lines stop on number 10?

    noob question from me now... i have a script that gets the lines off a php file that are on seperate lines... it gets the lines fine and displays them correctly only what i want to do is only get 10 lines and when its at the 10th line i need it to stop...

    here is my function

    Code:
    function listScripts(userobj, lines)
    {
        for (i = 0; i < lines.length; i++)
        {
            tmp = lines[i].split("\n");
            print(userobj, "\x0305Template: \x0302" + tmp[0]);
        }
    }

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Code:
    function listScripts(userobj, lines)
    {
        for (i = 0; i < 10; i++)
        {
            tmp = lines[i].split("\n");
            print(userobj, "\x0305Template: \x0302" + tmp[0]);
        }
    }

  3. The Following User Says Thank You to Schmoopy For This Useful Post:

    Tim Dobson (03-25-2011)

  4. #3
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    ah greate stuff i did do this just to see if it works but i knew there wuld be something more clean

    Code:
    function listScripts(userobj, lines)
    {
        for (i = 0; i < lines.length; i++)
        {
    		if (i == 10){
    		break;
    		} else {
            tmp = lines[i].split("\n");
            print(userobj, "\x0305Template: \x0302" + tmp[0]);
    		}
        }
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •