Computing.Net > Forums > Programming > Writing text to files in QuickBASIC

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Writing text to files in QuickBASIC

Reply to Message Icon

Original Message
Name: CompFreek101
Date: June 21, 2005 at 14:20:52 Pacific
Subject: Writing text to files in QuickBASIC
OS: Windows XP
CPU/Ram: 400mhz P2M, 128mb
Comment:

Hello again, if I wanted to write the text "Hello!"
on the second line of "test.txt", how would
I do that?
The programming language is QuickBASIC
Thanks again, everybody!


Report Offensive Message For Removal


Response Number 1
Name: CompFreek101
Date: June 21, 2005 at 21:42:51 Pacific
Reply: (edit)

Woops, I left out something, my bad:


OPEN "c:\test.txt" FOR OUTPUT AS #1
WRITE #1, "Whatsup"
CLOSE #1

This is what I have now, but when I open test.txt, I see (on line one) "Whatsup" (including the quotes) and I would like to get rid of the quotes, and have "Whatsup" on the third line of the file. Thanks again, everybody!


Report Offensive Follow Up For Removal

Response Number 2
Name: borelli35
Date: June 21, 2005 at 23:57:36 Pacific
Reply: (edit)

====================================================================
To start with, the quotes are what is referred to as a text delimiter. This is how QB knows when a string begins and ends. In a text file using VB this is unavoidable. The only way to do this (yes it is doable but more difficult) is to write binary files using get and put rather than input and write. The other thing to be aware of is that QB text files are sequencial. This means that you must open them for append or rewrite them in the order of text you wish (the latter is the most common solution). I hope this clears some of your questions up. Feel free to keep asking.

John W. Borelli
IT Specialist
Hawkeye Security
borelli35


Report Offensive Follow Up For Removal

Response Number 3
Name: wizard-fred
Date: June 22, 2005 at 04:00:53 Pacific
Reply: (edit)

open "test.txt" for output as #1
print #1, ""
print #1, ""
print #1, "whatsup"
close #1

WRITE # and PRINT # are used for different purposes. WRITE creates comma separated data elements. Therefore the quotation marks.


Report Offensive Follow Up For Removal

Response Number 4
Name: CompFreek101
Date: June 22, 2005 at 08:22:16 Pacific
Reply: (edit)

Thank! Works great!


Report Offensive Follow Up For Removal

Response Number 5
Name: borelli35
Date: June 24, 2005 at 02:08:04 Pacific
Reply: (edit)

Thanks fred. It's been a while since I've used QB and I forgot about that difference...good catch.

John W. Borelli
IT Specialist
Hawkeye Security
borelli35


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software