|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
QBasic...
I know that this is WAY old... but im doing it for a class...
This isnt the complete code, because theres way more to be done... but im having problems with this... nameInput$ = "filler" CLS DO UNTIL nameInput$ = "" GOSUB inputInfo dataString$ = dataString$ + nameInput$ + "," + piecesInput$ + "," LOOP dataString$ = dataString$ + "END,0" GOSUB inputdata DO UNTIL UCASE$(name$) = "END" GOSUB displayData LOOP END inputInfo: INPUT "Name: ", nameInput$ INPUT "Pieces: ", piecesInput$ RETURN displayData: PRINT name$, pieces$ READ name$, pieces$ RETURN inputData: READ name$, peices$ DATA dataString$ RETURN This returns on the READ statement, in "inputData" sub, that it is Out of DATA.... Anyone have any idea as to what may be going on? |
|
#2
|
|||
|
|||
|
dataString$ is a variable value,not two variable value..U must have two value to give the name$ and Peices$..
When Data statement has little value than variable in the read statement,Out of Data error happened.. |
|
#3
|
|||
|
|||
|
U can try Set statement:set a$="123"
__________________
Being a Code Headman !
|
|
#4
|
||||
|
||||
|
Well, even so.. wouldnt it echo the variable on the DATA statement? therefore setting the DATA to ####, ####, ####, #### ??
|
|
#5
|
|||
|
|||
|
####, ####, ####, #### must be const value..
|
|
#6
|
|||
|
|||
|
Your problem is this: the READ statement reads data from a DATA statement. You are storing all your data as a String. Then, when you store it as data, you will only be able to read the string name, not the contents. After that you are out of data.
As I see it, you want the user to type in a whole bunch of names and something about pieces. You then want the program to store all that information and be able to access it again, right? This is my version of your program, but simplified and hopefully it works. I am used to QB4.5, so it may not work for you. By the way, I got rid of all the GOSUBs, as they are superfluous and take more code. [COLOR = blue] CLS Open “Data.Dat” for Output as #1 DO INPUT "Name: ", nameInput$ INPUT "Pieces: ", piecesInput$ IF nameInput$ = “” Then Exit Do Write #1, nameInput$, piecesInput$ LOOP Close #1 Open “Data.dat” for Input as #1 DO UNTIL Input #1, name$, pieces$ PRINT name$, pieces$ LOOP Until Eof(1) Close #1 END [/COLOR] I hope this helps. What I did was create a file to write the information to and access all the data from there. As an added bonus, you can look at this data any time you want after you close the program. However, every time you run the program, it erases the file's contents. Have fun in QB. |
|
#7
|
|||
|
|||
|
that is old....i forgot how to program that
|
|
#8
|
|||
|
|||
|
You caught me
I admit it. I still program in QBasic. It's archaic, I know, but it's a challenge. I'm crossing over more and more to VB.NET, though.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > QBasic... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|