Vruki Salet Posted January 30, 2006 Share Posted January 30, 2006 I have a simple file that's a list of paired keys & values, just like a server config file. Let's call it "stuff.cfg." I want to read the values and assign them to variables. Looking at the way the .sab and .npc files and the others is making my head spin. Will somebody help me here? Like walk me through it or direct me to instructions. Here's a setup to work with: stuff.cfg contains 3 lines like this: fooInt 24 fopInt 0 fooString "yomama" Then I have 3 variables like so: int entNumberFoo int entNumberFop char *fooString I have stuff.cfg read into memory in the name stuffData. How do I parse stuffData so that: entNumberFoo = the value of fooInt entNumberFop = the value of fopInt fooString = the value of fooString ??? BTW there's just one file to parse and no curly braced sections to separate. Being able to deal with // and /* */ comments would be nice but not necessary. Link to comment Share on other sites More sharing options...
Tinny Posted January 30, 2006 Share Posted January 30, 2006 I'm not at all good at this, but have you taken a look at the AOTC_Holocron code in ojp basic repository? It shows pretty cleanly how to do it. It might help. Link to comment Share on other sites More sharing options...
Vruki Salet Posted January 30, 2006 Author Share Posted January 30, 2006 I figured it out using BG_SiegeGetPairedValue like so: BG_SiegeGetPairedValue(stuffData, "key_from_cfgfile", tempBufferVartoHoldData) then used atoi(tempBufferVartoHoldData) if it had to be an int. Thanks though. I'll still check it out to maybe get more understanding. If all goes well I'm going to have to write back to the file later. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.