READ....DATA

  • Thread starter Thread starter Ron
  • Start date Start date
Hi Ron,

If you tell what you want to do, than is it a lot easier for more people to
answer.

Now you can only expect an answer from the happy view who like you also know
QuickBasic.

It is far away from VB.net do you know?

Cor
 
To explain further:

For the simple things I do, I have not gone to .NET but
have stayed with VB6. Each time I start up the program
originally written in QuickBasic, I want to load a lookup
table with over 700 data items. I have done this in QB by
using READ... DATA. The data are then 'embedded' in the
program and since the data is proprietary, is not directly
readable once compiled. This avoids reading in the data
from a separate file. So, going back to my original
question: What is the VB equivalent of the READ statement?

Thanks,
Ron
 
Hi Herfried,

Thank you for your link, but for me it conflicts with what the OP is saying.

You are probably one of those happy few who knows what is Quick Basic.

What the OP says sounds for me as a collection of objects, but I am not
sure.

So maybe you can explain this?

(And than I know it also for the next time).

Cor
 
Ron said:
What is the VB equivalent of the READ...DATA statements in
QuickBasic?

There is no equivalent. Didn't you like Ken's answer three days ago?
 
* "Cor said:
Thank you for your link, but for me it conflicts with what the OP is saying.

You are probably one of those happy few who knows what is Quick Basic.

What the OP says sounds for me as a collection of objects, but I am not
sure.

So maybe you can explain this?

I never worked with this commands...

:-(
 
Hello, Ron:

There wasn't an equivalent in previous versions of VB, but with VB.NET you can use the array constructor to store your data.
DATA and READ were used almost always to fill an array, or to read the data secuencially... the same way you can do with an array.
The sample Herfried pointed at could be translated to something like:

'\\\
structure CityData
dim Name as string
dim State as string
dim ZIP as integer

sub new(a as string, b as string, c as integer)
name=a:state=b:zip=c
end sub
end structure

sub InitializeData
'Emulates the DATA instruction:
citydataarray=new citydata() {new citydata("CLEVELAND", "OHIO", 44114), _
new citydata("Santander", "Cantabria, Spain", 39007)}
end sub

sub PrintData
'Emulates the READ instruction:
for each cd as citydata in citydataarray
console.writeline("The city of {0} is in {1} and it's ZIP code is {3}.",cd.name,cd.state,cd.zip)
next
end sub
'///

Well... it's far from similar... but that's what we have.
It is much (very much) easier if all the data is of the same type:
'\\\
'You have the effect of the DATA and the READ instructions in a single line:
dim city() as new string(){"La Coruña","Lugo","Oviedo","Santander","Bilbao","San Sebastián"}
'Instead of:
'for n=0 to 5 : read c$ : city$(n)=c$ : next (you couldn't use READ with an indexed variable)
'data "La Coruña", Lugo, Oviedo, Santander, Bilbao, "San Sebastián"
'///

Regards.


"Ron" <[email protected]> escribió en el mensaje | What is the VB equivalent of the READ...DATA statements in
| QuickBasic?
|
| Thanks
 
Cor said:
What the OP says sounds for me as a collection of objects, but I am not
sure.
So maybe you can explain this?
(And than I know it also for the next time).

Cor... I'm gonna show my age (: ... but what the DATA statement is (for
GWBasic) is when you use to be able to hard code data values in your
application for later use (kind of like a 2D array of info). An (OLD) example
I use to have is:

120 ' DATA TABLE
130 ' X 200 460 575 VOLTS
140 ' *******************************
150 DATA 2, 32.2, 34, 27
160 DATA 4, 119.6, 124, 99
170 DATA 6, 220.6, 240, 192
180 DATA 12, 414, 465, 372
190 '
200 DIM UNIT$(4,4)
210 FOR I=1 TO 4
220 READ UNIT$(I,1), UNIT$(I,2), UNIT$(I,3), UNIT$(I,4)
230 NEXT I
240 '

So:
UNIT$(2,2) = 119.6
UNIT$(3,1) = 6
UNIT$(4,3) = 465

..... etc.

Regards,

Bruce
 
Hi Mr B,

Thanks, because I got the idea that it was possible to insert that from a
file on runtime,

This is just a kind of collection

Thanks,

Cor
 
Ron said:
What is the VB equivalent of the READ...DATA statements in
QuickBasic?

Thanks

All,

I had the privilege to work with a man who as a graduate student was one of
the original writers of BASIC -- Dartmouth BASIC. Regrettably, time has
erased both his name and the name of the designer of BASIC from my memory.
He was one of a team of graduate students that wrote the first BASIC
interpreter. I learned from him a bit of history about the language.

It was designed to be a teaching aid. At that time the only programming
language was FORTRAN. If any other of you recall that language (it was the
first one I learned) you will remember that I/O was far from simple. In
fact, the use of I/O statements statements was a complicated area of the
language that required quite a bit of study to learn. As you might
imagine, this lead to difficulties in teaching fundamental programming
concepts. The instructor was required to provide "mystery" code that the
student would write into his program in order to do I/O. External files
were necessary (in a world where mass storage was at a premium). Hard to
teach.

The designer of BASIC wanted to invent a teaching language that taught the
concepts of FORTRAN (the "real" language) in a way that students could
readily grasp. One of the areas that was simplified was I/O. Instead of
having a separate file (as was required in FORTRAN) the data was put right
in the source code in DATA statements.

In addition to simplified I/O it was intended to run interpretively. One
entered the code on a terminal and gave the command $run. It would execute
line by line and stop with an error message indicating which line number
was in error. Output was generated right to the screen! This was a big
improvement over the more typical method of writing, running and debugging
programs. In that era the program was keypunched into cards, the cards
turned in to the lab to be run overnight, and the results returned the next
day. A syntax error lost the student 24 hours.

Regards,
Ot

p.s. If you follow the history parallel, then, and want to recreate DATA
statements, any method that allows you to code the data in the source code
is the equivalent of DATA statements.
 
Back
Top