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.

Dark GDK / Reading From a text file, what to do...

Author
Message
Freedom Fighters
15
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 5th Dec 2009 22:51
well, for my game i need to be able to read from a text file to load data for creating a map.
problem is i cant find something that works in reading a text file.

the built in function are a complete fail. cant read more than one line.

and using the <fstream>

i use this code to load the text file and read from it



and it creates these errors



and im unable to find a file i/o dll that works.

all help would be helpfull.
thank you

Problem Solution That Never Fails: "Build A Bridge And Get Over It"
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 6th Dec 2009 00:55 Edited at: 6th Dec 2009 00:55
Read the error messages, you attempt to use 'string' which I assume it meant to be the string class from the standard library, in which case you need to use std::string or automatically find them by adding: using namespace std; after you include <string> in your source file(assuming you did...).

Also, 'getline()' isn't a global function, it's a method of istream so you need to use: 'MapFile.getline()'. There's probably more issues but they should be similarly easy to see, don't blame the tools!

Freedom Fighters
15
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 6th Dec 2009 03:49
that caused more problems.

i tried file reading and writing in a new project . it worked fine.
when i included the #include "DarkGDK.h"
it stuff up. why does it not work when GDK involved

Erros:


Problem Solution That Never Fails: "Build A Bridge And Get Over It"
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 6th Dec 2009 09:36
You didn't post your code, so no idea!

Also, make sure you create GDK projects using the GDK wizard as it sets various project settings that allow you to compile with GDK.

Freedom Fighters
15
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 7th Dec 2009 02:29
Here the Code i use



Here the Error List



I made this with the GDK wizard. also running it from another GDK project that was empty it came up with the same list

Problem Solution That Never Fails: "Build A Bridge And Get Over It"
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Dec 2009 03:55
put this at the beginning right after the includes:

using namespace std;

also, as was stated above, the getline function is a method of your ifstream variable. use myFile.getline()

That should solve all the errors.

New Site! Check it out \/
Freedom Fighters
15
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 7th Dec 2009 08:12 Edited at: 7th Dec 2009 08:48
Its Fixed. no i see where i went wrong. thanks all for the help.

Problem Solution That Never Fails: "Build A Bridge And Get Over It"
Cetobasilius
14
Years of Service
User Offline
Joined: 29th Dec 2009
Location: Mexico
Posted: 29th Dec 2009 12:45
all that code can be done in less than 10 lines with the "fail" commands of the gdk... you just dont know how to use that command... it reads only one line, because thats what it is meant to do!... just call it again and it will read the next line. you could implement a FOR in combination with dbReadString(numberofyourfile) and it will read all of the lines... and you can use dbFileEnd to specify when the FOR breaks to continue... hope it helps i know dark gdk seems not so good and sometimes can be frustrating but it really gets things done.

hi

Login to post a reply

Server time is: 2024-11-19 09:02:34
Your offset time is: 2024-11-19 09:02:34