! ! open"text.txt" for input & output ! ! ques - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: ! ! open"text.txt" for input & output ! ! ques (/thread-4599.html) Pages:
1
2
|
! ! open"text.txt" for input & output ! ! ques - -dezell- - 09-01-2004 I have some questions...but answers seem too complicated for me 1)how do I save file with the name I want? something like this Code: open "input"mychoosednamewhichIcantype" .txt" for output as #1 2)what does #1 mean? how does it help me anyway? 3)how can i read from the second line of file?? bla.txt: Code: Bond qbasic program: Code: open"bla.txt" for input as #1 but it will only print me the first line word, Bond... so thank you if you wasted your time helping me ! ! open"text.txt" for input & output ! ! ques - Sterling Christensen - 09-01-2004 1) Code: INPUT youCanUseAStringVariable$ 2) You can open more than one file at a time. For example, to copy stuff from "source.dat" to "dest.dat", you could make "source.dat" #1, and "dest.dat" #2. You can pick any number you want, even #53 should work. 3) The first time, INPUT gives you the first line. But if you do it again, it'll give you the second, etc... example: Code: OPEN "blah.txt" FOR INPUT AS #1 ! ! open"text.txt" for input & output ! ! ques - -dezell- - 09-01-2004 thank you for your answers ...they helped me a lot still...when I looked at these questions, one thing came to mind...how do I save some certain text? let's say i have an input form, Code: input"What means HTML : ";answer$ well...and let's say I want to choose a name for this file? how would the code then look like? started learning qbasic by myself last night and already I have so many ideas...and questions ! ! open"text.txt" for input & output ! ! ques - HQSneaker - 09-01-2004 [syntax="qbasic"] input"What means HTML : ",answer$ input "Choose filename: ", filename$ open filename$ + ".txt" for output as #1 print #1, answer$ close #1 [/syntax] ! ! open"text.txt" for input & output ! ! ques - -dezell- - 09-01-2004 thanks :wink: ! ! open"text.txt" for input & output ! ! ques - frostyservant - 09-03-2004 In response to #3... although you could, as Sterling suggested, loop LINE INPUT, I would suggest switching over to .dat files if you're going to want to write multiple lines at a time in a file... MUUUUCH easier. For information on .dat files... read the "Random Access Files" section of http://www.qbasic.com/chapter5.txt. ! ! open"text.txt" for input & output ! ! ques - whitetiger0990 - 09-03-2004 the extention does matter. it could be .dat or .txt or .aaa read it anyways though =P ! ! open"text.txt" for input & output ! ! ques - oracle - 09-03-2004 Files don't even need extensions (though this is normally good practice) ! ! open"text.txt" for input & output ! ! ques - Ruudboy - 09-03-2004 like with my programs, my word procesor used .gdm files, and my ftp program used .gf extension to save logs, (not to self:i shud finish that, now if only i cud find the disk) ! ! open"text.txt" for input & output ! ! ques - adosorken - 09-03-2004 You might want to reconsider your extension .gdm is used for General Digital Music, and is the native format (and extension) for the BWSB sound library. If I were you, I'd try to find an extension that's not already being used...you can get a good list of used extensions at wotsit.org. |