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.

Newcomers DBPro Corner / How You read float numbers from file?

Author
Message
Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 1st Jul 2011 14:25
I wish to make a RTS engine which would load any map that is in maps folder and any object(whether it is soldier, vehicle or building) reading all the required data from text files. It would be some kinda open source, open to edit for anyone project.

As David T said
Quote: "
The program will only read floats written there by DB."


Isn't there any way to read floats written with notepad?

If I make a DB program to write into text file, anyone else couldn't make their own models and make it work if they don't have the writing program. Ofc it is not a big problem to add it as a tool into program folder, but it would be easier if can write with notepad

Join The dark Side! We have cookies
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 1st Jul 2011 16:08
You can simply read it in as a string, and then use Val to convert that string into a float.



Hope that helps

Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 1st Jul 2011 17:06
No it doesn't. If use val() it returns 0 if value was 0.5 or 5 if it was 5.5. I checked some functions from "string to float" threads but they return the same.

Here is my function, to read attributes from .dat file (i used .txt before but it is the same result):



Join The dark Side! We have cookies

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Jul 2011 17:24
You are reading your VALues into an integer.
Check Prof's code again, he's reading the VALue into a float.

Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 1st Jul 2011 22:17
Ahh... my fail forgot the #... it works now

Join The dark Side! We have cookies

Login to post a reply

Server time is: 2024-11-22 18:42:30
Your offset time is: 2024-11-22 18:42:30