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 / how to read this file

Author
Message
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 12th Feb 2010 00:07
I want my game to read file that looks like this

ScreenWidth="1024"
ScreenHeight="768"
ScreenBpp="32"

but so it reads first part until it reaches = or "" and then return the value in "" with different variable how can I do this, or is it even possible to do.

If anyone wants to join my team and help me with development of my sci-fi fps game, please send me an e-mail.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Feb 2010 02:11 Edited at: 12th Feb 2010 23:10
If you really want to keep the file in your first format, you can use or build a couple of custom string functions to return the specific data. I've simulated the resulting strings a$,b$ and c$ as if the were read in using read string filenumber,string$ and then sent them through a custom function to look in between the quotes:



The above function will probably do the trick for a lot of different situations if you know how you are storing stuff in your file. You may want to create a few functions of your own like Instr() or a better mid$() function where you can put in a start and end value.

Or, a much easier way, if you stored your file like this:

ScreenWidth
1024
ScreenHeight
768
ScreenBpp
32

You could just read each line as a string and then convert the numbers using Val(string$).

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Feb 2010 02:15
It's definetly possible. First you open the file and read a string:



then search for the equals. you could make a function like this:



I would suggest not using the quotes. It makes it easier to read. without the quotes here is how you would get the value:



there it is! You should now have your screen width and be able to use it on all the values!

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Feb 2010 02:26
@Caleb
Nice and clean! I guess I tend towards the big productions!

Enjoy your day.
jfroco
14
Years of Service
User Offline
Joined: 1st Dec 2009
Location: Chile
Posted: 12th Feb 2010 02:56
Hello nruser,

I would recommend INI files.

DBPro code for reading and wrinting INI files:
http://forum.thegamecreators.com/?m=forum_view&t=155677&b=6

Using a plugin and using system DLL:
http://forum.thegamecreators.com/?m=forum_view&t=106708&b=18

DLL mode:
http://forum.thegamecreators.com/?m=forum_view&t=14207&b=1

Hope this helps

Best regards
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Feb 2010 05:16
Latch:

Thanks! Your between characters function is useful though!

Your second idea is a lot like a ini file. lol

jfroco:

That's for dbpro this is the dbc board.

Although the Kernel32 functions would probably work. I'm not sure of the speed of them though.

New Site! Check it out \/
nruser
16
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 12th Feb 2010 13:56
ok that works, but how can I convert that string in quotes into an integer value?

If anyone wants to join my team and help me with development of my sci-fi fps game, please send me an e-mail.
sysx
14
Years of Service
User Offline
Joined: 12th Feb 2010
Location:
Posted: 12th Feb 2010 13:59
hai some one pls explain the concept

[URL="http://www.dressuparcade.com"]dress up games for girls[/URL]
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Feb 2010 15:22
Quote: "That's for dbpro this is the dbc board."


Correct - here's the DBC version of reading/writing to INI files:

http://forum.thegamecreators.com/?m=forum_view&t=106556&b=6

TDK

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Feb 2010 16:57 Edited at: 12th Feb 2010 17:01
Small problem with the functions though. On the write functions, they try to use 'open to read' before they create the file. Open to read doesn't create the file. Open to write does.


Not too hard, just add this at the beginning of the write functions:



New Site! Check it out \/
xiaopywsp
13
Years of Service
User Offline
Joined: 23rd Apr 2010
Location:
Posted: 23rd Apr 2010 12:22
Good !this is my need ,thanks a lots!

Login to post a reply

Server time is: 2024-04-18 20:49:18
Your offset time is: 2024-04-18 20:49:18