• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA [C++] loading data in ini files

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi there,

besides my struggle with the fs9gps data, I want to load and later save some data to ini files.

KISS, therefore I tried this:
Code:
	int my_number=GetPrivateProfileInt("GENERAL","number",0,"C:\TEST.DAT");

the TEST.DAT textfile contains:
Code:
[GENERAL]
number=42

but my_number remains "0". What am I missing?

Regards,
Vitus
 
Method for reading integers and float values shown below. Integers are relatively simple. Floats are a little bit more fun:

Code:
// declare your variables:
// path and filename
char total_name[100] = "./blackbox.ini\0";  [COLOR="Red"]// path to ini file[/COLOR]

// integers
UINT32 int_value1;

// floats
CHAR  float_val1[45];
FLOAT64 float_value1;

// read your ini file:

int_value1 = GetPrivateProfileInt("Integers", "Int_Value1", 0, total_name);

GetPrivateProfileString("Floats", "Float_Value1", "0", float_val1, 32, total_name);

// convert string float value to float:

float_value1=atof(float_val1);
 
Last edited:
Yesyesyes! The issue was that I used the backslash instead of a forward-slash.

One question remains: For obvious reasons, I want to use relative paths. Where is my "file cursor" located by default on start up?

Cheers,
Vitus
 
Note the relative path of my variable:

char total_name[100] = "./blackbox.ini\0"; // path to ini file

the single-dot/ relative path is the root folder of FS9 or FSX. Work it out from there... :D
 
Back
Top