![]() |
|
get_config_string |
mscava
Member #6,815
January 2006
![]() |
I'm using Allegro 4.2.1 and functiom get_config_string does not work for me. All others do ( int, float ). and I'm sure that section and value exist in my cfg.file ( LogPath = log.txt ) Anyone has any advice? Can this be a bug? Thanks. |
CGamesPlay
Member #2,559
July 2002
![]() |
No, it isn't a bug. Try this code, though. set_config_string("Vars", "LogPath", "set value"); string s = get_config_string("Vars", "LogPath", "Not Read"); As tell me what the value is. -- Ryan Patterson - <http://cgamesplay.com/> |
mscava
Member #6,815
January 2006
![]() |
Yes... It works now. s == "set value" Could you please explain it to me? |
CGamesPlay
Member #2,559
July 2002
![]() |
Can you provide the file as an attachment? -- Ryan Patterson - <http://cgamesplay.com/> |
mscava
Member #6,815
January 2006
![]() |
Here it is EDIT: EDIT2: And I've found out, that it's not gonna read even file into which was written by set_config_string. Pls... help me someone... |
piccolo
Member #3,163
January 2003
![]() |
try that. string s.c_str() = get_config_string("Vars", "LogPath", "Not Read"); Edit: wow |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Piccolo, that has nothing to do with the problem. And that would most probably crash the program. I haven't done much work with the config routines. Try posting the relevant parts of your source.
|
BAF
Member #2,981
December 2002
![]() |
Quote: for a lot of allegro fountions the string must be converted to a char string Yes, when sending values in. But when assigning, string reads from char* just fine. |
mscava
Member #6,815
January 2006
![]() |
Here is my configuration function:
Everything gets initialized, only Log is associated with file 'Not Read'. Well it's the only string that is being loaded in this procedure, so I've tried even: string s = get_config_string("Gfx", "ResolutionWidth", "Not Read"); Log :: SetOutputFile ( s ); But with the same result. Well... I'm attaching my Setup.cfg ( the file that is being read ), so someone else might try it. I'm gonna do some more tests meanwhile... Hopefully I'm gonna find a solution. |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Reading numbers etc work then? How does your CfgFile class look?
|
mscava
Member #6,815
January 2006
![]() |
Yes. Reading numbers works. Really simple wrapper. I want to to add functionality in the future... class CfgFile { public: static void SetCfgFile ( const string& path ); static string ReadString ( const string& section, const string& name ); static int ReadInt ( const string& section, const string& name ); static float ReadFloat ( const string& section, const string& name ); static bool ReadBool ( const string& section, const string& name ); }; And now source file:
In the example I didn't used ReadString, so I'm sure the problem is not in my class. Well... Anyone tried to use my setup.cfg wheter it works. Or even tried to use get_config_string wheter it is not a bug? |
Tomasz Grajewski
Member #4,284
February 2004
|
I've tested your file and it works for me. Also I'm using the get_config_string(); function many times in my custom project and never had problems with it. It's probably bug in your code, sorry. ___________________________________________________________________________________________ |
|