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:

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
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:

statickid

CatDog from Deimos
Donator
Joined
Nov 23, 2008
Messages
1,683
Reaction score
4
Points
38
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.
 

dr_evil

New member
Joined
Dec 17, 2014
Messages
2
Reaction score
0
Points
0
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
         }
}
 
Top