Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Writing 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

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

    Table of Contents:
  • Writing Text Files in WSH
  • Opening an existing text file
  • Advanced Writing Methods
  • Advanced writing 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


    Writing Text Files in WSH - Advanced Writing Methods


    (Page 3 of 4 )

    You can pretty much solve all of your writing needs with the methods we’ve discussed, but WSH provides us with one more method to make things even easier.  It’s nice to be able to space out the text that we write to a text file, but it’s sometimes tedious to do using the Write and WriteLine methods.

    object.WriteBlankLines(Int)

    The WriteBlankLines methods will write a given number of consecutive newline characters to a file.  It accepts a single required parameter, Int, which is an integer indicating how many newline character to write.

    Note that the methods provided in this article can only write to TextStream objects.  WSH does not provide any way natively to read or edit binary files.

    The WriteBlankLines method is used in much the same way as the writing methods we’ve seen previously.  Here’s a quick example.

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objFile = objFSO.OpenTextFile("C:\ScriptLog.txt", 2, 1)

    objFile.WriteLine("This is our first line")

    objFile.WriteBlankLines(3)

    objFile.Write("This line is written after 3 blank lines")

    objFile.Close

    Here we’ve used the WriteBlankLines method to write three blank lines in our text file.  The output should look like this:

    This is our first line

     

     

     

    This line is written after 3 blank lines

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


       · In part 2 of this series, we learn how to write information to text files. I'd love...
       · the link for the file does not work. you get a page not found error.
     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT