# Subprograms

Any program in TRIK Studio can be saved as a subprogram and used in another program.

Subprograms [can be saved](#save) to a local collection or [exported](#export) to a separate file for transfer to other computers.

To work with the collection of subprograms, use the menu item `Tools → Subprograms`:

1. [Export to file](#export).
2. [Import from file](#import).
3. [Save to collection](#save).
4. [Load from the collection](#load).
5. [Clear collection](#delete).

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiNTsjik8e8YlofGuU%2F27%201%20En%20Subprogramms1.png?alt=media\&token=591f3721-ded8-4ee0-9aaa-ae0d72d97427)

## Export to file <a href="#export" id="export"></a>

{% hint style="info" %}
Use the export of subprograms to a file to transfer them to other computers. If you plan to use the subprograms on your computer, then use the option [Save to collection](#save).
{% endhint %}

To export subprograms from an open project to a separate qrs file, select `Tools → Subprograms → Export to file` in the main menu.

All subprograms from the current project will be exported to this file.

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiNYQtANwVxHcN688y%2F27%202%20En%20Subprogramms2%203.png?alt=media\&token=9dbdcc62-4bd7-46dd-bb21-50c56f085643)

## Import from file <a href="#import" id="import"></a>

To load previously-stored subprograms, select `Tools → Subprograms → Import from file` in the main menu.

{% hint style="danger" %}
**Attention!** If the imported file contains subprograms with the same names as in the current project, then the subprograms from the project will be replaced by imported ones.
{% endhint %}

## Save to collection <a href="#save" id="save"></a>

{% hint style="info" %}
To transfer subprograms to other computers, use the [export](#export) function.
{% endhint %}

To save routines from the current project, select `Tools → Routines → Save to Collection` from the main menu.

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiNo7oB2Yq8UG1CXPT%2F27%203%20En%20Subprogramms3%203.png?alt=media\&token=a62d7a82-e3b1-4504-bd47-0db45097ae76)

Then select the subprograms you want to save and click OK.

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiNsojYMiZe8ct4bo-%2F27%204%20En%20Subprogramms4%202.png?alt=media\&token=512833df-e33a-4584-a38b-2f2665377d03)

{% hint style="danger" %}
**Attention!** If there are subprograms with the same names in the collection, they will be overwritten.
{% endhint %}

## Load from collection <a href="#load" id="load"></a>

To load subprograms from the collection, select `Tools → Subprograms → Download` from the collection from the main menu.

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiNxSKr4Ybr-c_mNY9%2F27%205%20En%20Subprogramms5%203.png?alt=media\&token=7ef19312-df35-428b-9e8d-78edb39153f1)

Then select the subprograms that you want to import into the current project, and click OK.

![](https://2483351831-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-9YMGCK0ySSnTAiseS%2F-MSi90rBF6uNtg0g9R-f%2F-MSiO-bIlzZpnjsR5-h_%2F27%206%20En%20Subprogramms6%202.png?alt=media\&token=afc3089c-5a67-4f13-b5af-da7175880aba)

## Clear collection <a href="#delete" id="delete"></a>

To delete all subprograms saved in the collection, select `Tools → Subprograms → Clear` collection in the main menu.

{% hint style="info" %}
The collection of subprograms is stored in the user directory and is not lost when uninstalling or reinstalling TRIK Studio.
{% endhint %}
