Reading And Writing To Files

Article by:
Date Published:
Last Modified:


You have the ability to write to and read from files inside Altium scripts. This can be useful for saving user configuration data that persists between each time the script is run, or providing input/output data for a particular script that needs to interact with the operating system.

The objects of interest are TIniFile.

TIniFile is great for storing category-key-value (or just key-value) information.

INI Files

Creating An INI File

You can create an INI file by using:

var myIniFile
myIniFile = TIniFile.Create(fileName)

where fileName is an absolute path string to the file you wish to create (e.g. C:\Users\MyUser\test.ini).


“Create” is a little misleading. If the file already exists, this function performs more like “open for editing”. It does not delete any information already present in the INI file.

Reading And Writing To INI Files


You can write a boolean-based data point using:

iniFile.WriteBool category, key, trueFalse

where category and key are strings, and trueFalse is a `boolean.

You can read a boolean-based data point from an INI file using:

Dim myBool
myBool = myIniFile.ReadBool(category, key)


Similarly to writing a boolean, you can write a string-based data set using:

iniFile.WriteString category, key, value

where category, key and value are all strings. This will create an INI file which looks like this:


You can read a data set from an INI file using:

value = iniFile.ReadString category, key

Have a look at the file UserData.vbs in the AltiumScriptCentral repo on GitHub for INI file read/write examples.


Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .


    comments powered by Disqus