racer home

Onyx Tutorial - working with ini files

 

Home A simple start.


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

Introduction

Most setting files in the Racer environment are stored in .ini files. These use a tree structure (complete with branch referencing) to define values (numbers and string). There are a number of functions available in Onyx, even core Onyx (onyx_run.exe) that can be used to work with .ini files. (Racer v0.9.0RC8+)

An example script is shown below, which shows how to use them (these are core functions and available also outside of Racer):


//
// Onyx ini functions
//

string s;    // Globally defined

void main()
{
  handle h;
  int n;
  float f;

  // Open the ini file
  h=IniOpen("myfile.ini");

  // Retrieve some values
  n=IniGetInt(h,"test.x",0);
  echo(n);
  f=IniGetFloat(h,"test.y",0);
  echo(f);
  IniGetString(h,"test.s",s,"default_string");
  echo(s);

  IniClose(h);
}

Here is an example of how to use Racer's racer.ini settings. Note that IniGetMain() is not a core function, but only available inside Racer.


//
// Onyx ini functions inside Racer
//

string s;    // Globally defined

void main()
{
  handle h;
  int n;

  // Get a reference to the ini file
  h=IniGetMain();

  // Retrieve some values
  n=IniGetInt(h,"race.max_time_race",0);
  echo(n);

  // No need to close - Racer is responsible for that
}


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated July 24, 2013 )