[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2006-07-18T19:30:43-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/1576 2006-07-18T19:30:43-05:00 2006-07-18T19:30:43-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12165#p12165 <![CDATA[Need help with openin a file on the interwebs]]>

Code:

'main loop:IF a = 2 THENINPUT "Input your text: ", text$OPEN "talk.txt" FOR APPEND AS #1WRITE #1, text$CLOSE #1CLSDO UNTIL text$ = "q":mcy:IF v = 1 THENOPEN "C:\Docume~1\Matt\zero\mine\talk1.txt" FOR INPUT AS #1INPUT #1, othertext$CLOSE #1IF othertext$ = "" THENv = 2END IFLOCATE g, 1PRINT username$; ": "; text$PLAY m$g = g + 1IF v = 1 THENLOCATE g, 1PRINT friend$; ": "; othertext$PLAY m$g = g + 1END IFEND IFLOCATE 1, 1INPUT "", text$OPEN "talk.txt" FOR APPEND AS #1WRITE #1, text$CLOSE #1LOCATE 1, 1PRINT "                                                                                              "IF text$ = "king" THEN GOTO kingv = 1LOOPEND IFEND

Statistics: Posted by plad6111 — Tue Jul 18, 2006 7:30 pm


]]>
2006-07-17T23:05:00-05:00 2006-07-17T23:05:00-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12160#p12160 <![CDATA[Need help with openin a file on the interwebs]]>
Okay, what I wan't to happen is:

1. I wan't to write several lines of text into an input statment

2. I wan't to open those lines of text from the file later in the program.

My problem: when I say open for append, the files get writen at the end of the file, just like i wan't them to, but then, when I try to use the open for input statment later, it doesn't work because it only takes the first line of text from the file.
That is the best I can explain it and I think that is dang clear!!
I'm sorry. It is not clear at all. We could help you out if you would post a short code sample demonstating how you are attempting to output to the file and how you are attempting to input from the file. As it stands, you don't seem to be familiar enough with programming in general to describe your problem.

However, I think I may have an idea about what is confusing you. Whenever you open a file for input, the file position is set to the beginning of the file. When you use the input statement to read from the file, the file position is updated, and the next input statement will read from that position. This will continue until you reach the end of the file, at which point any attempt to input from the file will throw an error. BUT... if you close the file and reopen it, the file position will be set back to the begining of the file, and I suspect this is what you are doing inside your loop, but I can't know for sure unless you post an example of exactly what lines of code you are having trouble with.

Statistics: Posted by RyanKelly — Mon Jul 17, 2006 11:05 pm


]]>
2006-07-17T15:34:01-05:00 2006-07-17T15:34:01-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12156#p12156 <![CDATA[Need help with openin a file on the interwebs]]>
1. I wan't to write several lines of text into an input statment

2. I wan't to open those lines of text from the file later in the program.

My problem: when I say open for append, the files get writen at the end of the file, just like i wan't them to, but then, when I try to use the open for input statment later, it doesn't work because it only takes the first line of text from the file.
That is the best I can explain it and I think that is dang clear!!

Statistics: Posted by plad6111 — Mon Jul 17, 2006 3:34 pm


]]>
2006-07-14T19:31:34-05:00 2006-07-14T19:31:34-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12134#p12134 <![CDATA[Need help with openin a file on the interwebs]]>
Thanks, but I already knew all of that. What I wan't to know is, after you say open for input, I say input as #1, so that only takes the first file, and since it is in a do/loop I can't make it say anything else. Please help.
Kindly expain yourself more clearly and precisely.

You said:" after you say open for input, I say input as #1, so that only takes the first file".
What do you mean by "takes the first file"?

The you said: "and since it is in a do/loop I can't make it say anything else."
What do you mean by "say anything rlse"?

Assuming that you wrote records of string data to the file, the normal procedure for reading records from the file is as follows:

Code:

open "thefile" for input as #1do while not eof(1)     line input #1, recdata$   'recdata$ will contain the data from each record.     gosub processdataloopsystemprocessdata:    ' Your logic for processing each and every record on the file.return
The LINE INPUT # statement above is the recommended method of reading an entire record of string data from a file, because it reads the entire record regardless of blanks, commas or other punctuation, which do affect the INPUT # statement.

You might already know all this, but perhaps an example might help you.
*****

Statistics: Posted by moneo — Fri Jul 14, 2006 7:31 pm


]]>
2006-07-14T16:38:40-05:00 2006-07-14T16:38:40-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12133#p12133 <![CDATA[Need help with openin a file on the interwebs]]>
Hello?
This is a forum, not a chat.

Statistics: Posted by Z!re — Fri Jul 14, 2006 4:38 pm


]]>
2006-07-14T09:34:26-05:00 2006-07-14T09:34:26-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12129#p12129 <![CDATA[Need help with openin a file on the interwebs]]> Statistics: Posted by plad6111 — Fri Jul 14, 2006 9:34 am


]]>
2006-07-13T18:59:48-05:00 2006-07-13T18:59:48-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12121#p12121 <![CDATA[Need help with openin a file on the interwebs]]> Statistics: Posted by plad6111 — Thu Jul 13, 2006 6:59 pm


]]>
2006-07-13T18:27:32-05:00 2006-07-13T18:27:32-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12120#p12120 <![CDATA[Need help with openin a file on the interwebs]]>
......how do I make an open for append statment and then make an input statment that will take everything from the file that I said to append?
An OPEN FOR APPEND is very similar to an OPEN FOR OUTPUT.
An OPEN FOR OUTPUT creates a new file. If you write 10 records to it, you will have 10 records on the file.

An OPEN FOR APPEND works as follows:
If the file does not already exist, then it works exactly the same as the OPEN FOR OUTPUT. However, if the file does exist, and let's say it already has 6 records on it, then it positions AFTER the 6th record so that the next write or print to the file will become the 7th record, and subsequent writes or prints to the file will become the 8th record and so on.

In order to read everything, or "take everything" as you say, from the previously appended file, you have to CLOSE it first. Then, if you're still in the same program, you can open that file FOR INPUT, and read from it from the beginning of the file.
*****

Statistics: Posted by moneo — Thu Jul 13, 2006 6:27 pm


]]>
2006-07-13T09:21:06-05:00 2006-07-13T09:21:06-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12119#p12119 <![CDATA[Need help with openin a file on the interwebs]]> Statistics: Posted by plad6111 — Thu Jul 13, 2006 9:21 am


]]>
2006-07-12T21:34:41-05:00 2006-07-12T21:34:41-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12116#p12116 <![CDATA[Need help with openin a file on the interwebs]]>
but when i try it in qb it doesn't work, I don't know why!
Maybe the path is wrong, maybe you should try going to my computer and check the path

other than that, I dunno what's wrong.

Statistics: Posted by Anima — Wed Jul 12, 2006 9:34 pm


]]>
2006-07-12T20:16:04-05:00 2006-07-12T20:16:04-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12115#p12115 <![CDATA[Need help with openin a file on the interwebs]]> Statistics: Posted by plad6111 — Wed Jul 12, 2006 8:16 pm


]]>
2006-07-12T20:08:39-05:00 2006-07-12T20:08:39-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12114#p12114 <![CDATA[Need help with openin a file on the interwebs]]>
No, I mean, if I have a file that I wan't to open, and it is in a place where the program isn't, how do I make the program look in the file that the .txt document is in.

For example: if the program is sitting on my desktop, and the .txt file that I wan't to open is in a file in my documents. How do I make it look in there for the first file, and on the desktop for the second file?
Well it should work when your typing in the path. But the example program you put up there, all you have to do is type the full path of the file AND the file at the end, like, if I had something call file.txt in C:\txt, I would say "C:\txt\file.txt"

Statistics: Posted by Anima — Wed Jul 12, 2006 8:08 pm


]]>
2006-07-12T19:03:52-05:00 2006-07-12T19:03:52-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12113#p12113 <![CDATA[Need help with openin a file on the interwebs]]>
For example: if the program is sitting on my desktop, and the .txt file that I wan't to open is in a file in my documents. How do I make it look in there for the first file, and on the desktop for the second file?

Statistics: Posted by plad6111 — Wed Jul 12, 2006 7:03 pm


]]>
2006-07-12T19:01:42-05:00 2006-07-12T19:01:42-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12112#p12112 <![CDATA[Need help with openin a file on the interwebs]]>
do:
open "bla.txt" for append as #1
write #1, text$
close #1

open "bla.txt" for input as #1
input $1, text2$
close #1
print text2$
loop

The only thing that appears on the screen is the first entry in the bla.txt, but since I said to append every input to the file, I wan't to get the second, third, fourth and so on entry in the file. How do I do that?
I have been trying to figure it out, but I can't! :x Please help!

Statistics: Posted by plad6111 — Wed Jul 12, 2006 7:01 pm


]]>
2006-07-12T19:01:17-05:00 2006-07-12T19:01:17-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=12111#p12111 <![CDATA[Need help with openin a file on the interwebs]]>
there isn't on my version of qb, but I have a very old version, so they may have updated it. What I was wondering is how do you change the file path on an open statment?
Um... if you mean changing the path while it's running, you CAN set a string variable for the path and have an input command in so that you can change it. If that's what you mean.

Statistics: Posted by Anima — Wed Jul 12, 2006 7:01 pm


]]>