Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Reading Text Files in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Reading Text Files in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2007-01-23

    Table of Contents:
  • Reading Text Files in WSH
  • Reading methods
  • More methods
  • Advanced concepts

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading Text Files in WSH - More methods


    (Page 3 of 4 )

    Sometimes reading one character at a time just isn’t very useful or is inefficient.  For those times, the TextStream Object provides a few more methods.

    Methods:

    object.ReadLine

    object.ReadAll

    object.Skip(Int)

    object.SkipLine

     

    Properties:

    object.AtEndOfLine

    object.Column

    object.Line

    The ReadLine method will read until it finds an end of line character (vbCr, vbLf, or vbCrLf) and return a string containing the characters excluding the line ending.  The ReadAll method will read every character until it reaches an EOF marker before returning its findings as a string (including end of line indicators).

    Exercise caution when using the ReadAll method with large files.  You can run out of memory which will result in errors during execution.

    The Skip method accepts an integer as its parameter and will skip reading the specified number of characters.  The SkipLine method can be used to skip an entire line or continue until the next end of line indicator.

    Several properties are also available that can help you determine where the file pointer is in a file.  AtEndOfLine works in much the same way as AtEndOfStream except that it returns a Boolean value indicating whether the file pointer is at an end of line indicator.

    The Column property returns an integer indicating the position of the file pointer in the current line.  The first character of the line is position 1.  The Line property returns the current line number.  The first line in the file is line 1.

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · I continue to explore the world of WSH with the first of a 3-part series dealing...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT