DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    John K. Guest

    Printing to file without line feed

    Hi!

    When I do like this:

    Print #1, "Text" '#1 is my file

    the program puts the word "text" on a new line
    in a given file. But how do I append the text
    on the same line as the last time?

    I know I could be saving all the text in a variable,
    and then print it to the file, but believe me,
    that doesn't work for me in this situation.

    Please, any suggestions?



  2. #2
    Mattias Sjögren Guest

    Re: Printing to file without line feed

    Hi John,

    >But how do I append the text on the same line as the last time?


    If you type:

    Print #1, "Text1";
    Print #1, "Text2"

    "Text2" will follow "Text1" in the file, without any line breaks in
    between. Notice the semicolon on the first line.


    Mattias

    __________________________________________________
    Mattias Sjögren (MCP) - mattiass @ hem.passagen.se
    VB+ http://hem.spray.se/mattias.sjogren/
    Please send questions/replies to the newsgroups

  3. #3
    Robert Gelb Guest

    Re: Printing to file without line feed


    >When I do like this:
    >Print #1, "Text" '#1 is my file
    >
    >the program puts the word "text" on a new line
    >in a given file. But how do I append the text
    >on the same line as the last time?


    Do this:

    Print #1, "Text"; 'note the semicolon

    'the semicolon prevents vb from inserting a carriage return & line feed




  4. #4
    Chris G Guest

    Re: Printing to file without line feed


    "Robert Gelb" <Robert.Gelb-nospam@db.com> wrote:
    >
    >>When I do like this:
    >>Print #1, "Text" '#1 is my file
    >>
    >>the program puts the word "text" on a new line
    >>in a given file. But how do I append the text
    >>on the same line as the last time?

    >
    >Do this:
    >
    >Print #1, "Text"; 'note the semicolon
    >
    >'the semicolon prevents vb from inserting a carriage return & line feed
    >
    >
    >


    You may want to read the line of text into a variable, then combine the new
    text to the end of the old. Finally, write the new string out with the print
    statement.

    I.E
    Line Input oldString
    Print #1, oldstring & "New Text";

    Hope you get the idea?!?

    Chris



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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links