readline

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James

    #1

    readline

    i've opened a text file, say config.ini and it contains 3 lines

    config.ini
    ' this is a test file
    mypath=c:\abc
    mybatch=c:\batc h\runme.bat

    1. How do i use readline method to ignore anything that has 'comments ?

    2. What is the best way to read those those variables from mypath and
    mybatch ? I can use a do loop, how do i pass c:\abc and c:\batch\runme. bat
    into different variables as i execute the programs ?




  • Ken Tucker [MVP]

    #2
    Re: readline

    Hi,

    Free software components for C#, VB.NET and other .NET languages.


    Ken
    -------------
    "James" <jkklim@hotmail .com> wrote in message
    news:ueEvSXIyFH A.3180@TK2MSFTN GP14.phx.gbl...[color=blue]
    > i've opened a text file, say config.ini and it contains 3 lines
    >
    > config.ini
    > ' this is a test file
    > mypath=c:\abc
    > mybatch=c:\batc h\runme.bat
    >
    > 1. How do i use readline method to ignore anything that has 'comments ?
    >
    > 2. What is the best way to read those those variables from mypath and
    > mybatch ? I can use a do loop, how do i pass c:\abc and c:\batch\runme. bat
    > into different variables as i execute the programs ?
    >
    >
    >
    >[/color]


    Comment

    • Rykie

      #3
      Re: readline

      I assume you have something like this:

      Dim line as String

      while not line is nothing
      line = sr.readline()
      if line.StartsWith ("'") then
      'ignore line
      else
      'do whatever
      end if

      end while

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: readline

        "James" <jkklim@hotmail .com> schrieb:[color=blue]
        > i've opened a text file, say config.ini and it contains 3 lines
        >
        > config.ini
        > ' this is a test file
        > mypath=c:\abc
        > mybatch=c:\batc h\runme.bat
        >
        > 1. How do i use readline method to ignore anything that has 'comments ?[/color]

        If you use 'StreamReader' you can read each line of the file and analyze the
        text:

        Reading a text file line-by-line or blockwise with a progress indicator
        <URL:http://dotnet.mvps.org/dotnet/faqs/?id=readfile&la ng=en>

        For simple string manipulation take a look at the 'String' class' members
        and the methods in the 'Strings' module.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        Working...