API Question How to read BEGIN_<blah> section in cfg?

dr_evil

New member
Joined
Dec 17, 2014
Messages
2
Reaction score
0
Points
0
Does anyone knows how to read/write section in the CFG file that surrounded with:

BEGIN_<name>
....
END_<name>

tags?
 
Last edited:
This is explained in Orbiter Manual. Have a look at it, because that's essential stuff to play around with scenarii.

To be more specific, the file you want to look at is : "OrbiterConfig.pdf", located in the /doc folder. It contains all you want to know.
 
Last edited:
Once you get a general idea of what the sections are, you can usually hash together a few quick parameters with the scenario editor dialog, then save various states of your scenario. Once you've done that you can also just copy paste ships, stations, etc. between your save states.
 
Thanks. I actually was asking how to do it in C++, sorry for the confusion.
But I figured it out:

Code:
FILEHANDLE hFile = oapiOpenFile("MyConfig.cfg", FILE_IN, CONFIG);
char *line;

while (oapiReadScenario_nextline(hFile, line))
{
         if (strcmp(line, "BEGIN_MYTAG") == 0)
         {
            bItems = true;
            continue;
         }
         else if (strcmp(line, "END_MYTAG") == 0)
         {
            bItems = false;
         }

         if (bItems)
         {
            std::string sLine = line;
           // Parse line
         }
}
 
Back
Top