Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Trouble opening .txt or .csv for reading in data

Author
Message
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 29th Sep 2003 11:41
Here's my dilemma: I'm using Dark Basic with Dark Edit which allows the use of TYPES. My program starts by reading in a ton of data and storing it in various TYPE formats (Ex.: Aircraft(X).Model, Aircraft(X).Range, etc.). Each line of data is for 1 specific aircraft (it's an airline sim.), so the load array wouldn't be very efficient here. I can load in the data using the simple READ/DATA format but what would be ideal is to put this data into a separate file, OPEN TO READ and then read in that data, allowing easy reconfiguring and modifying in the future. I did a simple test using a few straight integer values and all I got were zeros. Is this just not possible with DB? Thanks in advance. The code attached is the quick test I did.

John
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Sep 2003 16:43
I would'nt usually put all the variables on 1 line in the code - I'd split it into seperate lines. It probably won't make much of a difference though.

What about strings? - I mean, if you make your own setup format, like ''Plane Name=Boeing 747'', you could just load in the text string and look for the '=' character - then left hand side = command, right hand side = string. You could use this to free up the file format making modifications and revisions easy. There's nothing worse than making a lot of files then having to change the format, this way you could just add to it and code for the commands - build on your files rather than have to redo them. Strings would probably be a lot easier to work with too, because each line in the file could be a string that is parsed.


Van-B

My cats breath smells of cat food.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 29th Sep 2003 16:52
It is possible..
looking at your code, you have the READ command which reads the information in your DATA statement
you need something like READ BYTE or one of those commands... Im not good at this sort of thing but thats where your problem is...

Hope i Helped...

If Quizz's Are Quizzical, Then What Are Test's?
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 30th Sep 2003 05:29
I tried READ BYTE and READ STRING and they didn't work either. VanB, I guess I don't understand what you're describing. I'll give a little more info so you can see the full scope of what I'm trying to do.

Basically, I want three databases: Aircraft, Airlines and Airports or cities. Each will be a TYPE with various strings, integers and decimals (REAL?). Here's a small example of the Aircraft TYPE setup.

"Boeing","737-200",120,488,6000,1855,2

The corrosponding variables would be, inside Aircraft(x):
.Manufacturer
.Model
.Seats
.Speed
.Runway
.Range
.Crew

etc., for all data for that aircraft.

I want to use the simple READ/DATA format to just read in all this info into the variables that the game will use. None of this data will be changed by the program, but I do want the ability to allow others to make modifications, such as adding new aircraft configurations, new aircraft, etc. This could be done easily with a simple spreadsheet program and then converting to .csv and then saving and renaming as a .txt with the Aircraft label.

There's tons of variables, so it seems like doing "Plane = 737-200","Seats = 120", etc. would get pretty ugly.
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 30th Sep 2003 05:58
Here's a quick view of what that code would look like. Again, this is the current, working READ/DATA setup and also, keep in mind that the actual TYPES will contain many more variables (sub-types?) such as seat configurations, fuel consumption, delivery time, etc.

Login to post a reply

Server time is: 2025-05-20 14:34:35
Your offset time is: 2025-05-20 14:34:35