INC Files.. For Beginners

Aim - to users with an understanding of how to use INC files in the configuration of stock for Open Rails. Based upon information by Sanjay Das.

If you wish to provide any feedback on this page, please use the contact page. It would be great to have some feedback as this helps to ensure the accuracy of the information and models.

Index

Introduction to Open Rails Include Files

Advantages of using Include Files

Challenges with using Include Files

The Include Statement

INC File Content Principles

File Naming Principles

Multiple Call INC Files for Rolling Stock

Single Call INC Files.

Example Aplications.


Introduction to Open Rails Include Files

Include (INC) files in Open Rails are files whose content is copied into a configuration file using an "Include" statement.

Open Rails uses configuration files with user-configurable parameters that define the appearance and behavior of rolling stock (.eng and .wag files), routes (.trk), environment (.env), sound management (.sms) and other objects used in the simulator.

INC files are used to eliminate duplicate code, which may use up many megabytes of disk space in no time at all. For instance rolling stock WAG and ENG configuration files often have groups of parameters with the same values across multiple files. The Include statement makes it possible to maintain these common parameters in a single INC file that can be changed once, and used by multiple configuration files. This method uses an Include statement that looks like this: Include (filepath/filename).

There are a couple of different ways to use the Include statement and these are as follows:

top


Advantages of using Include Files

  • Easier and faster maintenance of parameters and roll-out of common changes. Updating one INC file saves a lot of time compared to updating each individual configuration file.
  • Lower the risk of making mistakes. Duplication of code across multiple files increases the risk of unintended differences. Using INC files ensures that parameter definitions are the same across all configuration files.
  • Concentrating common parameters in INC files saves some disk space.

top


Challenges with using Include Files

There are few restrictions on how to organize the content of INC files and where the files are stored on a user's harddrive. This can make maintaining and debugging configuration files a daunting task. Imagine having to dig through multiple configuration and INC files to find the specific parameter you are looking for.

To overcome above mentioned challenges with INC files, and to make it easier to share INC files with other developers and users, a set of principles are proposed on this webpage, that will ensure a consistent structure and format across developers of INC files. These principles are supported by examples of using and organizing INC files.

Given the many years of history that OR has, content developers have used a number of different approaches to structure INC files. The following suggested principles are provided on the basis of trying to bring some order to the file structure and layout of users OR environment. Some existing stock distributions may require editing to fit within the suggested principles. These changes will be at the discretion of the content developer.

top


The Include Statement

The syntax of the Include statement is:

Include (filepath/filename)

The Open Rails simulator reads the parameter declarations in configuration files from top to bottom. The common parameters defined in an INC file will be inserted into for instance WAG or ENG files at the location of the Include statement. The example below shows how the simulator reads the configuration parameter file with an Include statement.

INC File flowchart

If the same parameter is declared multiple times in an WAG or ENG file, only the last one will be used by ORTS. This also applies to parameters that are defined in INC files. Thus a parameter defined in an INC file will be replaced by defining that same parameter after the Include statement, and vice versa, a parameter that is defined before the Include statement will be replaced when the INC file re-defines that same parameter.

The filepath in the Include statement can be specified by either providing the full path name to the INC file (absolute file path), or a file path relative to the folder that contains the WAG or ENG file that is calling the INC file.

Examples of relative file paths: